@toclocoinc/lattice-grid 1.88.2 → 1.88.3
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 +6 -0
- package/README.md +1 -1
- package/angular/fesm2022/toclocoinc-lattice-grid-angular.mjs +6 -2
- package/angular/package.json +1 -1
- package/angular/types/toclocoinc-lattice-grid-angular.d.ts +3 -1
- package/docs/API.html +62 -6
- 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/deckgl.html +1 -1
- package/docs/api/gantt.html +58 -2
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- 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/mapview.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/presets.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +2 -2
- package/docs/api-detail.html +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/calendar.d.ts +1 -1
- package/modules/calendar.esm.min.js +2 -2
- package/modules/calendar.min.cjs +2 -2
- package/modules/calendar.min.js +2 -2
- 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-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 +2 -2
- package/modules/charts.min.cjs +2 -2
- package/modules/charts.min.js +2 -2
- package/modules/dashboard.d.ts +1 -1
- package/modules/dashboard.esm.min.js +2 -2
- package/modules/dashboard.min.cjs +2 -2
- package/modules/dashboard.min.js +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +1 -1
- package/modules/deckgl.esm.min.js +2 -2
- package/modules/deckgl.min.cjs +2 -2
- package/modules/deckgl.min.js +2 -2
- 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 +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +58 -3
- package/modules/gantt.esm.min.js +223 -217
- package/modules/gantt.esm.min.js.map +2 -2
- package/modules/gantt.min.cjs +222 -216
- package/modules/gantt.min.js +222 -216
- package/modules/gantt.min.js.map +2 -2
- 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 +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +2 -2
- package/modules/leaflet.min.cjs +2 -2
- package/modules/leaflet.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mapview.d.ts +1 -1
- package/modules/mapview.esm.min.js +2 -2
- package/modules/mapview.min.cjs +2 -2
- package/modules/mapview.min.js +2 -2
- 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 +2 -2
- package/modules/presets.min.cjs +2 -2
- package/modules/presets.min.js +2 -2
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.esm.min.js.map +1 -1
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/react.min.js.map +1 -1
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +3 -3
- package/modules/svelte.esm.min.js.map +1 -1
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/svelte.min.js.map +1 -1
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.esm.min.js.map +1 -1
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/vue.min.js.map +1 -1
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +4 -4
- package/modules/webcomponent.esm.min.js.map +1 -1
- package/modules/webcomponent.min.cjs +4 -4
- package/modules/webcomponent.min.js +4 -4
- package/modules/webcomponent.min.js.map +1 -1
- package/package.json +1 -1
package/lattice-grid.min.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.88.
|
|
2
|
+
* Lattice Grid 1.88.3, core + DOM renderer
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
(function(fr){"use strict";var Wn=Object.create(null),_n=Object.create(null);function Le(e,K){Wn[e]=K}function Rn(e){var K=_n[e];if(K)return K;var Q=Object.create(null);_n[e]=Q;var x=Wn[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Rn),Q}Le("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.88.2";async function x(){return Q}const B="1.88.2",I=new Set,_=2e3;function X(ie){if(I.add(ie),I.size>_){const se=I.values().next().value;se!==void 0&&I.delete(se)}}const W=[],V=500;function H(ie,se,he){W.push({key:ie,level:se,message:he.map(ce=>typeof ce=="string"?ce:z(ce)).join(" "),at:Date.now()}),W.length>V&&W.shift()}function z(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function j(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const se=ie[0].replace(/^\[lattice\]\s*/,"");return se===ie[0]?ie:[se,...ie.slice(1)]}function g(ie,...se){if(I.has(ie))return;X(ie);const he=j(se);H(ie,"warn",he),console.warn("[lattice]",...he)}function u(ie,...se){if(I.has(ie))return;X(ie);const he=j(se);H(ie,"info",he),console.info("[lattice]",...he)}function h(){I.clear(),W.length=0}function a(ie,se){const he=new Error(`[lattice] ${ie}`);throw se!==void 0&&(he.cause=se),he}function r(ie,se){ie||a(se)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function o(ie){return typeof ie=="function"}function d(ie){return ie==null}function l(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let se=m.get(ie);if(se)return se;if(!ie.includes("."))se=he=>he?.[ie];else{const he=ie.split("."),ce=he.length;se=te=>{let oe=te;for(let fe=0;fe<ce;fe++){if(oe==null)return;oe=oe[he[fe]]}return oe}}return m.set(ie,se),se}const f=new Map;function s(ie){let se=f.get(ie);if(se)return se;if(!ie.includes("."))se=(he,ce)=>{he!=null&&(he[ie]=ce)};else{const he=ie.split("."),ce=he.length-1;se=(te,oe)=>{let fe=te;for(let de=0;de<ce;de++){if(fe==null)return;const we=he[de];fe[we]==null&&(fe[we]={}),fe=fe[we]}fe!=null&&(fe[he[ce]]=oe)}}return f.set(ie,se),se}function p(ie,se){return c(se)(ie)}function b(ie,se,he){s(se)(ie,he)}function A(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,he=>he.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(ie){const se=ie==null?"":String(ie);return/[&<>"']/.test(se)?se.replace(/[&<>"']/g,he=>k[he]):se}function S(ie){return String(ie).replace(/\w\S*/g,se=>se[0].toUpperCase()+se.slice(1).toLowerCase())}function R(ie,se,he){if(ie!==void 0)return ie===!0?{enabled:!0,...he}:ie===!1?{enabled:!1}:n(ie)?ie:{[se]:ie,enabled:!0}}function O(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ie,se){if(!n(ie))return n(se)?{...se}:se;if(!n(se))return se===void 0?ie:se;const he={...ie};for(const ce of Object.keys(se)){if(F.has(ce))continue;const te=se[ce];te!==void 0&&(he[ce]=n(te)&&n(he[ce])?E(he[ce],te):te)}return he}function T(ie,se){if(!n(ie)||!n(se)||ie===se)return se;const he=Object.create(Object.getPrototypeOf(ie));return Object.assign(he,ie,se),he}class L{#e;#t=new Map;#n;constructor(se=256,he=null){this.#e=se,this.#n=he}get size(){return this.#t.size}get max(){return this.#e}set max(se){this.#e=se,this.#r()}has(se){return this.#t.has(se)}get(se){const he=this.#t;if(!he.has(se))return;const ce=he.get(se);return he.delete(se),he.set(se,ce),ce}peek(se){return this.#t.get(se)}set(se,he){const ce=this.#t;return ce.has(se)&&ce.delete(se),ce.set(se,he),this.#r(),he}delete(se){const he=this.#t.get(se);return this.#t.delete(se)&&this.#n&&this.#n(he,se),he}clear(){if(this.#n)for(const[se,he]of this.#t)this.#n(he,se);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const se=this.#t;for(;se.size>this.#e;){const he=se.keys().next().value,ce=se.get(he);se.delete(he),this.#n&&this.#n(ce,he)}}}const C=new Map;function D(ie,se){const he=`${ie||""}|${se?JSON.stringify(se):""}`;let ce=C.get(he);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...se}),C.set(he,ce)),ce}function $(ie,se){if(ie===se)return 0;if(ie==null)return 1;if(se==null)return-1;if(typeof ie=="number"&&typeof se=="number")return Number.isNaN(ie)?Number.isNaN(se)?0:1:Number.isNaN(se)||ie<se?-1:ie>se?1:0;const he=String(ie),ce=String(se);return he<ce?-1:he>ce?1:0}function P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function N(ie){return v?requestAnimationFrame(ie):setTimeout(()=>ie(P()),16)}function G(ie){ie!=null&&(v?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let se=null,he=null;const ce=()=>{se=null;const oe=he;he=null,ie(...oe||[])},te=(...oe)=>{he=oe,se===null&&(se=N(ce))};return te.cancel=()=>{G(se),se=null,he=null},te.flush=()=>{se!==null&&(G(se),ce())},te}function Z(ie,se){let he=null,ce=null;const te=()=>{if(he=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{he=setTimeout(te,se),typeof he?.unref=="function"&&he.unref()},fe=(...de)=>{he===null?(ie(...de),oe()):(ce=de,clearTimeout(he),oe())};return fe.flush=()=>{if(he!==null&&clearTimeout(he),he=null,ce===null)return;const de=ce;ce=null,ie(...de)},fe.cancel=()=>{he!==null&&clearTimeout(he),he=null,ce=null},fe.pending=()=>he!==null||ce!==null,fe}function J(ie,se=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:se}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function ne(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Le("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=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 W(R,O){const F=Number(R),E=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(F)&&Number.isFinite(E))return F<E?-1:F>E?1:0;const L=String(R??"").toLowerCase(),C=String(O??"").toLowerCase();return L<C?-1:L>C?1:0}function V(R){return R==null||R===""}function H(R,O){if(!O||typeof O!="object")return!1;const{op:F}=O,E=O.value,T=O.value2;switch(F){case"blank":return V(R);case"notBlank":return!V(R);case"true":return R===!0;case"false":return R===!1;default:break}if(V(R))return!1;switch(F){case"eq":return W(R,E)===0;case"ne":return W(R,E)!==0;case"gt":return W(R,E)>0;case"gte":return W(R,E)>=0;case"lt":return W(R,E)<0;case"lte":return W(R,E)<=0;case"between":return W(R,E)>=0&&W(R,T)<=0;case"outside":return W(R,E)<0||W(R,T)>0;case"contains":return String(R).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function z(R,O,F){const E=G=>{const q=String(G).replace("#",""),Z=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Z.slice(J,J+2),16)||0)},[T,L,C]=E(R),[D,$,P]=E(O),v=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*v);return`#${[N(T,D),N(L,$),N(C,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const $=D instanceof Date?D.getTime():Number(D);Number.isFinite($)&&O.push($)}if(!O.length)return null;O.sort((D,$)=>D-$);let F=0,E=0,T=0;for(const D of O){F++;const $=D-E;E+=$/F,T+=$*(D-E)}const L=j(O,.25),C=j(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:E,stddev:O.length>1?Math.sqrt(T/(O.length-1)):0,median:j(O,.5),q1:L,q3:C,iqr:C-L,sorted:O}}function j(R,O){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,O)),E=Math.floor(F),T=Math.ceil(F);return E===T?R[E]:R[E]+(F-E)*(R[T]-R[E])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function u(R,O){const F=Number(R.value),E=T=>j(O.sorted,T);switch(R.op){case"topPercent":{const T=h(F,10);return{op:"gte",value:E(1-T)}}case"bottomPercent":{const T=h(F,10);return{op:"lte",value:E(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,O.sorted.length-T);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(O.sorted.length-1,T-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(F)?F:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(F)?F:2)*O.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-T,value2:O.q3+T}:null}default:return null}}function h(R,O){const F=Number.isFinite(R)?R:O,E=F>1?F/100:F;return Math.max(0,Math.min(1,E))}function a(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:j(O.sorted,h(Number(R.low),5)),max:j(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-F*O.stddev,max:O.mean+F*O.stddev}}return R}function r(R,O){const F=Array.isArray(R)?R:[];return!O||!O.n?F.map(E=>E&&g([E])?{...E,enabled:!1}:E):F.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:a(E.scale,O)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,O)};if(E.iconSet)return{...E,iconSet:n(E.iconSet,O)};if(!E.when||!_.includes(E.when.op))return E;const T=u(E.when,O);return T?{...E,when:T}:{...E,enabled:!1}})}function t(R,O){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,E=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&E!==void 0)return{...R,min:F,max:E};if(R.from==="quantile")return{...R,min:F??j(O.sorted,h(Number(R.low),5)),max:E??j(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??O.mean-T*O.stddev,max:E??O.mean+T*O.stddev}}return{...R,min:F??O.min,max:E??O.max}}function n(R,O){if(Array.isArray(R.thresholds))return R;const F=o(R),E=[];for(let T=1;T<F;T++)E.push(j(O.sorted,T/F));return{...R,thresholds:E}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=s[R.set];return O?O.length:3}function d(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function l(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const F="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 E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let T=0;T<O;T++){const L=T<R?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${E}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?d(String(E)):String(E));const O=R.set||"arrows";if(O==="ratings"){const E=o(R),T=[];for(let L=1;L<=E;L++)T.push(d(m(L,E)));return T}const F=s[O];return F?F.map(d):(B(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),c.map(d))}function A(R){const O=Number(R.min),E=Number(R.max)-O,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",C=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-O)/E))*100,$=E?Math.max(0,Math.min(100,(0-O)/E*100)):0;return P=>{if(V(P))return null;const v=Number(P);if(!Number.isFinite(v)||!E)return null;const N=D(v),G=Math.min(N,$),q=Math.max(N,$),Z=v>=0?T:L;return{backgroundImage:`linear-gradient(to ${C}, transparent ${G}%, ${Z} ${G}%, ${Z} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const O=b(R),F=R.reverse?[...O].reverse():O,E=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*o(R):T;return C=>{if(V(C))return null;const D=Number(C);if(!Number.isFinite(D))return null;let $=0;for(const v of E)D>=v&&$++;const P=F[Math.min($,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),E=Number(R.max),T=E-F,L=O.length-1,C=[];for(let $=0;$<=L;$++)C.push(L?$/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,E)&&D<Math.max(F,E)){const $=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let v=0;v<=L;v++)C[v]=v<=$?$?v/$*P:P:P+(v-$)/(L-$)*(1-P)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return $=>{const P=Number($);if(!Number.isFinite(P)||!T)return null;const v=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&v>C[N+1];)N++;const G=C[N+1]-C[N],q=G>0?(v-C[N])/G:0;return{background:z(O[N],O[N+1],Math.max(0,Math.min(1,q)))}}}function S(R,O=null){const F=g(R)?r(R,O):R,E=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!E.length)return()=>null;const T=E.map(L=>L.scale?{scale:y(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:A(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:k(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const C=L?L.value:void 0;let D=null;for(const $ of T){if(!$.enabled)continue;if($.scale){const v=$.scale(C);v&&(D={...D||{},...v});continue}if(!H(C,$.when))continue;const P=x($.style)?$.style(L):$.style;if(P&&(D={...D||{},...P}),$.stop)break}return D}}}),Le("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],V="+-*/^%(),<>=";class H extends Error{constructor(o,d){super(o),this.name="FormulaError",this.at=d}}function z(n){const o=[];let d=0;for(;d<n.length;){const l=n[d];if(l===" "||l===" "||l===`
|
|
6
|
+
(function(fr){"use strict";var Wn=Object.create(null),_n=Object.create(null);function Le(e,K){Wn[e]=K}function Rn(e){var K=_n[e];if(K)return K;var Q=Object.create(null);_n[e]=Q;var x=Wn[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Rn),Q}Le("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Q="1.88.3";async function x(){return Q}const B="1.88.3",I=new Set,_=2e3;function X(ie){if(I.add(ie),I.size>_){const se=I.values().next().value;se!==void 0&&I.delete(se)}}const W=[],V=500;function H(ie,se,he){W.push({key:ie,level:se,message:he.map(ce=>typeof ce=="string"?ce:z(ce)).join(" "),at:Date.now()}),W.length>V&&W.shift()}function z(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function j(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const se=ie[0].replace(/^\[lattice\]\s*/,"");return se===ie[0]?ie:[se,...ie.slice(1)]}function g(ie,...se){if(I.has(ie))return;X(ie);const he=j(se);H(ie,"warn",he),console.warn("[lattice]",...he)}function u(ie,...se){if(I.has(ie))return;X(ie);const he=j(se);H(ie,"info",he),console.info("[lattice]",...he)}function h(){I.clear(),W.length=0}function a(ie,se){const he=new Error(`[lattice] ${ie}`);throw se!==void 0&&(he.cause=se),he}function r(ie,se){ie||a(se)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function o(ie){return typeof ie=="function"}function d(ie){return ie==null}function l(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let se=m.get(ie);if(se)return se;if(!ie.includes("."))se=he=>he?.[ie];else{const he=ie.split("."),ce=he.length;se=te=>{let oe=te;for(let fe=0;fe<ce;fe++){if(oe==null)return;oe=oe[he[fe]]}return oe}}return m.set(ie,se),se}const f=new Map;function s(ie){let se=f.get(ie);if(se)return se;if(!ie.includes("."))se=(he,ce)=>{he!=null&&(he[ie]=ce)};else{const he=ie.split("."),ce=he.length-1;se=(te,oe)=>{let fe=te;for(let de=0;de<ce;de++){if(fe==null)return;const we=he[de];fe[we]==null&&(fe[we]={}),fe=fe[we]}fe!=null&&(fe[he[ce]]=oe)}}return f.set(ie,se),se}function p(ie,se){return c(se)(ie)}function b(ie,se,he){s(se)(ie,he)}function A(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,he=>he.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(ie){const se=ie==null?"":String(ie);return/[&<>"']/.test(se)?se.replace(/[&<>"']/g,he=>k[he]):se}function S(ie){return String(ie).replace(/\w\S*/g,se=>se[0].toUpperCase()+se.slice(1).toLowerCase())}function R(ie,se,he){if(ie!==void 0)return ie===!0?{enabled:!0,...he}:ie===!1?{enabled:!1}:n(ie)?ie:{[se]:ie,enabled:!0}}function O(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ie,se){if(!n(ie))return n(se)?{...se}:se;if(!n(se))return se===void 0?ie:se;const he={...ie};for(const ce of Object.keys(se)){if(F.has(ce))continue;const te=se[ce];te!==void 0&&(he[ce]=n(te)&&n(he[ce])?E(he[ce],te):te)}return he}function T(ie,se){if(!n(ie)||!n(se)||ie===se)return se;const he=Object.create(Object.getPrototypeOf(ie));return Object.assign(he,ie,se),he}class L{#e;#t=new Map;#n;constructor(se=256,he=null){this.#e=se,this.#n=he}get size(){return this.#t.size}get max(){return this.#e}set max(se){this.#e=se,this.#r()}has(se){return this.#t.has(se)}get(se){const he=this.#t;if(!he.has(se))return;const ce=he.get(se);return he.delete(se),he.set(se,ce),ce}peek(se){return this.#t.get(se)}set(se,he){const ce=this.#t;return ce.has(se)&&ce.delete(se),ce.set(se,he),this.#r(),he}delete(se){const he=this.#t.get(se);return this.#t.delete(se)&&this.#n&&this.#n(he,se),he}clear(){if(this.#n)for(const[se,he]of this.#t)this.#n(he,se);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const se=this.#t;for(;se.size>this.#e;){const he=se.keys().next().value,ce=se.get(he);se.delete(he),this.#n&&this.#n(ce,he)}}}const C=new Map;function D(ie,se){const he=`${ie||""}|${se?JSON.stringify(se):""}`;let ce=C.get(he);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...se}),C.set(he,ce)),ce}function $(ie,se){if(ie===se)return 0;if(ie==null)return 1;if(se==null)return-1;if(typeof ie=="number"&&typeof se=="number")return Number.isNaN(ie)?Number.isNaN(se)?0:1:Number.isNaN(se)||ie<se?-1:ie>se?1:0;const he=String(ie),ce=String(se);return he<ce?-1:he>ce?1:0}function P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function N(ie){return v?requestAnimationFrame(ie):setTimeout(()=>ie(P()),16)}function G(ie){ie!=null&&(v?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let se=null,he=null;const ce=()=>{se=null;const oe=he;he=null,ie(...oe||[])},te=(...oe)=>{he=oe,se===null&&(se=N(ce))};return te.cancel=()=>{G(se),se=null,he=null},te.flush=()=>{se!==null&&(G(se),ce())},te}function Z(ie,se){let he=null,ce=null;const te=()=>{if(he=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{he=setTimeout(te,se),typeof he?.unref=="function"&&he.unref()},fe=(...de)=>{he===null?(ie(...de),oe()):(ce=de,clearTimeout(he),oe())};return fe.flush=()=>{if(he!==null&&clearTimeout(he),he=null,ce===null)return;const de=ce;ce=null,ie(...de)},fe.cancel=()=>{he!==null&&clearTimeout(he),he=null,ce=null},fe.pending=()=>he!==null||ce!==null,fe}function J(ie,se=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:se}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function ne(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Le("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=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 W(R,O){const F=Number(R),E=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(F)&&Number.isFinite(E))return F<E?-1:F>E?1:0;const L=String(R??"").toLowerCase(),C=String(O??"").toLowerCase();return L<C?-1:L>C?1:0}function V(R){return R==null||R===""}function H(R,O){if(!O||typeof O!="object")return!1;const{op:F}=O,E=O.value,T=O.value2;switch(F){case"blank":return V(R);case"notBlank":return!V(R);case"true":return R===!0;case"false":return R===!1;default:break}if(V(R))return!1;switch(F){case"eq":return W(R,E)===0;case"ne":return W(R,E)!==0;case"gt":return W(R,E)>0;case"gte":return W(R,E)>=0;case"lt":return W(R,E)<0;case"lte":return W(R,E)<=0;case"between":return W(R,E)>=0&&W(R,T)<=0;case"outside":return W(R,E)<0||W(R,T)>0;case"contains":return String(R).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function z(R,O,F){const E=G=>{const q=String(G).replace("#",""),Z=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Z.slice(J,J+2),16)||0)},[T,L,C]=E(R),[D,$,P]=E(O),v=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*v);return`#${[N(T,D),N(L,$),N(C,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const $=D instanceof Date?D.getTime():Number(D);Number.isFinite($)&&O.push($)}if(!O.length)return null;O.sort((D,$)=>D-$);let F=0,E=0,T=0;for(const D of O){F++;const $=D-E;E+=$/F,T+=$*(D-E)}const L=j(O,.25),C=j(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:E,stddev:O.length>1?Math.sqrt(T/(O.length-1)):0,median:j(O,.5),q1:L,q3:C,iqr:C-L,sorted:O}}function j(R,O){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,O)),E=Math.floor(F),T=Math.ceil(F);return E===T?R[E]:R[E]+(F-E)*(R[T]-R[E])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function u(R,O){const F=Number(R.value),E=T=>j(O.sorted,T);switch(R.op){case"topPercent":{const T=h(F,10);return{op:"gte",value:E(1-T)}}case"bottomPercent":{const T=h(F,10);return{op:"lte",value:E(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,O.sorted.length-T);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(O.sorted.length-1,T-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(F)?F:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(F)?F:2)*O.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-T,value2:O.q3+T}:null}default:return null}}function h(R,O){const F=Number.isFinite(R)?R:O,E=F>1?F/100:F;return Math.max(0,Math.min(1,E))}function a(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:j(O.sorted,h(Number(R.low),5)),max:j(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-F*O.stddev,max:O.mean+F*O.stddev}}return R}function r(R,O){const F=Array.isArray(R)?R:[];return!O||!O.n?F.map(E=>E&&g([E])?{...E,enabled:!1}:E):F.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:a(E.scale,O)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,O)};if(E.iconSet)return{...E,iconSet:n(E.iconSet,O)};if(!E.when||!_.includes(E.when.op))return E;const T=u(E.when,O);return T?{...E,when:T}:{...E,enabled:!1}})}function t(R,O){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,E=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&E!==void 0)return{...R,min:F,max:E};if(R.from==="quantile")return{...R,min:F??j(O.sorted,h(Number(R.low),5)),max:E??j(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??O.mean-T*O.stddev,max:E??O.mean+T*O.stddev}}return{...R,min:F??O.min,max:E??O.max}}function n(R,O){if(Array.isArray(R.thresholds))return R;const F=o(R),E=[];for(let T=1;T<F;T++)E.push(j(O.sorted,T/F));return{...R,thresholds:E}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=s[R.set];return O?O.length:3}function d(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function l(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const F="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 E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let T=0;T<O;T++){const L=T<R?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${E}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?d(String(E)):String(E));const O=R.set||"arrows";if(O==="ratings"){const E=o(R),T=[];for(let L=1;L<=E;L++)T.push(d(m(L,E)));return T}const F=s[O];return F?F.map(d):(B(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),c.map(d))}function A(R){const O=Number(R.min),E=Number(R.max)-O,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",C=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-O)/E))*100,$=E?Math.max(0,Math.min(100,(0-O)/E*100)):0;return P=>{if(V(P))return null;const v=Number(P);if(!Number.isFinite(v)||!E)return null;const N=D(v),G=Math.min(N,$),q=Math.max(N,$),Z=v>=0?T:L;return{backgroundImage:`linear-gradient(to ${C}, transparent ${G}%, ${Z} ${G}%, ${Z} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const O=b(R),F=R.reverse?[...O].reverse():O,E=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*o(R):T;return C=>{if(V(C))return null;const D=Number(C);if(!Number.isFinite(D))return null;let $=0;for(const v of E)D>=v&&$++;const P=F[Math.min($,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),E=Number(R.max),T=E-F,L=O.length-1,C=[];for(let $=0;$<=L;$++)C.push(L?$/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,E)&&D<Math.max(F,E)){const $=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let v=0;v<=L;v++)C[v]=v<=$?$?v/$*P:P:P+(v-$)/(L-$)*(1-P)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return $=>{const P=Number($);if(!Number.isFinite(P)||!T)return null;const v=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&v>C[N+1];)N++;const G=C[N+1]-C[N],q=G>0?(v-C[N])/G:0;return{background:z(O[N],O[N+1],Math.max(0,Math.min(1,q)))}}}function S(R,O=null){const F=g(R)?r(R,O):R,E=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!E.length)return()=>null;const T=E.map(L=>L.scale?{scale:y(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:A(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:k(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const C=L?L.value:void 0;let D=null;for(const $ of T){if(!$.enabled)continue;if($.scale){const v=$.scale(C);v&&(D={...D||{},...v});continue}if(!H(C,$.when))continue;const P=x($.style)?$.style(L):$.style;if(P&&(D={...D||{},...P}),$.stop)break}return D}}}),Le("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",B="ref",I="name",_="op",X="end",W=["<=",">=","<>","!="],V="+-*/^%(),<>=";class H extends Error{constructor(o,d){super(o),this.name="FormulaError",this.at=d}}function z(n){const o=[];let d=0;for(;d<n.length;){const l=n[d];if(l===" "||l===" "||l===`
|
|
7
7
|
`||l==="\r"){d++;continue}if(l>="0"&&l<="9"){d=j(n,d,o);continue}if(l==="."&&n[d+1]>="0"&&n[d+1]<="9"){d=j(n,d,o);continue}if(l==='"'||l==="'"){d=g(n,d,o);continue}if(l==="["){const m=n.indexOf("]",d+1);if(m<0)throw new H("a [column reference] was opened and never closed",d);o.push({kind:B,value:n.slice(d+1,m).trim(),at:d}),d=m+1;continue}if(w(l)){d=u(n,d,o);continue}const i=n.slice(d,d+2);if(W.includes(i)){o.push({kind:_,value:i==="!="?"<>":i,at:d}),d+=2;continue}if(V.includes(l)){o.push({kind:_,value:l,at:d}),d++;continue}throw new H(`unexpected character ${JSON.stringify(l)}`,d)}return o.push({kind:X,value:null,at:n.length}),o}function w(n){return/[A-Za-z_À-]/.test(n)}function j(n,o,d){let l=o,i=!1;for(;l<n.length;){const m=n[l];if(m>="0"&&m<="9"){l++;continue}if(m==="."&&!i){i=!0,l++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(n[l+1]||"")){for(l+=2;l<n.length&&n[l]>="0"&&n[l]<="9";)l++;break}break}return d.push({kind:Q,value:Number(n.slice(o,l)),at:o}),l}function g(n,o,d){const l=n[o];let i=o+1,m="";for(;i<n.length;){if(n[i]===l){if(n[i+1]===l){m+=l,i+=2;continue}return d.push({kind:x,value:m,at:o}),i+1}m+=n[i],i++}throw new H("a string was opened and never closed",o)}function u(n,o,d){let l=o;for(;l<n.length&&/[A-Za-z0-9_.À-]/.test(n[l]);)l++;const i=n.slice(o,l);let m=l;for(;m<n.length&&n[m]===" ";)m++;return d.push({kind:n[m]==="("?I:B,value:i,at:o}),l}const h={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(n){const o=String(n??"").replace(/^\s*=/,"");if(!o.trim())throw new H("the formula is empty");const d=z(o);let l=0;const i=()=>d[l],m=()=>d[l++],c=y=>{const S=i();if(S.kind!==_||S.value!==y)throw new H(`expected ${JSON.stringify(y)}`,S.at);l++},f=y=>{let S=s();for(;;){const R=i();if(R.kind!==_)break;const O=h[R.value];if(!O||O<y)break;l++;const F=f(R.value==="^"?O:O+1);S={kind:"bin",op:R.value,left:S,right:F}}return S},s=()=>{const y=i();return y.kind===_&&(y.value==="-"||y.value==="+")?(l++,{kind:"unary",op:y.value,arg:s()}):p()},p=()=>{let y=b();for(;i().kind===_&&i().value==="%";)l++,y={kind:"unary",op:"%",arg:y};return y},b=()=>{const y=m();if(y.kind===Q)return{kind:"num",value:y.value};if(y.kind===x)return{kind:"str",value:y.value};if(y.kind===B)return{kind:"ref",name:y.value};if(y.kind===I){c("(");const S=[];if(!(i().kind===_&&i().value===")"))for(;;){if(S.push(f(1)),i().kind===_&&i().value===","){l++;continue}break}return c(")"),{kind:"call",name:String(y.value).toUpperCase(),args:S}}if(y.kind===_&&y.value==="("){const S=f(1);return c(")"),S}throw y.kind===X?new H("the formula ends unexpectedly",y.at):new H(`unexpected ${JSON.stringify(y.value)}`,y.at)},A=f(1),k=i();if(k.kind!==X)throw new H(`unexpected ${JSON.stringify(k.value)}: is an operator missing?`,k.at);return A}function r(n){const o=new Set,d=l=>{if(!(!l||typeof l!="object")){if(l.kind==="ref"){o.add(String(l.name));return}if(l.kind==="bin"){d(l.left),d(l.right);return}if(l.kind==="unary"){d(l.arg);return}if(l.kind==="call")for(const i of l.args)d(i)}};return d(n),[...o]}function t(n){return typeof n=="string"&&/^\s*=/.test(n)&&n.trim()!=="="}}),Le("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return j}});const x=K("packages/core/src/formula/parse.js").FormulaError;function B(g){if(g==null||g==="")return 0;if(typeof g=="boolean")return g?1:0;if(g instanceof Date)return g.getTime();const u=typeof g=="number"?g:Number(String(g).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new x(`${JSON.stringify(g)} is not a number`);return u}function I(g){return g==null?"":String(g)}function _(g){if(typeof g=="boolean")return g;if(g==null||g==="")return!1;if(typeof g=="number")return g!==0;const u=String(g).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function X(g){const u=[];for(const h of g){if(Array.isArray(h)){for(const a of h)a!=null&&a!==""&&u.push(B(a));continue}h==null||h===""||u.push(B(h))}return u}function W(g,u){const h=10**u,a=g*h;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/h}function V(g,u){if(!g.length)return 0;const h=g.slice().sort((n,o)=>n-o),a=(h.length-1)*Math.min(1,Math.max(0,u)),r=Math.floor(a),t=Math.ceil(a);return r===t?h[r]:h[r]+(a-r)*(h[t]-h[r])}function H(g,u){let h=0,a=0,r=0;for(const n of g){h++;const o=n-a;a+=o/h,r+=o*(n-a)}const t=u?h-1:h;return t>0?Math.sqrt(r/t):0}const z={SUM:g=>X(g).reduce((u,h)=>u+h,0),AVERAGE:g=>{const u=X(g);return u.length?u.reduce((h,a)=>h+a,0)/u.length:0},MIN:g=>{const u=X(g);return u.length?Math.min(...u):0},MAX:g=>{const u=X(g);return u.length?Math.max(...u):0},COUNT:g=>X(g).length,PRODUCT:g=>X(g).reduce((u,h)=>u*h,1),ROUND:g=>W(B(g[0]),g.length>1?B(g[1]):0),ROUNDDOWN:g=>{const u=10**(g.length>1?B(g[1]):0),h=B(g[0])*u;return(h<0?Math.ceil(h):Math.floor(h))/u},ROUNDUP:g=>{const u=10**(g.length>1?B(g[1]):0),h=B(g[0])*u;return(h<0?Math.floor(h):Math.ceil(h))/u},ABS:g=>Math.abs(B(g[0])),FLOOR:g=>Math.floor(B(g[0])),CEILING:g=>Math.ceil(B(g[0])),SQRT:g=>Math.sqrt(B(g[0])),POWER:g=>B(g[0])**B(g[1]),MOD:g=>{const u=B(g[1]);if(u===0)throw new x("MOD by zero");return(B(g[0])%u+u)%u},IF:g=>_(g[0])?g[1]:g.length>2?g[2]:!1,AND:g=>g.every(_),OR:g=>g.some(_),NOT:g=>!_(g[0]),COALESCE:g=>g.find(u=>u!=null&&u!=="")??null,CONCAT:g=>g.map(I).join(""),LEN:g=>I(g[0]).length,UPPER:g=>I(g[0]).toUpperCase(),LOWER:g=>I(g[0]).toLowerCase(),TRIM:g=>I(g[0]).trim(),LEFT:g=>I(g[0]).slice(0,g.length>1?B(g[1]):1),RIGHT:g=>{const u=g.length>1?B(g[1]):1;return u<=0?"":I(g[0]).slice(-u)},MEDIAN:g=>V(X(g),.5),PERCENTILE:g=>{const u=B(g[g.length-1]);return V(X(g.slice(0,-1)),u>1?u/100:u)},QUARTILE1:g=>V(X(g),.25),QUARTILE3:g=>V(X(g),.75),STDEV:g=>H(X(g),!0),STDEVP:g=>H(X(g),!1),VAR:g=>{const u=H(X(g),!0);return u*u},VARP:g=>{const u=H(X(g),!1);return u*u},COUNTDISTINCT:g=>{const u=new Set;for(const h of g){const a=Array.isArray(h)?h:[h];for(const r of a)r!=null&&r!==""&&u.add(r)}return u.size},IQR:g=>{const u=X(g);return V(u,.75)-V(u,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function w(g,u){const h=Number(g),a=Number(u);if(g!==null&&g!==""&&u!==null&&u!==""&&Number.isFinite(h)&&Number.isFinite(a))return h<a?-1:h>a?1:0;const t=I(g).toLowerCase(),n=I(u).toLowerCase();return t<n?-1:t>n?1:0}function j(g,u={}){const h=typeof u.lookup=="function"?u.lookup:null,a=u.functions?{...z,...u.functions}:z,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!h)throw new x(`there is no column called ${JSON.stringify(t.name)} here`);const n=h(String(t.name));if(n===void 0)throw new x(`there is no column called ${JSON.stringify(t.name)}`);return n}case"unary":{if(t.op==="%")return B(r(t.arg))/100;const n=B(r(t.arg));return t.op==="-"?-n:n}case"bin":{const n=t.op;if(n==="=")return w(r(t.left),r(t.right))===0;if(n==="<>")return w(r(t.left),r(t.right))!==0;if(n==="<")return w(r(t.left),r(t.right))<0;if(n==="<=")return w(r(t.left),r(t.right))<=0;if(n===">")return w(r(t.left),r(t.right))>0;if(n===">=")return w(r(t.left),r(t.right))>=0;const o=B(r(t.left)),d=B(r(t.right));if(n==="+")return o+d;if(n==="-")return o-d;if(n==="*")return o*d;if(n==="^")return o**d;if(n==="/"){if(d===0)throw new x("division by zero");return o/d}throw new x(`unknown operator ${JSON.stringify(n)}`)}case"call":{const n=a[t.name];if(typeof n!="function")throw new x(`there is no function called ${t.name}`);return n(t.args.map(r),u)}default:throw new x("the formula could not be read")}};return r(g)}}),Le("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/formula/parse.js"),x=Q.parseFormula,B=Q.referencesOf,I=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),V=W.evaluateAst,H=W.FUNCTIONS;function z(j){const{grid:g,row:u,data:h}=j||{},a=d=>String(d).toLowerCase().replace(/[\s_-]/g,""),r=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,n=t&&typeof t.isReadable=="function"?d=>t.isReadable(d):()=>!0,o=new Set;for(const d of r)n(d)||(o.add(a(d.id)),d.field&&o.add(a(d.field)),d.title&&o.add(a(d.title)));return d=>{const l=a(d);if(o.has(l))throw new _(`"${d}" cannot be read`);for(const i of r)if(a(i.id)===l||i.field&&a(i.field)===l||i.title&&a(i.title)===l)return u&&g.rows&&typeof g.rows.value=="function"?g.rows.value(u.key,i.id):h?h[i.field||i.id]:void 0;if(h&&typeof h=="object"){for(const i of Object.keys(h))if(a(i)===l){if(!n(i))throw new _(`"${d}" cannot be read`);return h[i]}}}}function w(j,g={}){try{const u=x(j);return{ok:!0,value:V(u,{lookup:z(g),functions:g.formulaFunctions}),references:B(u)}}catch(u){return{ok:!1,error:u instanceof _?u.message:"the formula could not be read",at:u instanceof _?u.at:void 0}}}}),Le("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),x=Q.isObject,B=Q.merge,I=Q.warnOnce;let _=null;class X extends Error{}function W(z,w=new Set){if(Array.isArray(z)){if(w.has(z))throw new X;w.add(z);const g=z.map(u=>W(u,w));return w.delete(z),g}if(!x(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(w.has(z))throw new X;w.add(z);const j={};for(const[g,u]of Object.entries(z))j[g]=W(u,w);return w.delete(z),j}function V(z){if(z===void 0)return W(_??{});if(z===null)return _=null,{};if(!x(z))return I("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(z)?"an array":typeof z}. The call was ignored and the defaults are unchanged.`),W(_??{});try{_=W(z)}catch(w){if(!(w instanceof X))throw w;return I("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."),W(_??{})}return W(_)}function H(z){return _===null?z:B(W(_),z)}}),Le("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const Q=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","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:menu:open","columns:changed","columns:tagged","columngroup:changed","header: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"]),x=new Set(Q);function B(I){return I==="*"||x.has(I)}}),Le("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.uid,I=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function V(h,a){!I||X(a)||x(`bus.unknown:${a}`,`${h}('${a}') 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 H=new Set(["api","user","init","ai"]),z=new WeakMap;function w(h){let a=z.get(h);return a||(a=B("h"),z.set(h,a)),a}function j(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(h){if(!h||typeof h!="object")return{};const a={};for(const[r,t]of Object.entries(h))r!=="grid"&&(t==null?a[r]=String(t):Array.isArray(t)?a[r]=`[${t.length}]`:typeof t=="object"?a[r]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?a[r]="[function]":a[r]=String(t).slice(0,60));return a}class u{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(a=null){this.#i=a}attach(a){this.#i=a}get grid(){return this.#i}get destroyed(){return this.#s}on(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`on('${a}') needs a function; ignored.`),()=>{};V("on",a);let t=this.#e.get(a);return t||(t=[],this.#e.set(a,t)),t.push(r),()=>this.off(a,r)}once(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`once('${a}') needs a function; ignored.`),()=>{};V("once",a);const t=n=>{this.off(a,r),r(n)};return this.#o.set(r,t),this.on(a,t)}off(a,r){if(r===void 0){this.#e.delete(a);return}const t=this.#e.get(a);if(!t)return;const n=this.#o.get(r),o=n&&t.includes(n)?n:r,d=t.indexOf(o);d>=0&&t.splice(d,1),n&&o===n&&this.#o.delete(r),t.length===0&&this.#e.delete(a)}count(a){const r=this.#e.get(a),t=a===W?null:this.#e.get(W);return(r?r.length:0)+(t?t.length:0)}#a(a,r,t,n,o){this.#n.push({type:a,origin:r,listeners:(n?n.length:0)+(o?o.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(a,r){this.#t=!!a,Number.isFinite(r)&&r>0&&(this.#r=Math.floor(r)),a||(this.#n=[])}eventLog(){return this.#n.map(a=>({...a}))}clearEventLog(){this.#n=[]}counts(){const a={};for(const[r,t]of this.#e)a[r]=t.length;return a}emit(a,r,t){const n=t??(r&&r.origin),o=H.has(n)?n:"api",d={...r||null,type:a,origin:o,grid:this.#i};if(this.#s)return d;const l=this.#e.get(a),i=a===W?void 0:this.#e.get(W);if(this.#t&&this.#a(a,o,r,l,i),!l&&!i)return d;const m=this.#t?j():0;this.#l++;try{l&&this.#u(l.slice(),d,a),i&&this.#u(i.slice(),d,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=j()-m)}return d}emitBefore(a,r,t){const n=t??(r&&r.origin),o=H.has(n)?n:"user";let d=!1,l=null;const i=b=>{d=!0,b!=null&&l===null&&(l=String(b))},m={...r||null,type:a,origin:o,grid:this.#i,get defaultPrevented(){return d},get reason(){return l},preventDefault(b){i(b)}};if(this.#s)return!0;const c=this.#e.get(a);this.#t&&this.#a(a,o,r,c,void 0);const f=c?c.slice():[];if(f.length===0)return!0;const s=()=>(d&&l===null&&(l="prevented"),d&&r&&typeof r=="object"&&(r.reason=l),!d),p=[];for(const b of f)try{const A=b(m);A&&typeof A.then=="function"?p.push(A):A===!1&&i("prevented")}catch(A){i("error"),x(`bus.beforeThrow:${a}:${w(b)}`,`a '${a}' before-handler threw; the action was cancelled.`,A)}return p.length===0?s():Promise.allSettled(p).then(b=>{for(const A of b)A.status==="rejected"?(i("error"),x(`bus.beforeReject:${a}`,`a '${a}' before-handler rejected; the action was cancelled.`,A.reason)):A.value===!1&&i("prevented");return s()})}#u(a,r,t){for(let n=0;n<a.length;n++)try{a[n](r)}catch(o){x(`bus.throw:${t}:${w(a[n])}`,`a '${t}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Le("packages/core/src/registry/free-tier-notice.js",function(e,K){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Q}});const Q="Free for non-commercial use: latticegrid.dev/free"}),Le("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return F}});const x=K("packages/core/src/internal/util.js").warnOnce,B=K("packages/core/src/registry/free-tier-notice.js"),I=B.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return B.FREE_TIER_NOTICE}});const _="lattice-grid",X=1,W="LG1",V=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",w=(()=>{const E=new Int16Array(128).fill(-1);for(let T=0;T<z.length;T++)E[z.charCodeAt(T)]=T;return E[43]=62,E[47]=63,E})();function j(E){if(typeof E!="string")return null;let T="";for(let v=0;v<E.length;v++){const N=E.charCodeAt(v);if(N!==61){if(N>127||w[N]<0)return null;T+=E[v]}}const L=T.length;if(L%4===1)return null;const C=new Uint8Array(Math.floor(L*3/4));let D=0,$=0,P=0;for(let v=0;v<L;v++)D=D<<6|w[T.charCodeAt(v)],$+=6,$>=8&&($-=8,C[P++]=D>>$&255);return P===C.length?C:C.subarray(0,P)}function g(E){let T="",L=0;for(;L+2<E.length;L+=3){const D=E[L]<<16|E[L+1]<<8|E[L+2];T+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]+z[D&63]}const C=E.length-L;if(C===1){const D=E[L]<<16;T+=z[D>>18&63]+z[D>>12&63]}else if(C===2){const D=E[L]<<16|E[L+1]<<8;T+=z[D>>18&63]+z[D>>12&63]+z[D>>6&63]}return T}function u(E){const T=new Uint8Array(E.length);for(let L=0;L<E.length;L++)T[L]=E.charCodeAt(L)&127;return T}function h(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let T="";for(let L=0;L<E.length;L++)T+=String.fromCharCode(E[L]);return T}function a(E){const T={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{...T,reason:"missing"};const L=E.trim(),C=L.split(".");if(C.length!==3)return T;const[D,$,P]=C;if(D!==W)return{...T,reason:"prefix"};const v=j($),N=j(P);if(!v||!N)return T;let G;try{G=JSON.parse(h(v))}catch{return T}return G===null||typeof G!="object"?T:{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:u($),signature:N,raw:L}}function r(E,T){if(!E)return!1;const L=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(L)?!0:T>L}function t(E){return E==="non-commercial"?"non-commercial":"commercial"}let n=null,o=null,d=null;function l(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function i(E){if(n&&o===E)return n;const T=l();if(!T)return null;const L=j(E);if(!L)return null;try{const C=await T.importKey("raw",L,{name:"Ed25519"},!1,["verify"]);return n=C,o=E,C}catch{return null}}async function m(){return d!==null||(d=await i(H)!==null),d}async function c(E,T={}){const L=T.warn!==!1,C=T.product||_,D=T.publicKey||H,$=T.now??Date.now(),P=T.host??s(),v=f(P)?"":` ${I}`,N=a(E);if(!N.ok){const ee=N.reason==="missing"?"missing":"malformed";return L&&x(`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.${v}`:`licence key could not be read. The grid will render with a watermark.${v}`),{valid:!1,reason:ee,terms:"commercial"}}const G={product:N.product||void 0,issuedTo:N.issuedTo||void 0,expires:N.expires||void 0,terms:t(N.terms)};if(N.product!==C)return L&&x("licence.product",`licence key is for '${N.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(r(N.expires,$))return L&&x("licence.expired",`licence expired on ${N.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const q=N.deployments||[];if(q.length&&P&&!f(P)&&!p(P,q))return L&&x("licence.domain",`licence key is not valid for ${P}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Z=await i(D);if(!Z){const ee=!!N.signature&&N.signature.length===V;return L&&x("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 J=!1;try{J=await l().verify({name:"Ed25519"},Z,N.signature,N.message)}catch{J=!1}return J?{valid:!0,...G}:(L&&x("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function f(E){const T=String(E??s()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!T||T==="localhost"||T.endsWith(".localhost")||T==="::1"||T==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(T)}function s(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function p(E,T){const L=b(E);return!L||!Array.isArray(T)?!1:T.some(C=>{const D=b(C);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const $=D.slice(2);return L===$||L.endsWith(`.${$}`)}return L===D})}function b(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class A{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#o;#i=new Set;constructor(T={}){this.#o=T}set(T){this.#e=typeof T=="string"?T.trim():"";const L=a(this.#e);return this.#t=L.ok?{valid:!r(L.expires,Date.now())&&L.product===(this.#o.product||_),product:L.product||void 0,issuedTo:L.issuedTo||void 0,expires:L.expires||void 0,terms:t(L.terms),reason:"pending"}:{valid:!1,reason:L.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const T=this.#e;return this.#n=c(T,this.#o).then(L=>{if(this.#e===T){this.#t=L;for(const C of this.#i)C(L)}return L}),this.#n}onSettled(T){return this.#i.add(T),()=>this.#i.delete(T)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(T){this.#r=T}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const k=new A;function y(E){return k.set(E)}function S(){return k.info()}function R(){return k.watermark()}function O(){return k.state()}function F(){return k}}),Le("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isFunction,I=Q.DEV,_=K("packages/core/src/registry/licence.js"),X=_.LicenceHolder,W=_.sharedLicence,V=["renderer","editor","filter","dataType","totalFn","pipe","component"],H=["all","header","body","totals","panels"];class z{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(o={}){for(const d of V)this.#t.set(d,new Map);this.#o=o.holder||W(),this.#s=o.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),o.licence&&this.setLicence(o.licence)}registerModules(o,d={}){d.licence&&this.setLicence(d.licence),d.grid!==void 0&&(this.#s=d.grid);const l=Array.isArray(o)?o:[o],i=[];for(const m of l){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){x("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(m.name)){I&&this.#c(this.#e.get(m.name),m);continue}if(!B(m.install)){x(`registry.module.install:${m.name}`,`module '${m.name}' has no install() and was ignored.`);continue}const c={registry:this,grid:this.#s};try{m.install(c)}catch(f){x(`registry.module.throw:${m.name}`,`module '${m.name}' threw during install; it was not registered.`,f);continue}this.#e.set(m.name,m);for(const f of w(m))this.#n.add(f);i.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:u(m)})}return i}unregisterModule(o){const d=this.#e.get(o);if(!d)return!1;if(B(d.uninstall))try{d.uninstall({registry:this,grid:this.#s})}catch(l){x(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,l)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:u(d)}),!0}modules(){return[...this.#e.values()]}has(o){return this.#e.has(o)}#u(){this.#n.clear();for(const o of this.#e.values())for(const d of w(o))this.#n.add(d)}#c(o,d){!o||o===d||j(o,d)||x(`registry.module.reconfigure:${d.name}`,`module '${d.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(o){return this.#n.has(o)}onChange(o){return B(o)?(this.#r.add(o),this.#a.set(o,this.#s),()=>{this.#r.delete(o),this.#a.delete(o)}):()=>{}}#d(o){for(const d of[...this.#r])try{d(o)}catch(l){x("registry.onChange.throw","a registry change handler threw.",l)}}register(o,d,l){const i=this.#t.get(o);if(!i){x(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${V.join(", ")}.`);return}if(!d||typeof d!="string"){x(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}i.has(d)&&i.get(d)!==l&&x(`registry.replace:${o}:${d}`,`'${d}' was already registered as a ${o} and has been replaced.`),i.set(d,l),this.#d({reason:"register",name:d,kind:o,capabilities:this.capabilities(),regions:h(o)})}registerAll(o,d){if(d)for(const l of Object.keys(d))this.register(o,l,d[l])}get(o,d){const l=this.#t.get(o);return l?l.get(d):void 0}names(o){const d=this.#t.get(o);return d?[...d.keys()]:[]}#h(o,d){const l=this.#t.get(o).get(d);return l!==void 0?l:this.#t.get("component").get(d)}renderer(o){return this.#h("renderer",o)}editor(o){return this.#h("editor",o)}filter(o){return this.#h("filter",o)}dataType(o){return this.get("dataType",o)}totalFn(o){return this.get("totalFn",o)}pipe(o){return this.get("pipe",o)}setLicence(o){return this.#o.set(o)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(o){o!=null&&(this.#l.add(o),this.#s=o)}detach(o){if(o!=null){this.#l.delete(o);for(const[d,l]of[...this.#a])l===o&&(this.#r.delete(d),this.#a.delete(d));if(this.#s===o){const d=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=d}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const d of[...this.#e.keys()])this.unregisterModule(d);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function w(n){const o=n.capabilities,d=Array.isArray(o)?o.filter(l=>typeof l=="string"):[];return[n.name,...d]}function j(n,o){return n.install!==o.install||n.uninstall!==o.uninstall||(n.version||"")!==(o.version||"")?!1:g(w(n),w(o))&&g(u(n),u(o))}function g(n,o){const d=new Set(n),l=new Set(o);if(d.size!==l.size)return!1;for(const i of d)if(!l.has(i))return!1;return!0}function u(n){const o=n.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(d=>H.includes(d))}function h(n){switch(n){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const a=new z;function r(){return a}function t(n,o={}){return a.registerModules(n,o)}}),Le("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const x=K("packages/core/src/internal/util.js").isNil;function B(I,_){const X=I||{},W=X.locale||_||void 0,V=X.style||"decimal",H=typeof X.scale=="number"?X.scale:1,z=X.nullDisplay??"",w=X.zeroDisplay,j=X.prefix||"",g=X.suffix||"",u=X.negative||"minus",h=X.signed===!0,a={style:V,notation:X.notation||"standard"};V==="currency"&&(a.currency=X.currency||"USD",X.currencyDisplay&&(a.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(a.minimumFractionDigits=X.decimals,a.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(a.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(a.maximumFractionDigits=X.maxDecimals),a.minimumFractionDigits>(a.maximumFractionDigits??20)&&(a.maximumFractionDigits=a.minimumFractionDigits)),X.thousandsSeparator===!1&&(a.useGrouping=!1),a.notation==="compact"&&(a.compactDisplay=X.compactDisplay||"short");const r=new Intl.NumberFormat(W,a),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,n=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let o=",",d=".";if(t||n)for(const s of r.formatToParts(12345.6))s.type==="group"?o=s.value:s.type==="decimal"&&(d=s.value);const l=s=>{let p=s;return t&&(p=p.split(o).join("")),n&&(p=p.split(d).join("")),t&&(p=p.split("").join(t)),n&&(p=p.split("").join(n)),p},i=!!(t||n),m=j!==""&&V==="currency",c=s=>{let p;if(m){const b=r.formatToParts(s);let A=!1;p="";for(const k of b)p+=k.value,!A&&k.type==="currency"&&(p+=j,A=!0);A||(p=j+p)}else p=j+r.format(s);return i&&(p=l(p)),p+g},f=s=>{if(x(s)||s==="")return z;const p=typeof s=="number"?s:Number(s);if(Number.isNaN(p))return z;const b=H===1?p:p*H;return b===0&&w!==void 0?w:b<0?u==="parentheses"?`(${c(-b)})`:u==="suffix"?`${c(-b)}-`:c(b):h&&b>0?`+${c(b)}`:c(b)};return f.negativeClass=X.negativeClass||null,f.spec=X,f}}),Le("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return r}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.warnOnce,I=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const n=[];let o=0,d="";const l=()=>{d&&(n.push({token:null,text:d}),d="")};for(;o<t.length;){const i=t[o];if(i==="'"){if(t[o+1]==="'"){d+="'",o+=2;continue}const c=t.indexOf("'",o+1);if(c===-1){d+=t.slice(o+1),o=t.length;continue}d+=t.slice(o+1,c),o=c+1;continue}const m=I.find(c=>t.startsWith(c,o));if(m){l(),n.push({token:m,text:m}),o+=m.length;continue}/[A-Za-z]/.test(i)&&B(`date.pattern.token:${i}`,`the date pattern "${t}" 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(" ")}.`),d+=i,o+=1}return l(),n}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if(x(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const n=X.exec(t.trim());if(n){const[,d,l,i,m="0",c="0",f="0"]=n;return new Date(+d,+l-1,+i,+m,+c,+f)}const o=new Date(t);return Number.isNaN(o.getTime())?null:o}return null}function V(t,n){return String(t).padStart(n,"0")}function H(t){if(!t)return d=>({year:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),ms:d.getMilliseconds(),weekday:d.getDay()});const n=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return d=>{const l={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:d.getMilliseconds(),weekday:0};for(const i of n.formatToParts(d))switch(i.type){case"year":l.year=Number(i.value);break;case"month":l.month=Number(i.value);break;case"day":l.day=Number(i.value);break;case"hour":l.hour=Number(i.value)%24;break;case"minute":l.minute=Number(i.value);break;case"second":l.second=Number(i.value);break;case"weekday":l.weekday=o[i.value]??0;break;default:break}return l}}function z(t,n,o){const d=_(t),l=H(o),i=new Set(d.filter(p=>p.token).map(p=>p.token)),m=i.has("MMM")?new Intl.DateTimeFormat(n,{month:"short",timeZone:o}):null,c=i.has("MMMM")?new Intl.DateTimeFormat(n,{month:"long",timeZone:o}):null,f=i.has("EEE")?new Intl.DateTimeFormat(n,{weekday:"short",timeZone:o}):null,s=i.has("EEEE")?new Intl.DateTimeFormat(n,{weekday:"long",timeZone:o}):null;return p=>{const b=l(p);let A="";for(const k of d){if(!k.token){A+=k.text;continue}switch(k.token){case"yyyy":A+=V(b.year,4);break;case"yy":A+=V(b.year%100,2);break;case"MMMM":A+=c.format(p);break;case"MMM":A+=m.format(p);break;case"MM":A+=V(b.month,2);break;case"M":A+=String(b.month);break;case"dd":A+=V(b.day,2);break;case"d":A+=String(b.day);break;case"EEEE":A+=s.format(p);break;case"EEE":A+=f.format(p);break;case"HH":A+=V(b.hour,2);break;case"H":A+=String(b.hour);break;case"hh":A+=V(b.hour%12===0?12:b.hour%12,2);break;case"h":A+=String(b.hour%12===0?12:b.hour%12);break;case"mm":A+=V(b.minute,2);break;case"m":A+=String(b.minute);break;case"ss":A+=V(b.second,2);break;case"s":A+=String(b.second);break;case"SSS":A+=V(b.ms,3);break;case"a":A+=b.hour<12?"AM":"PM";break;default:A+=k.text;break}}return A}}const w=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function j(t,n){const o=t||{},d=o.locale||n||void 0,l=o.nullDisplay??"",i=o.timeZone;let m;if(o.pattern)m=z(o.pattern,d,i);else if(o.dateStyle||o.timeStyle){const b={timeZone:i};o.dateStyle&&(b.dateStyle=o.dateStyle),o.timeStyle&&(b.timeStyle=o.timeStyle);const A=new Intl.DateTimeFormat(d,b);m=k=>A.format(k)}else{const b=new Intl.DateTimeFormat(d,{dateStyle:"medium",timeZone:i});m=A=>b.format(A)}const c=o.relative?new Intl.RelativeTimeFormat(d,{numeric:"auto"}):null,s=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,p=(b,A)=>{const k=W(b);if(!k)return l;if(c){const y=A&&typeof A.now=="number"?A.now:Date.now(),S=k.getTime()-y;if(Math.abs(S)<s){for(const[R,O]of w)if(Math.abs(S)>=O||R==="second")return c.format(Math.round(S/O),R)}}return m(k)};return p.spec=o,p}function g(t){if(x(t)||t==="")return null;if(typeof t=="string"){const d=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(d)return d[1];const l=W(t);return l?g(l):null}const n=W(t);if(!n)return null;const o=d=>String(d).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())}`}function u(t,n){if(x(t)||t==="")return null;if(typeof t=="string"){const d=t.trim();if(h.test(d)){const m=W(d);return m?a(m,n):null}const l=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(d);if(l){const[,m,c,f,s]=l;return`${m}T${c}:${f}${s&&s!=="00"?`:${s}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(d))return`${d}T00:00`;const i=W(d);return i?u(i):null}const o=W(t);return o?a(o,n):null}const h=/(?:Z|[+-]\d{2}:?\d{2})$/i;function a(t,n){const o=m=>String(m).padStart(2,"0");if(n)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((s,p)=>(p.type!=="literal"&&(s[p.type]=p.value),s),{}),c=m.hour==="24"?"00":m.hour,f=Number(m.second);return`${m.year}-${m.month}-${m.day}T${c}:${m.minute}`+(f?`:${m.second}`:"")}catch{}const d=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`,l=t.getSeconds(),i=`${o(t.getHours())}:${o(t.getMinutes())}${l?`:${o(l)}`:""}`;return`${d}T${i}`}function r(t,n){const o=x(t)||t===""?null:String(t),d=x(n)||n===""?null:String(n);return o===null?d===null?0:1:d===null||o<d?-1:o>d?1:0}}),Le("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},I={true:"◉",false:"◯",null:""};function _(W){if(x(W)||W==="")return null;if(typeof W=="boolean")return W;if(typeof W=="number")return W!==0;const V=String(W).trim().toLowerCase();return V==="true"||V==="yes"||V==="y"||V==="1"?!0:V==="false"||V==="no"||V==="n"||V==="0"?!1:null}function X(W,V){const H=W||{},z=H.display||"text",w=H.trueLabel??"Yes",j=H.falseLabel??"No",g=H.nullLabel??"";let u=w,h=j;const a=g;z==="checkbox"?(u=B.true,h=B.false):z==="switch"?(u=I.true,h=I.false):z==="icon"&&(u=H.trueIcon??w,h=H.falseIcon??j);const r=t=>{const n=_(t);return n===null?a:n?u:h};return r.display=z,r.labels={true:w,false:j,null:g},r.locale=V,r.spec=H,r}}),Le("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.titleCase;function I(_,X){const W=_||{},V=W.locale||X||void 0,H=W.nullDisplay??"",z=W.emptyDisplay??"",w=W.transform||"none",j=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=j?j.chars:0,u=j?j.ellipsis??"…":"",h=r=>{switch(w){case"upper":return V?r.toLocaleUpperCase(V):r.toUpperCase();case"lower":return V?r.toLocaleLowerCase(V):r.toLowerCase();case"title":return B(r);default:return r}},a=r=>{if(x(r))return H;let t=typeof r=="string"?r:String(r);return t===""?z:(w!=="none"&&(t=h(t)),g>0&&t.length>g&&(t=t.slice(0,g)+u),t)};return a.spec=W,a}}),Le("packages/core/src/format/mask.js",function(e,K){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),x="\0";function B(V){const H=[];let z="",w=!1;for(let j=0;j<V.length;j++){const g=V[j];if(g==="\\"){z+=g+(V[j+1]??""),j+=1;continue}if(g==='"'){w=!w,z+=g;continue}if(g===";"&&!w){H.push(z),z="";continue}z+=g}return H.push(z),H}function I(V){let H="",z="",w="",j=1,g=!1,u=!1;const h=m=>{u?z+=m:H+=m};for(let m=0;m<V.length;m++){const c=V[m];if(c==="\\"){h(V[m+1]??""),m+=1;continue}if(c==='"'){const f=V.indexOf('"',m+1);h(f===-1?V.slice(m+1):V.slice(m+1,f)),m=f===-1?V.length:f;continue}if(c==="%"){j*=100,h("%");continue}if(c==="@"){g=!0,h("\0");continue}if(Q.has(c)){w+=c,u=!0;continue}h(c)}let a=-1;for(let m=w.length-1;m>=0;m--){const c=w[m];if(c==="0"||c==="#"||c==="?"){a=m;break}}let r=!1,t="";for(let m=0;m<w.length;m++){const c=w[m];if(c===","){m>a?j/=1e3:r=!0;continue}t+=c}const n=t.indexOf("."),o=n===-1?t:t.slice(0,n),d=n===-1?"":t.slice(n+1);let l=0;for(const m of o)m==="0"&&(l+=1);let i=0;for(const m of d)m==="0"&&(i+=1);return{prefix:H,suffix:z,minInt:l,minDec:i,maxDec:d.length,grouping:r,scale:j,hasNumber:a!==-1,isText:g}}function _(V,H){const z=new Intl.NumberFormat(H,{minimumIntegerDigits:Math.max(V.minInt,1),minimumFractionDigits:V.minDec,maximumFractionDigits:Math.max(V.maxDec,V.minDec),useGrouping:V.grouping}),{prefix:w,suffix:j,scale:g,hasNumber:u}=V;return h=>{if(!u)return w+j;const a=g===1?h:h*g;return w+z.format(a)+j}}function X(V,H){const w=B(String(V)).map(I),j=w.map(t=>_(t,H)),g=0,u=w.length>1?1:-1,h=w.length>2?2:-1,a=w.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const n=Number(t);if(Number.isNaN(n))return a===-1?String(t):(w[a].prefix+w[a].suffix).split("\0").join(String(t));t=n}return t===0&&h!==-1?j[h](0):t<0&&u!==-1?j[u](-t):j[g](t)};return r.spec={mask:V},{format:r,ooxml:W(String(V))}}function W(V){return V.trim()}}),Le("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return W}});const Q=["currency","number","percent","date","boolean","text","relative"],x=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function I(V){return typeof V!="string"||V===""||X(V)?!1:x.test(V)}function _(V){return typeof V!="string"||V===""||X(V)?!1:B.test(V)}function X(V){const H=V.indexOf(":"),z=H===-1?V:V.slice(0,H);return Q.includes(z)?z:null}function W(V){const H=X(V);if(!H)return null;const z=V.indexOf(":"),w=z===-1?"":V.slice(z+1),j=w===""?[]:w.split(":");switch(H){case"currency":{const g={type:"number",style:"currency",currency:j[0]||"USD"};return j[1]!==void 0&&j[1]!==""&&(g.decimals=Number(j[1])),g}case"number":{const g={type:"number",style:"decimal"};return j[0]!==void 0&&j[0]!==""&&(g.decimals=Number(j[0])),g}case"percent":{const g={type:"number",style:"percent"};return j[0]!==void 0&&j[0]!==""&&(g.decimals=Number(j[0])),g}case"date":return{type:"date",pattern:w||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=w.split("/"),u={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(u.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(u.falseLabel=g[1]),g[2]!==void 0&&(u.nullLabel=g[2]),u}case"text":{const g={type:"text"};return j[0]&&(g.transform=j[0]),j[1]!==void 0&&j[1]!==""&&(g.truncate=Number(j[1])),g}default:return null}}}),Le("packages/core/src/format/index.js",function(e,K){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return A}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.isObject,I=Q.warnOnce,_=K("packages/core/src/format/number.js"),X=_.compileNumber,W=K("packages/core/src/format/date.js"),V=W.compileDate,H=W.scanPattern,z=K("packages/core/src/format/boolean.js"),w=z.compileBoolean,j=K("packages/core/src/format/text.js"),g=j.compileText,u=K("packages/core/src/format/mask.js"),h=u.compileMask,a=K("packages/core/src/format/shorthand.js"),r=a.parseShorthand,t=a.looksLikeMask,n=a.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return _.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return W.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return W.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return z.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return z.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return j.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return u.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return u.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return u.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return a.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return a.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return a.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),d=new Set(["type","locale"]),l={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),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"])},i=new Set(["number","date","boolean","text"]);function m(R,O){const F=R.type;if(F===void 0||i.has(F)||!o.has(String(F)))return;const E=O?`"${O}"`:"with no id";I(`format:unknown-style-key:${O||""}:${F}`,`column ${E} has format: { type: "${F}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${F}" instead?`)}function c(R,O,F){const E=l[O],T=F?`"${F}"`:"with no id";for(const L of R){if(d.has(L)||E.has(L))continue;const C=Object.keys(l).find(D=>D!==O&&l[D].has(L));C?I(`format:inapplicable:${F||""}:${L}`,`column ${T} has format key "${L}", which applies to a ${C} column, not the ${O} column it was applied to; it is ignored.`):I(`format:unknown:${F||""}:${L}`,`column ${T} has an unrecognised format key "${L}" for its ${O} format; it is ignored.`)}}function f(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const O=o.has(String(R.style));return!!(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone||R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon||R.transform||R.truncate||R.emptyDisplay||O||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)}function s(R,O){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return R.type;if(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone)return"date";if(R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon)return"boolean";if(R.transform||R.truncate||R.emptyDisplay)return"text";if(R.style||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)return"number";const F=O&&O.base;return F==="number"?"number":F==="date"||F==="dateString"?"date":F==="boolean"?"boolean":"text"}function p(R,O=null,F=void 0,E=void 0,T=void 0){if(R==null||R==="")return null;const L=B(R)?Object.keys(R):null;if(typeof R=="function"){const $=(P,v)=>String(R({...v||{},value:P,locale:F})??"");return $.ooxml=O&&O.excel||"General",$}if(typeof R=="string"){if(t(R)){const{format:P,ooxml:v}=h(R,F);return P.ooxml=v,P}const $=r(R)||(n(R)?{type:"date",pattern:R}:null);return $?p($,O,F,E,T):(I(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!B(R))return I("format:shape","format must be a spec object or a string; ignoring",R),null;if(O&&x(O.format)&&!f(R)||O&&x(O.format)&&Array.isArray(O.formatPatterns)&&R.type===void 0)return null;const C=s(R,O);C==="date"&&E&&R.timeZone===void 0&&(R={...R,timeZone:E}),m(R,T),c(L||Object.keys(R),C,T);let D;switch(C){case"number":D=X(R,F);break;case"date":D=V(R,F);break;case"boolean":D=w(R,F);break;default:D=g(R,F);break}return D.ooxml=A(R,C,F,O),D.kind=C,D}const b={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 A(R,O,F=void 0,E=null){if(O==="date"){if(R.pattern){let $="";for(const P of H(R.pattern))$+=P.token?b[P.token]??P.text:P.text;return $}return E&&E.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(R.notation==="compact"||R.notation==="scientific")return"General";const T=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let C=`${R.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,D="";return R.style==="currency"&&(D+=k(S(R.currency||"USD",F))),R.prefix&&(D+=k(R.prefix)),C=D+C,R.style==="percent"&&(C=`${C}%`),R.suffix&&(C+=k(R.suffix)),R.negative==="parentheses"?`${C};(${C})`:R.negative==="suffix"?`${C};${C}-`:C}function k(R){return`"${String(R).split('"').join("")}"`}const y=new Map;function S(R,O){const F=`${R}|${O||""}`;let E=y.get(F);if(E!==void 0)return E;E=R;try{const L=new Intl.NumberFormat(O,{style:"currency",currency:R}).formatToParts(0).find(C=>C.type==="currency");L&&(E=L.value)}catch{}return y.set(F,E),E}}),Le("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.isFunction,I=K("packages/core/src/format/date.js"),_=I.toDate,X=I.compilePattern,W=I.compileDate,V=I.toIsoDateTime,H=I.compareIso,z=864e5,w=Object.freeze({}),j=1e3,g=60*j,u=60*g,h=24*u,a=7*h,r=new WeakMap;function t(Oe,Ge){const Ze=Oe&&Oe.locale||"",rt=Oe&&Oe.column;if(!rt)return Ze?{locale:Ze}:w;const st=r.get(rt);if(st&&st.locale===Ze)return st.bag;const ht=rt.typeOptions||rt[Ge]||(n(rt.format)?rt.format:null),yt={...ht||w,locale:ht&&ht.locale||Ze||void 0};return r.set(rt,{locale:Ze,bag:yt}),yt}function n(Oe){return Oe!==null&&typeof Oe=="object"&&!Array.isArray(Oe)&&!(Oe instanceof Date)}function o(Oe,Ge){const Ze=Oe===null||Number.isNaN(Oe)?null:Oe,rt=Ge===null||Number.isNaN(Ge)?null:Ge;return Ze===null?rt===null?0:1:rt===null||Ze<rt?-1:Ze>rt?1:0}const d=/^(\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,l=/^(\d{3,6})$/;function i(Oe,Ge,Ze,rt){return!(Oe>=0&&Oe<=23)||!(Ge>=0&&Ge<=59)||!(Ze>=0&&Ze<=59)||!(rt>=0&&rt<=999)?null:Oe*u+Ge*g+Ze*j+rt}function m(Oe){if(x(Oe))return null;const Ge=String(Oe).trim();if(Ge==="")return null;const Ze=l.exec(Ge);if(Ze){const Tt=Ze[1];if(Tt.length===5)return null;const Et=Tt.length===3?1:2;return i(Number(Tt.slice(0,Et)),Number(Tt.slice(Et,Et+2)),Number(Tt.slice(Et+2,Et+4)||0),0)}const rt=d.exec(Ge);if(!rt)return null;let st=Number(rt[1]);const ht=Number(rt[2]||0),yt=Number(rt[3]||0),Ot=rt[4]?Number(rt[4].padEnd(3,"0")):0,Ct=rt[5]?rt[5][0].toLowerCase():null;if(Ct){if(st<1||st>12)return null;st=st%12,Ct==="p"&&(st+=12)}return i(st,ht,yt,Ot)}function c(Oe){return x(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?(Oe%h+h)%h:null:Oe instanceof Date?Number.isNaN(Oe.getTime())?null:Oe.getHours()*u+Oe.getMinutes()*g+Oe.getSeconds()*j+Oe.getMilliseconds():m(Oe)}const f=new Map;function s(Oe){const Ge=Oe.pattern||"",Ze=Oe.timeStyle||(Oe.seconds?"medium":"short"),rt=`${Oe.locale||""}|${Ge}|${Ze}`;let st=f.get(rt);if(st)return st;if(Ge)st=X(Ge,Oe.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(Oe.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});st=yt=>ht.format(yt)}return f.set(rt,st),st}function p(Oe,Ge){const Ze=Ge||w;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return Ze.nullDisplay??"";const rt=(Oe%h+h)%h;return s(Ze)(new Date(rt))}function b(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe=="number"?Number.isFinite(Oe)&&Oe>=0&&Oe<h:typeof Oe!="string"||!Oe.includes(":")?!1:m(Oe)!==null}function A(Oe){const Ge=c(Oe);return Ge==null?"":p(Ge,{pattern:Ge%j===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const k=new Map;function y(Oe){const Ge=Oe||"";let Ze=k.get(Ge);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),k.set(Ge,Ze)),Ze}function S(Oe,Ge){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const rt of y(Ge).formatToParts(new Date(Oe)))rt.type==="year"?Ze.year=Number(rt.value):rt.type==="month"?Ze.month=Number(rt.value):rt.type==="day"?Ze.day=Number(rt.value):rt.type==="hour"?Ze.hour=Number(rt.value)%24:rt.type==="minute"?Ze.minute=Number(rt.value):rt.type==="second"&&(Ze.second=Number(rt.value));return Ze}function R(Oe,Ge){const Ze=S(Oe,Ge);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(Oe/1e3)*1e3}function O(Oe,Ge){const Ze=Oe.hour||0,rt=Oe.minute||0,st=Oe.second||0,ht=Oe.ms||0;if(!Ge)return new Date(Oe.year,Oe.month-1,Oe.day,Ze,rt,st,ht).getTime();const yt=Date.UTC(Oe.year,Oe.month-1,Oe.day,Ze,rt,st,ht);let Ot=yt-R(yt,Ge);return Ot=yt-R(Ot,Ge),Ot}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function T(Oe,Ge){if(x(Oe))return null;const Ze=String(Oe).trim();if(Ze==="")return null;const rt=Ge&&Ge.timeZone||void 0;if(!F.test(Ze)){const st=E.exec(Ze);if(st){const ht=(st[4]||"").trim(),yt=ht===""?0:m(ht);if(yt===null)return null;const Ot=O({year:Number(st[1]),month:Number(st[2]),day:Number(st[3]),hour:Math.floor(yt/u),minute:Math.floor(yt/g)%60,second:Math.floor(yt/j)%60,ms:yt%j},rt);return Number.isNaN(Ot)?null:new Date(Ot)}}return _(Ze)}function L(Oe){if(typeof Oe=="number")return Number.isFinite(Oe)?Oe:null;const Ge=_(Oe);return Ge?Ge.getTime():null}const C=new Map;function D(Oe){const Ge=[Oe.locale||"",Oe.pattern||"",Oe.dateStyle||"",Oe.timeStyle||"",Oe.timeZone||"",Oe.seconds?"1":""].join("|");let Ze=C.get(Ge);if(Ze)return Ze;const rt=Oe.pattern?{type:"date",pattern:Oe.pattern,timeZone:Oe.timeZone}:{type:"date",dateStyle:Oe.dateStyle||"medium",timeStyle:Oe.timeStyle||(Oe.seconds?"medium":"short"),timeZone:Oe.timeZone};return Ze=W(rt,Oe.locale||void 0),C.set(Ge,Ze),Ze}function $(Oe,Ge){const Ze=Ge||w,rt=L(Oe);return rt==null?Ze.nullDisplay??"":D(Ze)(rt)}function P(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe!="string"||!E.test(Oe.trim())?!1:T(Oe)!==null}const v=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:h,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:g,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:j,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"]}]),N=new Map;for(const Oe of v)for(const Ge of Oe.names)N.set(Ge,Oe);const G=Object.freeze(v.filter(Oe=>Oe.key!=="w")),q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Z=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Oe){const Ge=Oe&&Oe.defaultUnit?N.get(String(Oe.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:g}function ne(Oe){return(Oe&&Oe.defaultUnit?N.get(String(Oe.defaultUnit).toLowerCase()):null)||N.get("m")}function ie(Oe,Ge){if(x(Oe))return null;let Ze=String(Oe).trim().toLowerCase();if(Ze==="")return null;let rt=1;if(Ze[0]==="-"?(rt=-1,Ze=Ze.slice(1).trim()):Ze[0]==="+"&&(Ze=Ze.slice(1).trim()),Ze==="")return null;const st=J.exec(Ze);if(st){const Ct=st[3]!==void 0,Tt=Number(st[1])*u+Number(st[2])*g+(Ct?Number(st[3])*j:0)+(st[4]?Number(st[4].padEnd(3,"0")):0);return rt*Tt}if(Z.test(Ze))return Math.round(rt*Number(Ze)*ee(Ge||w));let ht=Ze,yt=0,Ot=0;for(;ht!=="";){const Ct=q.exec(ht);if(!Ct)return null;const Tt=N.get(Ct[2]);if(!Tt)return null;yt+=Number(Ct[1])*Tt.ms,ht=ht.slice(Ct[0].length),Ot++}return Ot===0?null:Math.round(rt*yt)}function se(Oe){return x(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?Oe:null:ie(Oe)}const he=new Map;function ce(Oe,Ge,Ze){const rt=`${Ze||""}|${Ge.intl}`;let st=he.get(rt);if(st===void 0){try{st=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{st=null}he.set(rt,st)}return st?st.format(Oe):`${Oe} ${Oe===1?Ge.long[0]:Ge.long[1]}`}function te(Oe,Ge){return String(Oe).padStart(Ge,"0")}function oe(Oe,Ge){const Ze=Ge||w;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return Ze.nullDisplay??"";const rt=Ze.style||"short",st=Oe<0;let ht=Math.round(Math.abs(Oe));const yt=st?"-":"";if(ht===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(rt==="clock"){const Et=Math.floor(ht/u),zt=Math.floor(ht/g)%60,It=Math.floor(ht/j)%60;return`${yt}${te(Et,2)}:${te(zt,2)}:${te(It,2)}`}if(ht===0){const Et=ne(Ze);return rt==="long"?ce(0,Et,Ze.locale):`0${Et.key}`}const Ot=Ze.weeks===!0?v:G,Ct=typeof Ze.maxUnits=="number"&&Ze.maxUnits>0?Ze.maxUnits:Ze.maxUnits===void 0?2:1/0,Tt=[];for(const Et of Ot){if(Tt.length>=Ct)break;const zt=Math.floor(ht/Et.ms);zt!==0&&(ht-=zt*Et.ms,Tt.push(rt==="long"?ce(zt,Et,Ze.locale):`${zt}${Et.key}`))}return yt+Tt.join(" ")}function fe(Oe){if(typeof Oe!="string")return!1;const Ge=Oe.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:ie(Ge)!==null}const de=Date.UTC(1899,11,30),we=new Map;function Te(Oe,Ge){const Ze=Oe||"";let rt=we.get(Ze);rt||(rt=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),we.set(Ze,rt));const st=typeof Ge=="number"?Ge:Date.now();for(const ht of rt.formatToParts(new Date(st)))if(ht.type==="timeZoneName")return ht.value;return""}function Ae(Oe){if(Oe)return Oe;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ce(Oe,Ge){const Ze=Ae(Oe),rt=Te(Oe,Ge);return rt?`${Ze} (${rt})`:Ze}function pe(Oe,Ge){if(Oe&&Oe.timeZone)return Oe.timeZone;const Ze=Ge&&Ge.grid;return(Ze&&B(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function be(Oe,Ge){const Ze=Ge||w,rt=L(Oe);if(rt==null)return Ze.nullDisplay??"";const st=D(Ze)(rt);if(!Ze.showOrigin)return st;const ht=Ze.originZone;return ht?ht===(Ze.timeZone||Ae(Ze.timeZone))?st:`${st} (${Ce(ht,rt)})`:`${st} (no origin recorded)`}function ge(Oe,Ge,Ze,rt){if(Ge==="instant"||!Ge)return Oe;const st=S(Oe,Ze);if(Ge==="month")return O({year:st.year,month:st.month,day:1},Ze);if(Ge==="week"){const ht=rt>=1&&rt<=7?rt:1,Ot=((new Date(Date.UTC(st.year,st.month-1,st.day)).getUTCDay()+6)%7+1-ht+7)%7,Ct=new Date(Date.UTC(st.year,st.month-1,st.day-Ot));return O({year:Ct.getUTCFullYear(),month:Ct.getUTCMonth()+1,day:Ct.getUTCDate()},Ze)}return O({year:st.year,month:st.month,day:st.day},Ze)}function Ne(Oe,Ge){const Ze=Oe&&Oe.group,rt=Ze&&Ze.granularity||"day";if(rt==="instant")return null;const st=Ze&&Ze.weekStart;return ht=>typeof ht=="number"?ge(ht,rt,Ge,st):ht}const $e={time:{base:"number",storage:"float64",matches:b,format:Oe=>p(c(Oe.value),t(Oe,"time")),parse:Oe=>m(Oe.text),compare:(Oe,Ge)=>o(c(Oe),c(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Oe=>{const Ge=c(Oe);return Ge===null?null:Ge/z},toStorage:Oe=>c(Oe),toClipboard:A,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:P,format:Oe=>$(Oe.value,t(Oe,"datetime")),parse:Oe=>V(T(Oe.text,t(Oe,"datetime"))??Oe.text),compare:H,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Oe,Ge)=>V(Oe,Ge&&Ge.timeZone),toClipboard:Oe=>x(Oe)?"":String(Oe),fromClipboard:Oe=>V(Oe)},duration:{base:"number",storage:"float64",matches:fe,format:Oe=>oe(se(Oe.value),t(Oe,"duration")),parse:Oe=>ie(Oe.text,t(Oe,"duration")),compare:(Oe,Ge)=>o(se(Oe),se(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Oe=>{const Ge=se(Oe);return Ge===null?null:Ge/z},toStorage:Oe=>se(Oe),toClipboard:Oe=>oe(se(Oe),{style:"short",maxUnits:-1}),fromClipboard:Oe=>ie(Oe)},timestamp:{base:"number",storage:"float64",format:Oe=>{const Ge=t(Oe,"timestamp");return be(Oe.value,{...Ge,timeZone:pe(Ge,Oe)})},parse:Oe=>{const Ge=t(Oe,"timestamp"),Ze=T(Oe.text,{timeZone:pe(Ge,Oe)});return Ze?Ze.getTime():null},compare:(Oe,Ge)=>o(L(Oe),L(Ge)),groupProjector:(Oe,Ge)=>Ne(Oe,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Oe,Ge)=>{const Ze=L(Oe);if(Ze==null)return null;const rt=S(Ze,Ge&&Ge.timeZone||void 0);return(Date.UTC(rt.year,rt.month-1,rt.day,rt.hour,rt.minute,rt.second)-de)/z},toStorage:Oe=>L(Oe),toClipboard:Oe=>{const Ge=L(Oe);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:Oe=>L(Oe)}},He=["datetime","time","duration"],Ye=$e}),Le("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.Lru,I=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(L){if(x(L))return null;if(typeof L=="string")return W(L);const C=Number(L);return Number.isFinite(C)?C<0?C<-2147483648?null:C>>>0:C>I?null:Math.trunc(C)>>>0:null}function W(L){if(x(L))return null;const C=String(L).trim();if(C==="")return null;const D=_.exec(C);if(!D)return null;let $=0;for(let P=1;P<=4;P++){const v=D[P];if(v.length>1&&v.charCodeAt(0)===48)return null;const N=Number(v);if(N>255)return null;$=$*256+N}return $}function V(L){const C=X(L);return C===null?"":`${C>>>24&255}.${C>>>16&255}.${C>>>8&255}.${C&255}`}function H(L){return typeof L=="string"&&W(L)!==null}function z(L,C){const D=X(L),$=X(C);return D===null?$===null?0:1:$===null||D<$?-1:D>$?1:0}const w=64,j=I*w+32,g=/^(?:0|[1-9]\d?)$/;function u(L,C){return L*w+C}function h(L){if(x(L))return null;if(typeof L=="string"){const $=a(L);return $===null?null:h($)}if(typeof L=="object"){const $=X(L.address),P=Number(L.prefix);return $===null||!Number.isInteger(P)||P<0||P>32?null:{address:$,prefix:P}}const C=Number(L);if(!Number.isInteger(C)||C<0||C>j)return null;const D=C%w;return D>32?null:{address:(C-D)/w,prefix:D}}function a(L){if(x(L))return null;const C=String(L).trim();if(C==="")return null;const D=C.indexOf("/");if(D<0)return null;const $=W(C.slice(0,D));if($===null)return null;const P=C.slice(D+1).trim();if(!g.test(P))return null;const v=Number(P);return v>32?null:u($,v)}function r(L){const C=h(L);return C?`${V(C.address)}/${C.prefix}`:""}function t(L){return typeof L=="string"&&a(L)!==null}function n(L,C){const D=h(L),$=h(C);return D?$?D.address!==$.address?D.address<$.address?-1:1:D.prefix-$.prefix:-1:$?1:0}function o(L){return L===0?0:4294967295<<32-L>>>0}function d(L){const C=h(L);return C?(C.address&o(C.prefix))>>>0:null}function l(L){const C=h(L);return C?(C.address&o(C.prefix)|~o(C.prefix)>>>0)>>>0:null}function i(L){const C=h(L);return C?2**(32-C.prefix):null}function m(L){const C=h(L);return C?C.prefix===32?1:C.prefix===31?2:2**(32-C.prefix)-2:null}function c(L,C){const D=h(L);if(!D)return!1;const $=X(C);if($===null)return!1;const P=o(D.prefix);return($&P)>>>0===(D.address&P)>>>0}function f(L,C){const D=d(L),$=d(C);return D===null||$===null?!1:D<=l(C)&&$<=l(L)}const s=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function b(L){if(x(L))return null;let C=String(L).trim();if(C==="")return null;const D=C.indexOf("%");if(D>=0&&(C=C.slice(0,D)),C==="")return null;if(C.indexOf(".")>=0){const q=C.lastIndexOf(":");if(q<0)return null;const Z=W(C.slice(q+1));if(Z===null)return null;C=`${C.slice(0,q+1)}${(Z>>>16&65535).toString(16)}:${(Z&65535).toString(16)}`}const $=C.split("::");if($.length>2)return null;const P=A($[0]);if(P===null)return null;if($.length===1)return P.length===8?P:null;const v=A($[1]);if(v===null)return null;const N=8-P.length-v.length;if(N<1)return null;const G=P.slice();for(let q=0;q<N;q++)G.push(0);for(const q of v)G.push(q);return G}function A(L){if(L==="")return[];const C=[];for(const D of L.split(":")){if(!s.test(D))return null;C.push(parseInt(D,16))}return C}function k(L){if(typeof L!="string")return b(L);if(p.has(L))return p.get(L);const C=b(L);return p.set(L,C),C}function y(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${V((L[6]<<16|L[7])>>>0)}`;let C=-1,D=0,$=-1,P=0;for(let G=0;G<8;G++)L[G]===0?($<0?($=G,P=1):P++,P>D&&(D=P,C=$)):($=-1,P=0);if(D<2)return L.map(G=>G.toString(16)).join(":");const v=L.slice(0,C).map(G=>G.toString(16)).join(":"),N=L.slice(C+D).map(G=>G.toString(16)).join(":");return`${v}::${N}`}function S(L){const C=b(L);return C===null?null:y(C)}function R(L){return S(L)??""}function O(L){return typeof L=="string"&&L.indexOf(":")>=0&&b(L)!==null}function F(L,C){const D=k(L),$=k(C);if(!D)return $?1:0;if(!$)return-1;for(let P=0;P<8;P++)if(D[P]!==$[P])return D[P]<$[P]?-1:1;return 0}const E=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:H,parse:L=>W(L.text),compare:z,format:L=>V(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>X(L),toClipboard:L=>V(L),fromClipboard:L=>W(L)},cidr:{base:"number",storage:"float64",matches:t,parse:L=>a(L.text),compare:n,format:L=>r(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const C=h(L);return C===null?null:u(C.address,C.prefix)},toClipboard:L=>r(L),fromClipboard:L=>a(L)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:L=>S(L.text),compare:F,format:L=>R(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>S(L),toClipboard:L=>R(L),fromClipboard:L=>S(L)}}),T=E}),Le("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return I}});const x=K("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,B=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","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.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.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","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","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","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.","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","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.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.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","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"},"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.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.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.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.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.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.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}","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","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.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","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.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.","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","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","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","licence.watermark.free":x,"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.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.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.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}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","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"}),I=Object.freeze(Object.keys(B))}),Le("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return j}});const x=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,I=new Map,_=new Map;function X(g){const u=g||"";if(I.has(u))return I.get(u);let h=null;try{h=new Intl.PluralRules(g||void 0)}catch{h=null}return I.set(u,h),h}function W(g,u,h="conjunction"){const a=Array.isArray(g)?g.filter(n=>n!=null&&n!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${u||""}|${h}`;let t=_.get(r);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:h})}catch{t=null}_.set(r,t)}return t?t.format(a.map(String)):a.map(String).join(", ")}function V(g,u){return g==null?"":typeof g=="number"?Number.isFinite(g)?g.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(g)}function H(g,u,h){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const a=u&&typeof u.count=="number"?u.count:null;if(a===null)return g.other??"";const r=X(h),t=r?r.select(a):a===1?"one":"other";return g[t]??g.other??""}function z(g,u={},h){const a=H(g,u,h);return a?a.replace(B,(r,t)=>Object.prototype.hasOwnProperty.call(u,t)?V(u[t],h):r):""}function w(g,u,h="en-GB"){return typeof g=="string"&&g?g:typeof u=="string"&&u?u:h}function j(g,u){const h=g?g[u]:void 0;return h==null||x(h)?u:h}}),Le("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/i18n/catalogue.js"),x=Q.EN_GB,B=Q.MESSAGE_KEYS,I=K("packages/core/src/i18n/format.js"),_=I.formatMessage,X=I.formatList,W=I.lookup,V=I.resolveLocale,H=K("packages/core/src/internal/util.js"),z=H.isFunction,w=H.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return I.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return I.resolveLocale}});const j="en-GB";class g{#e=j;#t=x;constructor(t={}){this.configure(t)}configure(t={}){this.#e=V(t.locale,t.declared,j);const n=t.messages;if(!n||typeof n!="object"){this.#t=x;return}const o=Object.keys(n).filter(d=>!(d in x));o.length&&w(`i18n:unknown:${o[0]}`,`message keys not in the catalogue and so ignored: ${o.slice(0,5).join(", ")}${o.length>5?`, and ${o.length-5} more`:""}`),this.#t={...x,...n}}get locale(){return this.#e}t(t,n){return _(W(this.#t,t),n||{},this.#e)}list(t,n){return X(t,this.#e,n)}number(t,n){const o=Number(t);return Number.isFinite(o)?o.toLocaleString(this.#e,n||{maximumFractionDigits:20}):""}}const u=new g;function h(r){return r instanceof g?r:new g(r||{})}function a(r){const t=r&&typeof r=="object"?r:{},n=B.filter(d=>{const l=t[d];return l==null||l===""||z(l)}),o=Object.keys(t).filter(d=>!(d in x));return{missing:n,unknown:o}}}),Le("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.isObject,_=K("packages/core/src/i18n/index.js").defaultMessages,X=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function W(r,t){const n=t||{},o=n.emptyDisplay??X.emptyDisplay;if(x(r)||r==="")return o;const l=[...typeof n.char=="string"&&n.char!==""?n.char:X.char][0]||X.char,i=n.fixedLength??X.fixedLength,m=Number.isFinite(n.length)&&Number(n.length)>0?Math.floor(Number(n.length)):X.length,c=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let f=0;if(c!==null){const s=Number.isFinite(n.lastVisible)?Math.floor(Number(n.lastVisible)):X.lastVisible,p=[...c];if(f=s>0&&s<p.length?s:0,f>0){const b=p.slice(p.length-f).join(""),A=Math.max(1,(i?m:p.length)-f);return l.repeat(A)+b}return l.repeat(i?m:Math.max(1,p.length))}return l.repeat(m)}const V=48;function H(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function z(r,t){if(x(r))return"";const n=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):V;if(typeof r=="string")return r.length>n?`${r.slice(0,n-1)}…`:r;if(typeof r!="object")return String(r);const o=H(r);if(o!==null&&o.length<=n)return o;if(Array.isArray(r)){const l=r.length;return`[${_.t("count.items",{count:l})}]`}const d=Object.keys(r).length;return`{${_.t("count.keys",{count:d})}}`}function w(r,t){if(r==null)return"null";const n=typeof r;if(n==="number"||n==="boolean"||n==="bigint")return String(r);if(n==="string")return JSON.stringify(r);if(n!=="object")return JSON.stringify(String(r));const o=t||new WeakSet;return o.has(r)?'"[circular]"':(o.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(i=>w(i,o)).join(",")}]`:`{${Object.keys(r).sort().map(i=>`${JSON.stringify(i)}:${w(r[i],o)}`).join(",")}}`)}function j(r,t){if(x(r))return x(t)?0:1;if(x(t))return-1;const n=w(r),o=w(t);return n<o?-1:n>o?1:0}function g(r){if(x(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(r){const t=r&&r.cell&&r.cell.props;return B(t)?t:{}}const h=Object.freeze({json:{base:"object",storage:"object",format:r=>z(r&&r.value,u(r&&r.column)),parse:r=>g(r&&r.text),compare:j,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(x(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>g(r)},secret:{base:"text",storage:"object",format:r=>W(r&&r.value,u(r&&r.column)),parse:r=>{const t=r&&r.text;return x(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const n=x(r)||r==="",o=x(t)||t==="";return n===o?0:n?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>W(r),fromClipboard:r=>x(r)||String(r)===""?null:String(r)}}),a=h}),Le("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.warnOnce;function I(P,v,N,G){return Object.freeze({symbol:P,factor:v,aliases:Object.freeze(N||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(P,v,N,G){return I(P,v,N,G)}const X=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})])}),W=Symbol("ambiguous"),V=new Map,H=new Map;function z(P,v){const N=String(P||"").trim();if(!N)throw new Error("[lattice] a unit system needs a name");if(X[N]||H.has(N))throw new Error(`[lattice] unit system "${N}" already exists`);const G=[...v||[]];if(!G.length)throw new Error(`[lattice] unit system "${N}" has no units`);if(!G.some(Z=>Z.factor===1))throw new Error(`[lattice] unit system "${N}" has no base unit (none with factor 1)`);const q=new Set;for(const Z of G){if(q.has(Z.symbol))throw new Error(`[lattice] unit system "${N}" declares "${Z.symbol}" twice`);q.add(Z.symbol)}return H.set(N,Object.freeze(G)),V.delete(N),N}function w(){return[...Object.keys(X),...H.keys()]}function j(P){const v=g(P);return v?v.units:[]}function g(P){const v=String(P||""),N=V.get(v);if(N!==void 0)return N;const G=X[v]||H.get(v);if(!G)return V.set(v,null),null;const q=Object.freeze([...G].sort((ie,se)=>ie.factor-se.factor)),Z=new Map,J=new Map,ee=(ie,se)=>{const he=Z.get(ie);he===void 0?Z.set(ie,se):he!==se&&Z.set(ie,W)};for(const ie of q){ee(ie.symbol.toLowerCase(),ie);for(const se of ie.aliases)ee(se.toLowerCase(),ie);if(ie.prefix){const se=J.get(ie.prefix)||[];se.push(ie),J.set(ie.prefix,se)}}const ne={units:q,byToken:Z,byPrefix:J,decimal:q.filter(ie=>!ie.binary&&ie.auto),binary:q.some(ie=>ie.binary)?q.filter(ie=>(ie.binary||ie.factor===1)&&ie.auto):null};return V.set(v,ne),ne}function u(P,v){return v&&P.binary||P.decimal}function h(P,v){const N=g(P);if(!N||x(v))return null;const G=N.units.find(Z=>Z.symbol===String(v));if(G)return G;const q=N.byToken.get(String(v).trim().toLowerCase());return q&&q!==W?q:null}const a=new WeakMap;function r(P){const v=P||{};if(typeof v=="object"&&v!==null){const Z=a.get(v);if(Z!==void 0)return Z}const N=v.system||"data",G=g(N);let q=null;if(!G)B(`unit:system:${N}`,`unknown unit system "${N}"; known systems are ${w().join(", ")}`);else{let Z=v.unit?h(N,v.unit):null;Z||(v.unit&&B(`unit:unit:${N}:${v.unit}`,`unknown unit "${v.unit}" in system "${N}"; falling back to ${G.units[0].symbol}`),Z=G.units.find(J=>J.factor===1)||G.units[0]),q={index:G,base:Z,binary:v.binary===!0}}return typeof v=="object"&&v!==null&&a.set(v,q),q}const t=new WeakMap;function n(P,v){if(!P||!v||!Array.isArray(P.compound)||P.compound.length===0)return null;const N=t.get(P);if(N!==void 0)return N;const G=new Set,q=[];for(const J of P.compound){const ee=h(P.system||"data",J);if(!ee){B(`unit:compound:${P.system}:${J}`,`unknown compound unit "${J}" in system "${P.system||"data"}"; ignoring it`);continue}G.has(ee.symbol)||(G.add(ee.symbol),q.push(ee))}q.sort((J,ee)=>ee.factor-J.factor);const Z=q.length>=2?q:null;return t.set(P,Z),Z}function o(P,v,N){return v===N||v.factor===N.factor?P:P*v.factor/N.factor}const d=new Map;function l(P){const v=P||"",N=d.get(v);if(N)return N;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return d.set(v,G),G}const i=/[\s ]/g,m=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,f=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function s(P,v){const{group:N,decimal:G}=l(v);let q=String(P).replace(i,"");if(q==="")return null;const Z=G?q.indexOf(G):-1;if(N&&N!==G){if(Z>=0&&q.indexOf(N,Z+G.length)>=0)return null;q=q.split(N).join("")}if(G&&G!=="."&&(q=q.split(G).join(".")),!f.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function p(P,v,N){const G=String(P).trim().replace(/\.$/,"");if(G==="")return null;const q=v.units.find(se=>se.symbol===G);if(q)return q;const Z=G.toLowerCase(),J=v.byToken.get(Z);if(J===W)return null;if(J)return J;const ee=v.byPrefix.get(Z);if(!ee||!ee.length)return null;const ne=u(v,N),ie=ee.filter(se=>ne.includes(se));return ie.length===1?ie[0]:null}function b(P,v,N,G){let q=P,Z=0,J=!1,ee=!1;for(;q!=="";){const ne=m.exec(q)[0];if(ne==="")return null;const ie=s(ne,G&&G.locale);if(ie===null)return null;q=q.slice(ne.length).trim();const se=q.search(/[+-]?[\d]/),he=(se>=0?q.slice(0,se):q).trim();if(q=se>=0?q.slice(se).trim():"",he===""){if(J)return null;ee=!0,Z+=o(ie,N[0],v.base)}else{const ce=p(he,v.index,v.binary);if(!ce)return null;Z+=o(ie,ce,v.base)}if(J=!0,ee&&q!=="")return null}return J?Z:null}function A(P,v){if(x(P))return null;if(typeof P=="number")return Number.isFinite(P)?P:null;const N=r(v);if(!N)return null;let G=String(P).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Z=n(v,N);if(Z){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const te=b(G,N,Z,v);return te===null?null:q?-te:te}let J=null;const ee=c.exec(G);if(ee&&ee[0]){const te=p(ee[0].trim(),N.index,N.binary);te&&(J=te,G=G.slice(ee[0].length).trim())}const ne=m.exec(G)[0],ie=s(ne,v&&v.locale);if(ie===null)return null;const se=G.slice(ne.length).trim();if(J&&se!=="")return null;const he=J||(se===""?N.base:p(se,N.index,N.binary));if(!he)return null;const ce=o(ie,he,N.base);return q?-ce:ce}const k=new Map;function y(P,v,N,G){const q=`${P||""}|${v}|${N}|${G?1:0}`;let Z=k.get(q);return Z||(Z=new Intl.NumberFormat(P||void 0,{minimumFractionDigits:v,maximumFractionDigits:N,useGrouping:G}),k.set(q,Z)),Z}function S(P,v){if(!Number.isFinite(P)||P===0)return Math.max(0,v-1);const N=Math.floor(Math.log10(Math.abs(P)));return Math.min(20,Math.max(0,v-1-N))}function R(P,v){if(!Number.isFinite(P)||P===0)return P;const N=Math.ceil(Math.log10(Math.abs(P))),G=10**(v-N);return Math.round(P*G)/G}function O(P,v,N){if(!N||N===v.base.symbol)return v.base;if(N!=="auto")return F(v,N);if(P===0||!Number.isFinite(P))return v.base;const G=Math.abs(P)*v.base.factor,q=u(v.index,v.binary);let Z=q[0];for(const ne of q)G>=ne.factor&&(Z=ne);if(G>=Z.factor)return Z;let J=Z;for(const ne of v.index.units)ne.binary!==v.binary&&ne.factor!==1||ne.factor<=G&&ne.factor>(J===Z?0:J.factor)&&(J=ne);if(J!==Z)return J;let ee=Z;for(const ne of v.index.units)ne.binary!==v.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<v.base.factor?ee:v.base}function F(P,v){const N=P.index.units.find(q=>q.symbol===v);if(N)return N;const G=P.index.byToken.get(String(v).toLowerCase());return G&&G!==W?G:(B(`unit:display:${v}`,`unknown display unit "${v}"; rendering in ${P.base.symbol}`),P.base)}function E(P,v,N,G){const q=P<0;let Z=Math.abs(P)*v.base.factor;const J=typeof G.decimals=="number"?G.decimals:G.minDecimals??0,ee=typeof G.decimals=="number"?G.decimals:G.maxDecimals??Math.max(J,2),ne=G.space??" ",ie=[];for(let he=0;he<N.length;he++){const ce=N[he],te=he===N.length-1;let oe=te?Z/ce.factor:Math.floor(Z/ce.factor);if(Z-=oe*ce.factor,te){const de=10**ee;oe=Math.round(oe*de)/de+0}const fe=te?y(G.locale,J,ee,G.group!==!1):y(G.locale,0,0,G.group!==!1);ie.push(`${fe.format(oe)}${ne}${ce.symbol}`)}const se=ie.join(" ");return q?`-${se}`:se}function T(P,v){const N=v||{},G=N.nullDisplay??"";if(x(P)||P==="")return G;const q=typeof P=="number"?P:Number(P);if(!Number.isFinite(q))return G;const Z=r(N);if(!Z)return String(q);const J=n(N,Z);if(J)return E(q,Z,J,N);const ee=typeof N.significantFigures=="number"&&N.significantFigures>0?N.significantFigures:0,ne=ee?R(q,ee):q,ie=O(ne,Z,N.display),se=o(ne,Z.base,ie);let he=typeof N.decimals=="number"?N.decimals:N.minDecimals??0,ce=typeof N.decimals=="number"?N.decimals:N.maxDecimals??Math.max(he,2);ee&&(he=S(se,ee),ce=he);const te=y(N.locale,he,ce,N.group!==!1).format(se),oe=N.space??" ";return N.placement==="prefix"?`${ie.symbol}${N.space??""}${te}`:`${te}${oe}${ie.symbol}`}function L(P,v){const N=x(P)||Number.isNaN(P)?null:Number(P),G=x(v)||Number.isNaN(v)?null:Number(v);return N===null||Number.isNaN(N)?G===null||Number.isNaN(G)?0:1:G===null||Number.isNaN(G)||N<G?-1:N>G?1:0}function C(P){const v=typeof P.decimals=="number"&&P.decimals>0?`.${"0".repeat(P.decimals)}`:"";return`${typeof P.decimals=="number"?`#,##0${v}`:"#,##0.##"}" ${P.symbol}"`}function D(P){const v={system:"data",...P||{}},N=r(v),G=N?N.base.symbol:String(v.unit||""),q=Object.freeze({...v,unit:G}),Z=Object.freeze({...q,display:G,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),ee=ne=>{const ie=ne||"";let se=J.get(ie);return se||(se=Object.freeze({...q,locale:ne||void 0}),J.set(ie,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>T(ne.value,ne.locale?ee(ne.locale):q),parse:ne=>A(ne.text,ne.locale?ee(ne.locale):q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:v.total||"sum"},...v.totals?{totals:v.totals}:{},excel:v.excel||C({decimals:v.decimals,symbol:G}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?A(ne,q):x(ne)?null:A(String(ne),q),toClipboard:ne=>T(ne,Z),fromClipboard:ne=>A(ne,q)}}const $=D}),Le("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").isNil,I=K("packages/core/src/columns/types/unit.js").createUnitType;function _(V){const H=2*Math.PI/V;return z=>{let w=0,j=0,g=0;for(const h of z||[]){if(x(h))continue;const a=Number(h);Number.isFinite(a)&&(w+=Math.cos(a*H),j+=Math.sin(a*H),g+=1)}return!g||Math.hypot(w,j)/g<1e-12?null:(Math.atan2(j,w)/H%V+V)%V}}function X(V){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(V)}}}const W=Object.freeze({metres:I({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:I({system:"length",unit:"mm",maxDecimals:2}),kilometres:I({system:"length",unit:"km",maxDecimals:3}),grams:I({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:I({system:"mass",unit:"kg",maxDecimals:3}),tonnes:I({system:"mass",unit:"t",maxDecimals:3}),seconds:I({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:I({system:"duration",unit:"ms",maxDecimals:3}),hours:I({system:"duration",unit:"h",maxDecimals:2}),speed:I({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:I({system:"speed",unit:"km/h",maxDecimals:1}),mph:I({system:"speed",unit:"mph",maxDecimals:1}),knots:I({system:"speed",unit:"kn",maxDecimals:1}),acceleration:I({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:I({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:I({system:"area",unit:"ha",maxDecimals:4}),volume:I({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:I({system:"volume",unit:"m³",maxDecimals:3}),energy:I({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:I({system:"energy",unit:"kWh",maxDecimals:2}),power:I({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:I({system:"power",unit:"kW",maxDecimals:2}),force:I({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:I({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:I({system:"pressure",unit:"bar",maxDecimals:3}),psi:I({system:"pressure",unit:"psi",maxDecimals:1}),torque:I({system:"torque",unit:"N·m",maxDecimals:2}),density:I({system:"density",unit:"kg/m³",maxDecimals:2}),flow:I({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:I({system:"flow",unit:"L/min",maxDecimals:1}),radians:I({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:I({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:I({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:I({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:I({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:I({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:I({system:"fraction",unit:"bp",maxDecimals:1}),molarity:I({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:I({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:I({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:I({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:I({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:I({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:I({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:I({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Le("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/columns/types/unit.js"),x=Q.defineUnit,B=Q.registerUnitSystem,I=Q.createUnitType,_=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})]),X=Object.freeze(["p","n","µ","m","","k","M","G"]);function W(j){const g=String(j.base),u=new Set([...j.prefixes||X,""]),h=[];for(const a of _){if(!u.has(a.symbol))continue;const r=`${a.symbol}${g}`,t=[];if(j.name){t.push(`${a.name}${j.name}`,`${a.name}${j.name}s`);const n=a.name.slice(-1);if(n&&j.name.startsWith(n)){const o=`${a.name.slice(0,-1)}${j.name}`;t.push(o,`${o}s`)}}a.symbol==="µ"&&t.push(`u${g}`),a.factor===1&&j.aliases&&t.push(...j.aliases),h.push(x(r,a.factor,t))}for(const a of j.extra||[])h.push(a);return h}function V(j,g){const u=W(g);return B(j,u)}function H(j,g,u){return V(j,g),I({system:j,unit:g.base,display:"auto",maxDecimals:3,...u||{}})}const z=Object.freeze({voltage:H("voltage",{base:"V",name:"volt"}),current:H("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:H("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:H("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:H("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:H("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[x("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),x("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:H("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:H("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[x("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:H("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:H("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:H("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:H("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:H("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:H("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:H("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[x("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:H("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=H}),Le("packages/core/src/columns/types/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const x=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:h=>h+273.15,fromKelvin:h=>h-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:h=>(h+459.67)*(5/9),fromKelvin:h=>h*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:h=>h,fromKelvin:h=>h}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:h=>h*(5/9),fromKelvin:h=>h*(9/5)})});function I(h){if(x(h))return null;const a=String(h).trim();if(a==="")return null;for(const[t,n]of Object.entries(B))if(a===t||a===n.symbol)return{key:t,scale:n};const r=a.toLowerCase();for(const[t,n]of Object.entries(B))if(n.aliases.includes(r))return{key:t,scale:n};return null}function _(h,a,r){const t=I(a),n=I(r);return!t||!n||!Number.isFinite(Number(h))?null:t.key===n.key?Number(h):n.scale.fromKelvin(t.scale.toKelvin(Number(h)))}const X=new Map;function W(h,a,r){const t=`${h||""}|${a}|${r}`;let n=X.get(t);return n||(n=new Intl.NumberFormat(h||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),X.set(t,n)),n}function V(h,a){const r=a||{},t=r.nullDisplay??"";if(x(h)||h==="")return t;const n=Number(h);if(!Number.isFinite(n))return t;const o=I(r.scale||"C");if(!o)return String(n);const d=I(r.display||r.scale||"C")||o,l=d.key===o.key?n:d.scale.fromKelvin(o.scale.toKelvin(n)),i=typeof r.decimals=="number"?r.decimals:null,m=i??r.minDecimals??0,c=i??r.maxDecimals??1;return`${W(r.locale,m,c).format(l)}${r.space??" "}${d.scale.symbol}`}const H=/^[+-]?[\d\s., ]*\d/;function z(h,a){const r=String(h).trim();if(r==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",n=t===","?".":",",o=r.split(n).join("").split(/[\s ]/).join("").replace(t,"."),d=Number(o);return Number.isFinite(d)?d:null}function w(h,a){if(x(h))return null;const r=a||{},t=I(r.scale||"C");if(!t)return null;if(typeof h=="number")return Number.isFinite(h)?h:null;let n=String(h).trim();if(n==="")return null;let o=!1;n.startsWith("(")&&n.endsWith(")")&&(o=!0,n=n.slice(1,-1).trim());const d=H.exec(n);if(!d)return null;const l=z(d[0],r.locale);if(l===null)return null;const i=n.slice(d[0].length).trim();if(i==="")return o?-l:l;const m=I(i);if(!m)return null;const c=m.key===t.key?l:t.scale.fromKelvin(m.scale.toKelvin(l));return o?-c:c}function j(h){const a=Object.freeze({scale:"C",...h||{}}),t=(I(a.scale)||I("C")).scale.symbol,n=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[a.locale||"",a]]),d=l=>{const i=l||"";let m=o.get(i);return m||(m=Object.freeze({...a,locale:l||void 0}),o.set(i,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:l=>V(l.value,l.locale?d(l.locale):a),parse:l=>w(l.text,l.locale?d(l.locale):a),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:a.excel||`#,##0${typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".#"}" ${t}"`,toStorage:l=>typeof l=="number"?Number.isFinite(l)?l:null:typeof l=="string"?w(l,a):x(l)?null:w(String(l),a),toClipboard:l=>V(l,n),fromClipboard:l=>w(l,a)}}const g=Object.freeze({celsius:j({scale:"C"}),fahrenheit:j({scale:"F"}),kelvin:j({scale:"K"})}),u=j}),Le("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,B=Q.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}),_=Object.freeze({2:1,8:3,16:4}),X=Object.freeze({2:"0b",8:"0o",16:"0x"}),W=Object.freeze({2:4,8:3,16:2}),V=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),H=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),z=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),w=/[\s\u00a0\u202f_,']/g,j=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),u=new WeakSet,h=new WeakMap,a=new Map,r=new WeakMap,t=new WeakMap,n=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 o(T){if(T==null)return 16;const L=typeof T=="string"?T.toLowerCase():T,C=I[L];return C||(B(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function d(T,L){return Math.ceil(T/_[L])}function l(T,L){if(!T)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**T-1};const C=2**(T-1);return{min:-C,max:C-1}}function i(T){return H[T]||"hexadecimal"}function m(T){if(typeof T=="string"){const L=n[T];return L||B(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{}}}if(T&&typeof T.preset=="string"){const L=n[T.preset];return L||B(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{},...T}}return T||{}}function c(T){const L=m(T),C=o(L.radix),D=_[C];let $=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ne=Number(L.bitWidth);g.includes(ne)?$=ne:B(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let P=L.signed!==!1;!P&&$===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),$=32);const v=L.prefix===void 0||L.prefix===!0?X[C]:L.prefix===!1?"":String(L.prefix);let N=0;L.pad===!0?N=$?d($,C):0:typeof L.pad=="number"&&L.pad>0&&(N=Math.floor(L.pad));let G=0;L.group===!0?G=W[C]:typeof L.group=="number"&&L.group>0&&(G=Math.floor(L.group));const q=l($,P),Z=typeof L.min=="number"?Math.max(q.min,L.min):q.min,J=typeof L.max=="number"?Math.min(q.max,L.max):q.max,ee=Object.freeze({radix:C,bits:D,prefix:v,uppercase:L.uppercase!==!1,pad:N,group:G,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:$,signed:P,min:Z,max:J<Z?Z:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:i(C)});return u.add(ee),ee}function f(T){if(T&&u.has(T))return T;if(typeof T=="string"){let L=a.get(T);return L||(L=c(T),a.set(T,L)),L}if(T&&typeof T=="object"){let L=h.get(T);return L||(L=c(T),h.set(T,L)),L}return f("hex")}function s(T){return T<0?-Math.round(-T):Math.round(T)}function p(T,L,C){if(L<=0||T.length<=L)return T;const D=T.length%L||L,$=[T.slice(0,D)];for(let P=D;P<T.length;P+=L)$.push(T.slice(P,P+L));return $.join(C)}function b(T){const L=f(T),{radix:C,prefix:D,uppercase:$,pad:P,group:v,groupSeparator:N,signed:G,bitWidth:q,nullDisplay:Z}=L,J=q?2**q:0,ee=ne=>{if(x(ne)||ne==="")return Z;const ie=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(ie))return Z;const se=s(ie);let he="",ce=se;se<0&&(G?(he="-",ce=-se):ce=(se%J+J)%J);let te=ce.toString(C);return te=$?te.toUpperCase():te.toLowerCase(),P>0&&te.length<P&&(te=te.padStart(P,"0")),v>0&&(te=p(te,v,N)),he+D+te};return ee.options=L,ee}function A(T,L){const C=f(L);let D=r.get(C);return D||(D=b(C),r.set(C,D)),D(T)}function k(T){const L=f(T),{radix:C,groupSeparator:D,signed:$,min:P,max:v}=L,N=V[C],G=q=>{if(x(q))return{ok:!0,value:null,reason:"blank"};let Z=String(q);if(D&&D!==""&&(Z=Z.split(D).join("")),Z=Z.replace(w,""),Z==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Z[0]==="-"||Z[0]==="+")&&(J=Z[0]==="-",Z=Z.slice(1)),Z==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ie,se]of z){const he=ie.exec(Z);if(!he)continue;const ce=Z.slice(he[0].length);if(ce==="")break;if(!V[se].test(ce))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ce,se);break}if(ee===null)if(N.test(Z))ee=parseInt(Z,C);else if(j.test(Z))ee=Number(Z);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=s(J?-ee:ee);return!$&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<P||ne>v?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return G.options=L,G}function y(T,L){const C=f(L);let D=t.get(C);return D||(D=k(C),t.set(C,D)),D(T)}function S(T,L){const C=y(T,L);return C.ok?C.value:null}function R(T,L){const C=x(T)||Number.isNaN(T)?null:Number(T),D=x(L)||Number.isNaN(L)?null:Number(L);return C===null?D===null?0:1:D===null||C<D?-1:C>D?1:0}function O(T){const L=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&L?"int32":"float64"}function F(T){const L=c(T),C=b(L),D=k(L);return{base:"number",extends:"number",storage:O(L),matches:null,format:$=>C($.value),parse:$=>{const P=D($.text);return P.ok?P.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:$=>C($),fromClipboard:$=>{const P=D($);return P.ok?P.value:null},radix:L,formatValue:C,parseText:D}}const E=F}),Le("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").isNil;function B(z){const w=[];for(const j of z||[]){if(x(j))continue;const g=Number(j);Number.isFinite(g)&&w.push(g)}return w}function I(z){return w=>{const j=B(w);if(!j.length)return null;let g=0;for(const u of j)g+=10**(u/z);return z*Math.log10(g)}}function _(z){return w=>{const j=B(w);if(!j.length)return null;let g=0;for(const u of j)g+=10**(u/z);return z*Math.log10(g/j.length)}}function X(z,w){const j=w&&w.column,u=(j&&j.typeOptions||{}).weight,h=w&&w.valueAt;if(!u||typeof h!="function")return null;let a=0,r=0;for(let t=0;t<z.length;t++){if(x(z[t]))continue;const n=Number(z[t]);if(!Number.isFinite(n))continue;const o=h(u,t);if(x(o))continue;const d=Number(o);!Number.isFinite(d)||d<=0||(a+=n*d,r+=d)}return r===0?null:a/r}function W(z={}){const w=z.factor===20?20:10,j=typeof z.suffix=="string"?z.suffix:"",g=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:u=>{const h=u&&u.value;return x(h)||!Number.isFinite(Number(h))?"":`${Number(h).toFixed(g)}${j}`},parse:u=>{const h=String((u&&u.text)??"").replace(j,"").trim();if(!h)return null;const a=Number(h);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:I(w),avg:_(w)}}}}function V(z={}){const w=Number.isInteger(z.decimals)?z.decimals:1,j=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:g=>{const u=g&&g.value;return x(u)||!Number.isFinite(Number(u))?"":j?`${Number(u).toFixed(w)}%`:Number(u).toFixed(w)},parse:g=>{const u=String((g&&g.text)??"").replace("%","").trim();if(!u)return null;const h=Number(u);return Number.isFinite(h)?h:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const H=Object.freeze({decibel:W({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:W({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:V({name:"ratio"}),percentRate:V({name:"percentRate",percent:!0})})}),Le("packages/core/src/columns/types/currency.js",function(e,K){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const x=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function I(l){if(x(l))return null;const i=String(l).trim().toUpperCase();return i===""?null:i}function _(l){if(x(l))return null;if(typeof l=="object"&&!Array.isArray(l)){const i=Number(l.amount),m=I(l.code);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}if(Array.isArray(l)&&l.length===2){const i=Number(l[0]),m=I(l[1]);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}return null}const X=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),W=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),V=/[+-]?[\d\s., ]*\d/;function H(l,i){const m=String(l).trim();if(m==="")return null;const c=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",f=c===","?".":",",s=m.split(f).join("").split(/[\s ]/).join("").replace(c,"."),p=Number(s);return Number.isFinite(p)?p:null}function z(l,i){const m=i||{},c=I(m.code);if(x(l))return null;const f=_(l);if(f)return f;if(typeof l=="number")return Number.isFinite(l)&&c?{amount:l,code:c}:null;let s=String(l).trim();if(s==="")return null;let p=!1;s.startsWith("(")&&s.endsWith(")")&&(p=!0,s=s.slice(1,-1).trim());let b=null;for(const[O,F]of Object.entries(X)){if(s.startsWith(O)){b=F,s=s.slice(O.length).trim();break}if(s.endsWith(O)){b=F,s=s.slice(0,-O.length).trim();break}}const A=V.exec(s);if(!A)return null;const k=H(A[0],m.locale);if(k===null)return null;const y=(s.slice(0,A.index)+" "+s.slice(A.index+A[0].length)).trim();!b&&y!==""&&(b=I(y));const S=b||c;return S?{amount:p?-k:k,code:S}:null}function w(l,i){if(typeof l=="function")return(m,c)=>{if(m===c)return 1;const f=l(m,c);return typeof f=="number"&&Number.isFinite(f)&&f>0?f:null};if(l&&typeof l=="object"){const m=l;return(c,f)=>{if(c===f)return 1;const s=Number(m[c]),p=Number(m[f]);return!Number.isFinite(s)||!Number.isFinite(p)||s<=0||p<=0?null:p/s}}return(m,c)=>m===c?1:null}function j(l,i,m){if(!l)return null;if(l.code===i)return l.amount;const c=m(l.code,i);return c===null?null:l.amount*c}const g=new Map;function u(l,i,m){const c=`${l||""}|${i}|${m??""}`;let f=g.get(c);if(!f){const s={style:"currency",currency:i};typeof m=="number"&&(s.minimumFractionDigits=m,s.maximumFractionDigits=m);try{f={fmt:new Intl.NumberFormat(l||void 0,s),currency:!0}}catch{f={fmt:new Intl.NumberFormat(l||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(c,f)}return f}function h(l,i){const m=i||{},c=m.nullDisplay??"",f=_(l);if(!f)return c;const s=I(m.display)||f.code;let p=f.amount,b=f.code;if(s!==f.code){const y=m.rateFn||w(m.rates,m.rateBase),S=j(f,s,y);if(S===null)return`${m.missingRate??B} ${f.code}→${s}`;p=S,b=s}const{fmt:A,currency:k}=u(m.locale,b,m.decimals);return k?A.format(p):`${A.format(p)} ${b}`}function a(l){const i=_(l);return i?`${i.amount} ${i.code}`:""}function r(l){const i=l||{},m=I(i.display),c=i.rateFn||w(i.rates,i.rateBase);return(f,s)=>{const p=_(f),b=_(s);if(!p&&!b)return 0;if(!p)return 1;if(!b)return-1;if(m){const A=j(p,m,c),k=j(b,m,c);if(A!==null&&k!==null)return A===k?0:A<k?-1:1}return p.code===b.code?p.amount===b.amount?0:p.amount<b.amount?-1:1:p.code<b.code?-1:1}}function t(l){const i=l||{},m=(f,s)=>{const p=[];for(const S of f||[]){const R=_(S);R&&p.push(R)}if(!p.length)return null;if(new Set(p.map(S=>S.code)).size===1){const S=p[0].code;return{amount:s(p.map(R=>R.amount)),code:S}}const A=I(i.display);if(!A)return`${i.missingRate??B}: mixed currencies, no display currency set`;const k=i.rateFn||w(i.rates,i.rateBase),y=[];for(const S of p){const R=j(S,A,k);if(R===null)return`${i.missingRate??B}: ${S.code}→${A}`;y.push(R)}return{amount:s(y),code:A}},c=f=>f.reduce((s,p)=>s+p,0);return{sum:f=>m(f,c),avg:f=>m(f,s=>c(s)/s.length),min:f=>m(f,s=>Math.min(...s)),max:f=>m(f,s=>Math.max(...s))}}function n(l){const i=Object.freeze({code:"USD",...l||{}}),m=w(i.rates,i.rateBase),c=Object.freeze({...i,rateFn:m}),f=t(c),s=r(c),p=new Map([[i.locale||"",c]]),b=y=>{const S=y||"";let R=p.get(S);return R||(R=Object.freeze({...c,locale:y||void 0}),p.set(S,R)),R},A=W[I(i.display||i.code)]||"",k=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:y=>h(y.value,y.locale?b(y.locale):c),parse:y=>z(y.text,y.locale?b(y.locale):c),compare:s,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:f},excel:i.excel||(A?`"${A}"#,##0${k}`:`#,##0${k}`),toStorage:y=>{const S=_(y);return S||(typeof y=="string"||typeof y=="number"?z(y,c):null)},toClipboard:y=>a(y),fromClipboard:y=>z(y,c)}}const o=Object.freeze({currency:n({code:"USD"}),usd:n({code:"USD"}),eur:n({code:"EUR"}),gbp:n({code:"GBP"}),jpy:n({code:"JPY",decimals:0})}),d=n}),Le("packages/core/src/columns/types/index.js",function(e,K){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/columns/types/temporal.js"),x=Q.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),I=B.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),X=_.STRUCTURED_TYPES,W=K("packages/core/src/columns/types/unit.js"),V=W.createUnitType,H=W.UNIT_SYSTEMS,z=W.parseUnit,w=W.formatUnit,j=W.registerUnitSystem,g=W.unitSystemNames,u=W.unitsOf,h=W.defineUnit,a=K("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),n=t.SI_TYPES,o=t.createSiType,d=t.createSiSystem,l=t.siUnits,i=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),c=m.TEMPERATURE_TYPES,f=m.createTemperatureType,s=m.convertTemperature,p=m.formatTemperature,b=m.parseTemperature,A=m.TEMPERATURE_SCALES,k=K("packages/core/src/columns/types/radix.js"),y=k.createRadixType,S=k.RADIX_PRESETS,R=k.parseRadix,O=k.formatRadix,F=K("packages/core/src/columns/types/aggregable.js"),E=F.AGGREGABLE_TYPES,T=K("packages/core/src/columns/types/currency.js"),L=T.CURRENCY_TYPES,C=T.createCurrencyType,D=T.parseMoney,$=T.formatMoney,P=T.convertMoney,v=T.toMoney,N=T.rateFunction,G=T.moneyComparator,q=T.normaliseCode,Z=T.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return W.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return a.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return a.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return m.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return m.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return m.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return m.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return m.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return m.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return m.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return T.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return T.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return T.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return T.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return T.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return T.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return T.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return T.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return T.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return T.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return B.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return _.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return F.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return F.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return F.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return B.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return B.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return B.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return B.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return B.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return B.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return B.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return B.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return B.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return _.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _.summariseJson}});const J=Object.freeze({...x,...I,...X,...E,hex:y(S.hex),hex8:y(S.hex8),hex16:y(S.hex16),hex32:y(S.hex32),binary:y(S.binary),binary8:y(S.binary8),octal:y(S.octal),bytes:V({system:"data",unit:"B",display:"auto"}),megabytes:V({system:"data",unit:"MB"}),gigabytes:V({system:"data",unit:"GB"}),bitrate:V({system:"bitrate",unit:"Mbps"}),gigabits:V({system:"bitrate",unit:"Gbps"}),...r,...n,...c,...L});{const ee=new Set;for(const ne of[x,I,X,E,r,n,c,L])for(const ie of Object.keys(ne)){if(ee.has(ie))throw new Error(`[lattice] data type "${ie}" is declared twice`);ee.add(ie)}}}),Le("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.warnOnce;function _(n){const o=new Uint32Array(n);for(let d=0;d<n;d++)o[d]=d;return o}function X(n,o){if(o&&typeof o.count=="number")return o.count;if(!n)return 0;if(typeof n.count=="number")return n.count;if(typeof n.length=="number")return n.length;const d=n.values;return n.kind==="multi"&&n.offsets?Math.max(0,n.offsets.length-1):d?n.kind==="bitset"?typeof d.size=="number"?d.size:n.presence&&typeof n.presence.size=="number"?n.presence.size:(I(`count:${n.id}`,`column "${n.id}" is bitset-backed with no declared row count; assuming ${d.length*8}`),d.length*8):d.length:n.presence&&typeof n.presence.size=="number"?n.presence.size:0}const W=new WeakMap;function V(n){const o=n.constructor;if(!o)return"unknown";const d=W.get(o);if(d)return d;let l="unknown";try{let i=null;typeof o.from=="function"?i=o.from([!1,!0]):(i=new o(8),i.set(1));const m=i&&i.words;m&&m.length&&(m[0]===2?l="lsb":m[0]===64&&(l="msb"))}catch{l="unknown"}return W.set(o,l),l}function H(n){if(!n)return()=>0;const o=n instanceof Uint8Array?n:n.words;if(o instanceof Uint8Array){const d=n instanceof Uint8Array?"lsb":V(n);if(d==="lsb")return l=>o[l>>>3]>>>(l&7)&1;if(d==="msb")return l=>o[l>>>3]>>>7-(l&7)&1}return typeof n.get=="function"?d=>n.get(d)?1:0:()=>0}function z(n){return!n||!n.presence?null:H(n.presence)}function w(n){return n?typeof n.size=="number"?n.size:typeof n.values=="function"?n.values().length:0:0}function j(n,o){return n?typeof n.valueOf=="function"?n.valueOf(o):typeof n.values=="function"?n.values()[o]:null:null}function g(n,o){const d=n.offsets,l=n.values;if(!d||!l)return[];const i=d[o],m=d[o+1];if(!(m>i))return[];const c=n.dict,f=new Array(m-i);for(let s=i;s<m;s++)f[s-i]=c?j(c,l[s]):l[s];return f}function u(n){if(!n)return()=>{};const o=n.values,d=z(n),l=n.kind;if(l==="dictionary"){const i=n.dict;return d?m=>d(m)?j(i,o[m]):null:m=>j(i,o[m])}if(l==="bitset"){const i=H(o);return d?m=>d(m)?i(m)===1:null:m=>i(m)===1}if(l==="multi")return d?i=>d(i)?g(n,i):null:i=>g(n,i);if(!o&&typeof n.get=="function"){const i=n.get.bind(n);return m=>{const c=i(m);return c===void 0?null:c}}return d?i=>{if(!d(i))return null;const m=o[i];return m===void 0?null:m}:i=>{const m=o[i];return m===void 0?null:m}}function h(n,o){if(n<o)return-1;if(n>o)return 1;if(n===o){const i=Object.is(n,-0),m=Object.is(o,-0);return i===m?0:i?-1:1}const d=Number.isNaN(n),l=Number.isNaN(o);return d&&l?0:d?1:-1}function a(n){const o=x(n);return(d,l)=>{if(d===l)return 0;const i=typeof d,m=typeof l;if(i==="string"&&m==="string")return o.compare(d,l);if(i==="number"&&m==="number")return h(d,l);if(i==="boolean"&&m==="boolean")return d===l?0:d?1:-1;if(d instanceof Date||l instanceof Date){const c=d instanceof Date?d.getTime():Number(d),f=l instanceof Date?l.getTime():Number(l);return h(c,f)}return B(d,l)}}function r(n,o){if(n&&typeof n.ranks=="function")return n.ranks(o);const d=n&&typeof n.values=="function"?n.values():[],l=d.length,i=a(o),m=new Array(l);for(let f=0;f<l;f++)m[f]=f;m.sort((f,s)=>i(d[f],d[s])||f-s);const c=new Uint32Array(l);for(let f=0;f<l;f++)c[m[f]]=f;return c}function t(n){return n==null||typeof n=="number"&&Number.isNaN(n)}}),Le("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return C}}),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 J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return he}});const Q=K("packages/core/src/internal/util.js"),x=Q.isBlank,B=Q.toArray,I=Q.warnOnce,_=K("packages/core/src/format/date.js"),X=_.toDate,W=_.toIsoDate,V=K("packages/core/src/compute/handle.js"),H=V.bitReader,z=V.dictSize,w=V.dictValue,j=V.presenceReader,g=V.valueComparator,u=V.valueReader,h=/^\d{4}-\d{2}-\d{2}$/,a="\0null\0";function r(ce,te){const oe=ce&&ce.pool;if(oe){const fe=oe.mask||oe.acquireMask||oe.acquire||oe.take;if(typeof fe=="function"){const de=fe.call(oe,te);if(de&&de.length>=te)return de}}return new Uint8Array(te)}function t(ce,te){const oe=ce&&ce.pool;if(!oe||!te)return;const fe=oe.release||oe.releaseMask||oe.free||oe.recycle;typeof fe=="function"&&fe.call(oe,te)}function n(ce,te,oe){return ce.fill(oe,0,te),ce}function o(ce){return ce==null||typeof ce=="number"&&Number.isNaN(ce)}function d(ce,te){if(ce==null)return ce;if(te==="number")return typeof ce=="number"?ce:Number(ce);if(te==="date"||te==="dateString"){const oe=W(ce);return oe===null?l(ce):oe}return te==="boolean"?typeof ce=="boolean"?ce:ce==="true"||ce===1?!0:ce==="false"||ce===0?!1:!!ce:ce}function l(ce){return ce instanceof Date?ce.getTime():typeof ce=="number"?ce:Date.parse(String(ce))}function i(ce){return typeof ce=="number"?ce:ce instanceof Date?ce.getTime():ce==null||ce===""?NaN:Number(ce)}function m(ce,te){const oe=typeof ce=="string"?ce:String(ce);return te?oe:oe.toLowerCase()}function c(ce,te){return ce==null?a:typeof ce=="string"?te?ce:ce.toLowerCase():ce instanceof Date?ce.getTime():ce}function f(ce,te,oe){const fe=new Set;for(const de of B(ce)){const we=d(de,oe);fe.add(c(we,te)),typeof we=="string"&&we!==""&&Number.isFinite(Number(we))?fe.add(Number(we)):typeof we=="number"&&Number.isFinite(we)&&fe.add(c(String(we),te))}return fe}function s(ce,te,oe){if(ce==null||te===null||te===void 0)return ce==null&&te==null;const fe=typeof ce,de=typeof te;return fe==="string"&&de==="string"?oe?ce===te:ce.toLowerCase()===te.toLowerCase():ce instanceof Date||te instanceof Date?l(ce)===l(te):fe==="number"&&de==="number"?ce===te||Number.isNaN(ce)&&Number.isNaN(te):fe==="number"&&de==="string"?ce===Number(te):fe==="string"&&de==="number"?Number(ce)===te:fe==="boolean"||de==="boolean"?ce===te:Array.isArray(ce)&&Array.isArray(te)?ce.length===te.length&&ce.every((we,Te)=>s(we,te[Te],oe)):ce===te}function p(ce,te){try{if(ce instanceof RegExp){const oe=ce.flags.replace(/[gy]/g,"");return new RegExp(ce.source,te||oe.includes("i")?oe:`${oe}i`)}return new RegExp(String(ce),te?"":"i")}catch(oe){return I(`regex:${String(ce)}`,`filter operator "matches" received an invalid pattern: ${String(ce)}`,oe),null}}function b(ce,te){if(ce&&ce.type==="datetime"&&A.has(ce.op))return O(ce,te);const oe=F(ce,te),fe=ce&&ce.type;return fe!=="date"&&fe!=="dateString"?oe:de=>oe(typeof de=="string"&&h.test(de)?de:W(de)??de)}const A=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),k=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,y=new Map;function S(ce,te){let oe=y.get(te);if(oe===void 0){try{oe=new Intl.DateTimeFormat("en-CA",{timeZone:te,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{oe=null}y.set(te,oe)}if(!oe)return null;const fe={};for(const de of oe.formatToParts(ce))de.type!=="literal"&&(fe[de.type]=de.value);return fe}function R(ce,te){if(ce==null||ce==="")return null;if(typeof ce=="string"){const we=k.exec(ce.trim());if(we)return Date.UTC(+we[1],+we[2]-1,+we[3],+(we[4]||0),+(we[5]||0),+(we[6]||0),+(we[7]||"0").padEnd(3,"0"))}const oe=X(ce);if(!oe)return null;const fe=oe.getUTCMilliseconds(),de=te?S(oe,te):null;return de?Date.UTC(+de.year,+de.month-1,+de.day,de.hour==="24"?0:+de.hour,+de.minute,+de.second,fe):Date.UTC(oe.getFullYear(),oe.getMonth(),oe.getDate(),oe.getHours(),oe.getMinutes(),oe.getSeconds(),fe)}function O(ce,te){const oe=typeof ce.timeZone=="string"&&ce.timeZone?ce.timeZone:void 0,fe=Te=>R(Te,oe),de=Array.isArray(ce.value)?ce.value.map(fe):fe(ce.value),we=F({...ce,type:"number",value:de},te);return Te=>we(R(Te))}function F(ce,te){const oe=ce&&ce.op,fe=!!(ce&&ce.caseSensitive),de=ce&&ce.type,we=g(te),Te=Ae=>Ce=>!Ae(Ce);switch(oe){case"eq":{const Ae=d(ce.value,de);return Ce=>s(Ce,Ae,fe)}case"ne":{const Ae=d(ce.value,de);return Ce=>!s(Ce,Ae,fe)}case"lt":case"lte":case"gt":case"gte":{const Ae=d(ce.value,de);if(o(Ae))return()=>!1;const Ce=oe==="lt"?-1:oe==="lte"?0:oe==="gt"?1:2;return pe=>{if(o(pe))return!1;const be=we(pe,Ae);return Ce===-1?be<0:Ce===0?be<=0:Ce===1?be>0:be>=0}}case"between":case"notBetween":{const Ae=B(ce.value),Ce=d(Ae[0],de),pe=d(Ae[1],de),be=ce.bounds||"[]",ge=be.charAt(0)!=="(",Ne=be.charAt(1)!==")";if(o(Ce)||o(pe))return oe==="between"?()=>!1:()=>!0;const $e=He=>{if(o(He))return!1;const Ye=we(He,Ce),Oe=we(He,pe);return(ge?Ye>=0:Ye>0)&&(Ne?Oe<=0:Oe<0)};return oe==="between"?$e:Te($e)}case"in":case"notIn":{const Ae=f(ce.value,fe,de),Ce=pe=>Ae.has(c(pe,fe));return oe==="in"?Ce:Te(Ce)}case"contains":case"notContains":{const Ae=m(d(ce.value,de),fe),Ce=pe=>pe==null?!1:m(pe,fe).includes(Ae);return oe==="contains"?Ce:Te(Ce)}case"startsWith":{const Ae=m(d(ce.value,de),fe);return Ce=>Ce==null?!1:m(Ce,fe).startsWith(Ae)}case"endsWith":{const Ae=m(d(ce.value,de),fe);return Ce=>Ce==null?!1:m(Ce,fe).endsWith(Ae)}case"matches":{const Ae=p(ce.value,fe);return Ae?Ce=>Ce==null?!1:Ae.test(String(Ce)):()=>!1}case"blank":return Ae=>x(Ae)||Array.isArray(Ae)&&Ae.length===0;case"notBlank":return Ae=>!(x(Ae)||Array.isArray(Ae)&&Ae.length===0);case"containsAny":case"containsNone":{const Ae=f(ce.value,fe,de),Ce=pe=>{const be=pe==null?[]:B(pe);for(let ge=0;ge<be.length;ge++)if(Ae.has(c(be[ge],fe)))return!0;return!1};return oe==="containsAny"?Ce:Te(Ce)}case"containsAll":{const Ae=B(ce.value).map(Ce=>c(d(Ce,de),fe));return Ce=>{const pe=Ce==null?[]:B(Ce);if(Ae.length===0)return!0;const be=new Set(pe.map(ge=>c(ge,fe)));for(let ge=0;ge<Ae.length;ge++)if(!be.has(Ae[ge]))return!1;return!0}}default:{const Ae=he(oe);return Ae?Ae.compile(ce.value):(I(`op:${String(oe)}`,`unknown filter operator "${String(oe)}"; the condition is refused rather than matching every row`),()=>!1)}}}function E(ce,te,oe){return b(te,oe)(ce)}const T=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),L=new Set(["containsAny","containsAll","containsNone"]);function C(ce,te,oe){const fe=ce&&ce.op,de=T[fe]||fe,we=b({...ce,op:de,type:te.type},oe),Te=te.items,Ae=Ce=>{const pe=Te(Ce);if(!pe)return!1;for(let be=0;be<pe.length;be++)if(we(pe[be]))return!0;return!1};return T[fe]?Ce=>!Ae(Ce):Ae}function D(ce,te,oe,fe){const de=j(ce);if(de){const Ae=te?1:0;for(let Ce=0;Ce<fe;Ce++)oe[Ce]=de(Ce)===Ae?1:0;return oe}const we=ce.kind;if(we==="float64"||we==="int32"||we==="bitset")return n(oe,fe,te?1:0);const Te=u(ce);for(let Ae=0;Ae<fe;Ae++){const Ce=Te(Ae),pe=x(Ce)||Array.isArray(Ce)&&Ce.length===0;oe[Ae]=pe===te?0:1}return oe}function $(ce,te,oe,fe){const de=ce.dict,we=z(de),Te=new Uint8Array(we);for(let be=0;be<we;be++)Te[be]=te(w(de,be))?1:0;const Ae=ce.values,Ce=j(ce);if(!Ce){for(let be=0;be<fe;be++)oe[be]=Te[Ae[be]];return oe}const pe=te(null)?1:0;for(let be=0;be<fe;be++)oe[be]=Ce(be)===1?Te[Ae[be]]:pe;return oe}function P(ce,te,oe,fe){const de=H(ce.values),we=te(!0)?1:0,Te=te(!1)?1:0,Ae=j(ce);if(!Ae){for(let pe=0;pe<fe;pe++)oe[pe]=de(pe)===1?we:Te;return oe}const Ce=te(null)?1:0;for(let pe=0;pe<fe;pe++)oe[pe]=Ae(pe)===0?Ce:de(pe)===1?we:Te;return oe}function v(ce,te,oe,fe,de){const we=ce.values,Te=te.type,Ae=te.op;let Ce=!0;switch(Ae){case"eq":case"ne":{const be=i(d(te.value,Te)),ge=typeof te.value=="number"&&Number.isNaN(te.value),Ne=Ae==="ne"?1:0;if(ge)for(let $e=0;$e<de;$e++)fe[$e]=(Number.isNaN(we[$e])?1:0)^Ne;else for(let $e=0;$e<de;$e++)fe[$e]=(we[$e]===be?1:0)^Ne;break}case"lt":{const be=i(d(te.value,Te));for(let ge=0;ge<de;ge++)fe[ge]=we[ge]<be?1:0;break}case"lte":{const be=i(d(te.value,Te));for(let ge=0;ge<de;ge++)fe[ge]=we[ge]<=be?1:0;break}case"gt":{const be=i(d(te.value,Te));for(let ge=0;ge<de;ge++)fe[ge]=we[ge]>be?1:0;break}case"gte":{const be=i(d(te.value,Te));for(let ge=0;ge<de;ge++)fe[ge]=we[ge]>=be?1:0;break}case"between":case"notBetween":{const be=B(te.value),ge=i(d(be[0],Te)),Ne=i(d(be[1],Te)),$e=te.bounds||"[]",He=$e.charAt(0)!=="(",Ye=$e.charAt(1)!==")",Oe=Ae==="notBetween"?1:0;if(He&&Ye)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(we[Ge]>=ge&we[Ge]<=Ne?1:0)^Oe;else if(He)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(we[Ge]>=ge&we[Ge]<Ne?1:0)^Oe;else if(Ye)for(let Ge=0;Ge<de;Ge++)fe[Ge]=(we[Ge]>ge&we[Ge]<=Ne?1:0)^Oe;else for(let Ge=0;Ge<de;Ge++)fe[Ge]=(we[Ge]>ge&we[Ge]<Ne?1:0)^Oe;break}case"in":case"notIn":{const be=new Set;for(const Ne of B(te.value)){const $e=i(d(Ne,Te));Number.isNaN($e)||be.add($e)}const ge=Ae==="notIn"?1:0;for(let Ne=0;Ne<de;Ne++)fe[Ne]=(be.has(we[Ne])?1:0)^ge;break}default:Ce=!1;break}if(!Ce)return!1;const pe=j(ce);if(pe){const be=oe(null)?1:0;for(let ge=0;ge<de;ge++)pe(ge)===0&&(fe[ge]=be)}return!0}function N(ce,te,oe,fe){const de=u(ce);for(let we=0;we<fe;we++)oe[we]=te(de(we))?1:0;return oe}function G(ce,te,oe){const fe=te.count|0,de=oe||r(te,fe);if(!ce)return n(de,fe,1);const we=typeof te.handle=="function"?te.handle(ce.col):void 0,Te=typeof te.custom=="function"?te.custom:null;if(!we){if(Te){for(let be=0;be<fe;be++)de[be]=Te(ce,be)?1:0;return de}return I(`filter:col:${String(ce.col)}`,`filter references unknown column "${String(ce.col)}"; the condition is refused rather than matching every row`),n(de,fe,0)}const Ae=ce.op;if(Ae==="blank"||Ae==="notBlank")return D(we,Ae==="notBlank",de,fe);const Ce=typeof te.itemwise=="function"?te.itemwise(ce.col):null;if(Ce&&!he(Ae)&&!L.has(Ae))return N(we,C(ce,Ce,te.locale),de,fe);const pe=b(ce,te.locale);switch(we.kind){case"dictionary":return $(we,pe,de,fe);case"bitset":return P(we,pe,de,fe);case"float64":case"int32":return v(we,ce,pe,de,fe)?de:N(we,pe,de,fe);default:return N(we,pe,de,fe)}}function q(ce,te,oe){if(!ce)return n(r(te,oe),oe,1);if(Array.isArray(ce.conditions)){const fe=ce.conditions.filter(Te=>Te!=null),de=ce.op==="or"?"or":ce.op==="not"?"not":"and";if(fe.length===0)return n(r(te,oe),oe,1);const we=q(fe[0],te,oe);for(let Te=1;Te<fe.length;Te++){const Ae=q(fe[Te],te,oe);if(de==="or")for(let Ce=0;Ce<oe;Ce++)we[Ce]|=Ae[Ce];else for(let Ce=0;Ce<oe;Ce++)we[Ce]&=Ae[Ce];t(te,Ae)}if(de==="not")for(let Te=0;Te<oe;Te++)we[Te]^=1;return we}return G(ce,te,r(te,oe))}function Z(ce,te){return q(ce,te,te.count|0)}function J(ce,te){if(!ce||!te)return ce||null;const oe=ce;if(Array.isArray(oe.conditions)){if((oe.op==="or"?"or":oe.op==="not"?"not":"and")!=="and")return ee(oe,te)?null:ce;const de=[];for(const we of oe.conditions){const Te=J(we,te);Te&&de.push(Te)}return de.length?{...oe,op:"and",conditions:de}:null}return oe.col===te?null:ce}function ee(ce,te){if(!ce||typeof ce!="object")return!1;const oe=ce;if(oe.col===te)return!0;if(Array.isArray(oe.conditions)){for(const fe of oe.conditions)if(ee(fe,te))return!0}return!1}function ne(ce,te,oe){if(oe&&oe.length>=te){let Te=0;for(let Ae=0;Ae<te;Ae++)ce[Ae]&&(oe[Te++]=Ae);return oe.subarray(0,Te)}let fe=0;for(let Te=0;Te<te;Te++)fe+=ce[Te]?1:0;const de=new Uint32Array(fe);let we=0;for(let Te=0;Te<te;Te++)ce[Te]&&(de[we++]=Te);return de}const ie=new Map;function se(ce){if(!(!ce||typeof ce!="object"))for(const[te,oe]of Object.entries(ce))oe&&typeof oe.compile=="function"&&ie.set(te,oe)}function he(ce){return typeof ce=="string"?ie.get(ce):void 0}}),Le("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,V=Q.titleCase,H=K("packages/core/src/format/date.js"),z=H.toDate,w=H.toIsoDate,j=H.compareIso,u=K("packages/core/src/format/boolean.js").toTriState,a=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,r=K("packages/core/src/formula/index.js"),t=r.evaluateFormula,n=r.looksLikeFormula,d=K("packages/core/src/compute/filter.js").declareOperators,l=/^\d{4}-\d{2}-\d{2}$/;function i(C){return C.getHours()===0&&C.getMinutes()===0&&C.getSeconds()===0&&C.getMilliseconds()===0}const m=new Map;function c(C){const D=C||"",$=m.get(D);if($)return $;const P={group:",",decimal:"."};try{for(const v of new Intl.NumberFormat(C||void 0).formatToParts(12345.6))v.type==="group"?P.group=v.value:v.type==="decimal"&&(P.decimal=v.value)}catch{}return m.set(D,P),P}const f=/\d\s*[*/^]\s*[\d.(]/;function s(C,D){if(I(C))return null;let $=String(C).trim();if($===""||$.startsWith("=")||f.test($))return null;let P=1;$.startsWith("(")&&$.endsWith(")")&&(P=-1,$=$.slice(1,-1));const v=$.endsWith("%"),{group:N,decimal:G}=c(D);if($=$.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&($=$.split(N).join("")),$=$.replace(/[^0-9eE+\-.,]/g,""),G===","?$=$.split(".").join("").replace(",","."):$=$.split(",").join(""),$===""||$==="-"||$==="+")return null;const q=Number($);return Number.isNaN(q)?null:P*(v?q/100:q)}function p(C,D){const $=I(C)||Number.isNaN(C)?null:Number(C),P=I(D)||Number.isNaN(D)?null:Number(D);return $===null?P===null?0:1:P===null||$<P?-1:$>P?1:0}function b(C,D){const $=u(C),P=u(D);return $===null?P===null?0:1:P===null?-1:$===P?0:$?1:-1}function A(C,D){const $=z(C),P=z(D);if(!$)return P?1:0;if(!P)return-1;const v=$.getTime(),N=P.getTime();return v<N?-1:v>N?1:0}const k=new Map;function y(C){const D=z(C.value);if(!D)return"";const $=C.locale||"";let P=k.get($);return P||(P=new Intl.DateTimeFormat(C.locale||void 0,{dateStyle:"medium"}),k.set($,P)),P.format(D)}const S={boolean:{base:"boolean",storage:"bitset",matches:C=>typeof C=="boolean",parse:C=>u(C.text),compare:b,format:C=>u(C.value)===null?"":u(C.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:C=>u(C)===null?"":String(u(C)),fromClipboard:C=>u(C)},number:{base:"number",storage:"float64",matches:C=>typeof C=="number"&&!Number.isNaN(C),parse:C=>{if(n(C.text)){const D=t(C.text,C);if(!D.ok)return null;const $=Number(D.value);return Number.isFinite($)?$:null}return s(C.text,C.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:C=>I(C)?"":String(C),fromClipboard:(C,D)=>s(C,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:C=>typeof C=="string"&&l.test(C)&&!Number.isNaN(Date.parse(C))||C instanceof Date&&!Number.isNaN(C.getTime())&&i(C),parse:C=>w(C.text),compare:j,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:C=>w(C),toClipboard:C=>I(C)?"":String(C),fromClipboard:C=>w(C)},dateString:{base:"dateString",storage:"dictionary",matches:C=>typeof C=="string"&&l.test(C)&&!Number.isNaN(Date.parse(C)),parse:C=>w(C.text),compare:j,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:C=>w(C),toClipboard:C=>I(C)?"":String(C),fromClipboard:C=>w(C)},text:{base:"text",storage:"dictionary",matches:C=>typeof C=="string",parse:C=>C.text===""?null:String(C.text),compare:(C,D)=>I(C)?I(D)?0:1:I(D)?-1:x().compare(String(C),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:C=>I(C)?"":String(C),fromClipboard:C=>C},image:{base:"text",storage:"dictionary",parse:C=>C.text===""||C.text==null?null:String(C.text).trim(),compare:(C,D)=>I(C)?I(D)?0:1:I(D)?-1:x().compare(String(C),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:C=>I(C)?"":String(C),fromClipboard:C=>C},lookup:{base:"text",storage:"dictionary",parse:C=>{if(C.text===""||C.text==null)return null;const D=C.column&&C.column.lookup,$=D&&X(D.options)?D.options():null;if(!$)return C.text;const P=String(C.text),v=$.find(q=>String(q.id)===P);if(v)return v.id;const N=P.trim().toLowerCase(),G=$.find(q=>String(q.label).toLowerCase()===N);return G?G.id:C.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:C=>I(C)?"":String(C),fromClipboard:C=>C},object:{base:"object",storage:"object",matches:C=>C!==null&&typeof C=="object"&&!(C instanceof Date),parse:C=>{try{return C.text===""?null:JSON.parse(C.text)}catch{return C.text}},compare:(C,D)=>B(C,D),format:C=>{const D=C.value;if(I(D))return"";if(typeof D=="string")return D;try{return JSON.stringify(D)}catch{return String(D)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:C=>I(C)?"":typeof C=="string"?C:JSON.stringify(C),fromClipboard:C=>C}},R=["boolean","number","date","dateString","datetime","text","object"];function O(C,D,$,P){const v=$.get(C);if(v)return v;P.includes(C)&&W(`circular data type extends chain: ${[...P,C].join(" → ")}`);const N=D[C];N||W(`unknown data type "${C}"`);let G=null;N.extends&&(G=O(N.extends,D,$,[...P,C]));const q={...G||{},...N,name:C,defaults:{...G&&G.defaults||{},...N.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),$.set(C,q),q}function F(C,D){const $={...S,...a};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const v of D.names("dataType")){const N=D.dataType(v);N&&($[v]=N)}if(_(C))for(const[v,N]of Object.entries(C))$[v]=N;const P=new Map;for(const v of R)O(v,$,P,[]);O("lookup",$,P,[]);for(const v of Object.keys($))O(v,$,P,[]);for(const v of P.values())d(v.operators);return P}function E(C,D){if(C.base==="text"&&(!C.compare||C.compare===S.text.compare)){const $=x(D);return(P,v)=>I(P)?I(v)?0:1:I(v)?-1:$.compare(String(P),String(v))}return C.compare||B}function T(C,D){return D?C.multiStorage||"multi":C.storage||"object"}function L(C){return V(String(C).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Le("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return X}});const Q=K("packages/core/src/internal/util.js"),x=Q.infoOnce,B=Q.isNil,I=100;function _(W,V,H={}){const z=H.sampleSize??I,w=[];for(let j=0;j<W.length&&w.length<z;j++){const g=W[j];B(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[j,g]of V){if(typeof g.matches!="function")continue;let u=!0;for(let h=0;h<w.length;h++)if(!g.matches(w[h])){u=!1;break}if(u)return{type:j,unanimous:!0,sampled:w.length}}return H.quiet||x(`infer:${H.colId||"?"}`,`column "${H.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:w.length}}function X(W,V,H,z,w={}){const j=w.sampleSize??I,g=[];for(let u=0;u<V.length&&g.length<j;u++){const h=H(V[u]);B(h)||typeof h=="number"&&Number.isNaN(h)||g.push(h)}return _(g,z,{...w,colId:W}).type}}),Le("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const Q=K("packages/core/src/internal/util.js"),x=Q.DEV,B=Q.fail,I=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const j=w.value||{};if(!I(j.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const u=j.pure!==!1;return j.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:u}:Array.isArray(j.deps)?{computed:!0,wholeRow:!1,deps:j.deps.slice(),pure:u}:(_(`deps:missing:${w.id}`,`computed column "${w.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:u})}function V(w){const j=new Map;for(const m of w)j.set(m.id,m);const g=new Map,u=new Map,h=new Set,a=new Set,r=new Set,t=new Set;for(const m of w){const c=W(m);if(!c.computed){g.set(m.id,[]);continue}a.add(m.id),(c.pure?r:t).add(m.id),c.wholeRow&&h.add(m.id);const f=[],s=[];for(const p of c.deps)(j.has(p)?f:s).push(p);g.set(m.id,f),s.length&&u.set(m.id,s)}for(const m of r)for(const c of g.get(m))t.has(c)&&B(`pure computed column "${m}" depends on impure column "${c}". Mark it \`value.pure: false\` or make the dependency pure.`);const n=[],o=new Map,d=[],l=m=>{const c=o.get(m);if(c!=="done"){if(c==="open"){const f=d.indexOf(m);B(`circular column dependency: ${[...d.slice(f),m].join(" → ")}`)}o.set(m,"open"),d.push(m);for(const f of g.get(m)||[])j.has(f)&&l(f);d.pop(),o.set(m,"done"),n.push(m)}};for(const m of w)l(m.id);const i=new Map;for(const m of w)i.set(m.id,[]);for(const m of w)for(const c of g.get(m.id)||[]){const f=i.get(c);f&&!f.includes(m.id)&&f.push(m.id)}if(h.size)for(const m of w){if(a.has(m.id))continue;const c=i.get(m.id);for(const f of h)c.includes(f)||c.push(f)}return{order:n,dependents:i,pure:r,impure:t,computed:a,deps:g,wholeRow:h,external:u,index:j}}function H(w,j){const g=Array.isArray(j)?j:[j],u=new Set,h=[...g];for(;h.length;){const a=h.shift();for(const r of w.dependents.get(a)||[])u.has(r)||(u.add(r),h.push(r))}for(const a of g)u.delete(a);return w.order.filter(a=>u.has(a))}function z(w,j,g){if(!x)return w;const u=j instanceof Set?j:new Set(j);return new Proxy(w,{get(h,a){return typeof a=="string"&&!u.has(a)&&!Object.hasOwn(h,a)&&_(`undeclared:${g}:${a}`,`computed column "${g}" read undeclared dependency "${a}". Add it to \`value.deps\` or the value will go stale.`),h[a]}})}}),Le("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return h}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.pathGetter,I=Q.isFunction,_=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],W="";function V(a){if(a===null)return"\0n";if(a===void 0)return"\0u";const r=typeof a;if(r==="string")return a;if(r==="number"||r==="bigint"||r==="boolean")return String(a);if(a instanceof Date)return`\0d${a.getTime()}`;try{return`\0o${JSON.stringify(a)}`}catch{return"\0o?"}}function H(a){if(a.length===1)return V(a[0]);let r="";for(let t=0;t<a.length;t++)t&&(r+=W),r+=V(a[t]);return r}function z(a,r={}){const t=r.warn!==!1;if(I(a)){const n=a;return{stable:!0,fields:[],disabled:[],key(o,d){try{const l=n(o);return Array.isArray(l)?H(l):V(l)}catch(l){return x("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",l),`#${d??-1}`}},keyEmpty(o){try{const d=n(o);return Array.isArray(d)?d.length===0||d.some(_):_(d)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(a)&&a.length>0){const n=a.filter(l=>typeof l=="string"),o=n.map(l=>B(l)),d=o.length;return{stable:!0,fields:n,disabled:[],key(l){const i=new Array(d);for(let m=0;m<d;m++)i[m]=o[m](l);return H(i)},keyEmpty(l){for(let i=0;i<d;i++)if(_(o[i](l)))return!0;return!1},missingFields(l){const i=[];for(let m=0;m<d;m++)_(o[m](l))&&i.push(n[m]);return i}}}if(typeof a=="string"&&a.length>0){const n=B(a);return{stable:!0,fields:[a],disabled:[],key(o){return V(n(o))},keyEmpty(o){return _(n(o))},missingFields(o){return _(n(o))?[a]:[]}}}return t&&x("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${X.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:X.slice(),key(n,o){if(n===null||typeof n!="object")return`#${o??0}:${String(n)}`;let d=w.get(n);return d===void 0&&(d=`#${j++}`,w.set(n,d)),d}}}const w=new WeakMap;let j=0;function g(a,r){if(!a||a.stable===!1||!I(a.keyEmpty)||!Array.isArray(r)||r.length===0)return;let t=0,n=null,o;for(let m=0;m<r.length;m++){const c=r[m];a.keyEmpty(c)&&(t++,n===null&&(n=I(a.missingFields)?a.missingFields(c):[],o=c))}if(t===0)return;const d=a.fields.length?a.fields.join(","):"(function)",l=n&&n.length?n.join(", "):a.fields.length?a.fields.join(", "):"the rowKey function",i=o!==null&&typeof o=="object"?Object.keys(o).join(", ")||"(no fields)":String(o);x(`rowKey.emptyValue:${d}`,`rowKey ${l} is missing on ${t} of ${r.length} rows; the first such row has: ${i}. 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 u(a){return H(a)}function h(a){return a.split(W)}}),Le("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare,I=Q.isFunction,_=Q.isNil,X=Q.warnOnce,V=K("packages/core/src/model/rowkey.js").compositeKey,H=", ",z="";function w(r,t,n,o){if(r===null||typeof r!="object")return{id:r,label:r==null?"":String(r)};const d=r[t],l=r[n],i={id:d,label:l==null?String(d??""):String(l)};r.disabled&&(i.disabled=!0),r.variant&&(i.variant=r.variant),r.icon&&(i.icon=r.icon);const m=o?r[o]:r.group;return m!==void 0&&(i.group=m),i}function j(r,t,n=0,o=[],d=[]){for(const l of r||[]){const i=l&&typeof l=="object"?l[t]:null;if(d.push({raw:l,depth:n,path:o}),Array.isArray(i)&&i.length){const m=String(l&&typeof l=="object"?l.label??l.name??l.id??"":l);j(i,t,n+1,[...o,m],d)}}return d}function g(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&I(r.router&&r.router.subscribe)}class u{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#h=new Map;constructor(t,n={}){this.#e=t||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=x(this.#n),Array.isArray(this.#e.options)?this.#f(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??H}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=x(t)}#f(t){const n=this.#e,o=n.valueKey||"id",d=n.labelKey||"label",l=n.childrenKey||"children";this.#o=j(t,l).map(i=>{const m=w(i.raw,o,d,n.groupKey);return i.depth&&(m.depth=i.depth,m.path=i.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,m)=>{this.#i.set(i.id,i),this.#s.set(i.id,m)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(g(t))return this.#u=this.#p(t),this.#u;if(!I(t))return X(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let n;try{n=t()}catch(o){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),this.#u=Promise.resolve([]),this.#u}return!n||!I(n.then)?(this.#f(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(o=>(this.#f(o),this.#r&&this.#r(this),this.#o),o=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#f(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const n=this.#e,o=n.valueKey||"id",d=n.labelKey||"label",l=n.groupKey,i=I(t.map)?t.map:null,m=f=>w(i?i(f):f,o,d,l).id,c=f=>this.#m(f,i,o,d,l);return t.router.subscribe(t.predicate,c,{rowKey:m}),this.#d=()=>{I(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,n,o,d,l){const i=t&&t.add||[],m=t&&t.update||[],c=t&&t.remove||[];if(!(!i.length&&!m.length&&!c.length)){for(const f of i)this.#g(f,n,o,d,l);for(const f of m)this.#g(f,n,o,d,l);for(const f of c){if(!this.#h.has(f))continue;const s=this.#h.get(f);this.#h.delete(f),this.#i.delete(s);const p=this.#o.findIndex(b=>b.id===s);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((f,s)=>[f.id,s])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,n,o,d,l){const i=w(n?n(t):t,o,d,l);this.#h.set(V([i.id]),i.id);const m=this.#o.findIndex(c=>c.id===i.id);m>=0?this.#o[m]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,n){const o=this.#e;if(!I(o.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(i)))}const d=o.valueKey||"id",l=o.labelKey||"label";return Promise.resolve(o.search(t,n)).then(i=>(i||[]).map(m=>w(m,d,l,o.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const n=this.#i.get(t);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||X(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const o=this.#e.unknownLabel;return I(o)?String(o(t)??""):typeof o=="string"?o:String(t)}text(t){if(this.multiple){const n=h(t);return n.length===0?"":n.map(o=>this.label(o)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((o,d)=>B(o.id,d.id));const n=this.#c;return this.#o.slice().sort((o,d)=>n.compare(o.label,d.label))}comparator(){const t=this.sortBy,n=this.multiple,o=this.#c,d=this.#s;if(n&&t==="count")return(i,m)=>h(i).length-h(m).length;const l=n?i=>h(i)[0]:i=>i;return t==="value"?(i,m)=>B(l(i),l(m)):t==="optionOrder"?(i,m)=>{const c=d.has(l(i))?d.get(l(i)):Number.MAX_SAFE_INTEGER,f=d.has(l(m))?d.get(l(m)):Number.MAX_SAFE_INTEGER;return c-f}:(i,m)=>{const c=l(i),f=l(m);return _(c)?_(f)?0:1:_(f)?-1:o.compare(this.label(c),this.label(f))}}groupKey(t){return this.multiple?h(t).map(o=>String(o)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?h(t).length:_(t)?0:1}contains(t,n,o){const d=this.multiple?h(t):_(t)?[]:[t],l=Array.isArray(n)?n:[n];switch(o){case"containsAll":return l.every(i=>d.includes(i));case"containsNone":return!l.some(i=>d.includes(i));default:return l.some(i=>d.includes(i))}}exportText(t,n="label"){return n==="value"?this.multiple?h(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:o=>t?h(o).includes(n.id):o===n.id}))}}function h(r){return Array.isArray(r)?r:_(r)||r===""?[]:[r]}function a(r,t={}){const n=r.lookup;if(!n)return null;const o=new u(n,{colId:r.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&o.load(),o}}),Le("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.getPath,B=Q.isFunction,I=Q.isNil,_=Q.Lru,X=Q.warnOnce,V=K("packages/core/src/columns/graph.js").depsProxy,H="\0";function z(r,t={}){const n=t.locale,o=t.grid??null,d=t.context,l=r.value&&r.value.format,i=r.formatter||null,m=r.dataType&&r.dataType.format,c=r.lookup||null,f=(s,p,b)=>({value:s,data:b,row:p,column:r,colId:r.id,grid:o,context:d,locale:n});if(B(l))return(s,p,b)=>{const A=l(f(s,p,b));return A==null?"":String(A)};if(i){if(c){const s=i.kind==="text";return(p,b,A)=>i(s?c.text(p):p,f(p,b,A))}return(s,p,b)=>i(s,f(s,p,b))}return B(m)?(s,p,b)=>{const A=m(f(s,p,b));return A==null?"":String(A)}:c?s=>c.text(s):s=>I(s)?"":typeof s=="string"?s:String(s)}function w(r,t){!r||!r.value||r.value.pure!==!1||X(`impure:${t}:${r.id}`,`column "${r.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class j{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(n=>[n.id,n])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||g}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const n=t&&t.rows?new Set([...t.rows].map(String)):null,o=t&&t.columns?[...t.columns]:null;if(!n&&!o){this.#s.clear();return}const d=o?this.#l(o):null;for(const l of[...this.#s.keys()]){const i=String(l).split(H);i.length===3&&(n&&!n.has(i[0])||d&&!d.has(i[2])||this.#s.delete(l))}}#l(t){const n=new Set,o=this.#t,d=[...t];for(;d.length;){const l=d.pop();if(!n.has(l)){n.add(l);for(const i of o?o.dependents.get(l)||[]:[])d.push(i)}}return n}value(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return;if(!d.computed)return this.#u(d,n,o);if(d.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(d.id))return this.#i.get(d.id,o.physical);if(d.volatile)return this.compute(d,n,o);if(d.value.pure===!1)return this.compute(d,n,o);const l=`${this.#a(n,o)}${H}${d.id}`;if(this.#s.has(l))return this.#s.get(l);const i=this.compute(d,n,o);return this.#s.set(l,i),i}#a(t,n){return`${this.#o(t,n)}${H}${u(t)}`}#u(t,n,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,o.physical);if(t.field)return t.read?t.read(n):x(n,t.field)}compute(t,n,o){const d=this.#t,l=d&&d.wholeRow.has(t.id);let i;if(l)i=n??{};else{i={};const c=d&&d.deps.get(t.id)||[];for(const s of c)i[s]=this.value(s,n,o);const f=d&&d.external.get(t.id)||[];for(const s of f)i[s]=x(n,s);i=V(i,[...c,...f],t.id)}const m={data:n,row:o,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,m)}values(t,n){const o={},d=this.#t?this.#t.order:[...this.#e.keys()];for(const l of d)o[l]=this.value(l,t,n);return o}text(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;return d?d.formatValue(this.value(d,n,o),o,n):""}key(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return"";const l=this.value(d,n,o);return B(d.value.key)?String(d.value.key(this.#c(d,l,n,o))):d.lookup?d.lookup.groupKey(l):I(l)?"":String(l)}quickFilterText(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return"";if(B(d.value.quickFilterText)){const l=this.value(d,n,o);return String(d.value.quickFilterText(this.#c(d,l,n,o))??"")}return this.text(d,n,o)}#c(t,n,o,d){return{value:n,data:o,row:d,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return n;const i={text:n,value:this.value(l,o,d),data:o,row:d,column:l,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(l.value.parse)?l.value.parse(i):l.dataType&&B(l.dataType.parse)?l.dataType.parse(i):n}validate(t,n,o,d,l){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!B(i.edit.validate))return!0;const m=i.edit.validate({value:n,oldValue:o,data:d,row:l,column:i,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return!1;const i=this.value(l,o,d);if(B(l.value.apply)){const m=l.value.apply({value:n,oldValue:i,data:o,row:d,column:l,grid:this.#n,context:this.#r});return this.#d(l,o,d),m!==!1}return l.field?i===n?!1:(l.write(o,n),this.#d(l,o,d),!0):(X(`apply:${l.id}`,`column "${l.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(l,o,d),m=this.parse(l,n,o,d),c=this.validate(l,m,i,o,d);if(c!==!0)return{ok:!1,value:m,oldValue:i,changed:!1,error:c};const f=this.apply(l,m,o,d);return{ok:!0,value:m,oldValue:i,changed:f}}#d(t,n,o){if(this.#s.size===0)return;const d=this.#a(n,o);this.#s.delete(`${d}${H}${t.id}`);for(const l of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${d}${H}${l}`)}}function g(r,t){return t&&t.key!=null?String(t.key):u(r)}function u(r){if(r&&typeof r=="object"){let t=h.get(r);return t===void 0&&(t=`#${a++}`,h.set(r,t)),t}return String(r)}const h=new WeakMap;let a=0}),Le("packages/core/src/model/shadow.js",function(e,K){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const x=K("packages/core/src/internal/util.js").warnOnce,B=2e5,I=20,_=1e3,X=50;function W(m){return Math.min(_,Math.max(X,Math.floor(m)))}const V=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"]),H=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),z=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),w=.6745,j=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),h=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"});function a(m,c){if(!c)return null;const f=Number.isFinite(Number(c.lower))?Number(c.lower):null,s=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(f===null&&s===null||!Number.isFinite(m))return null;if(f!==null&&m<f||s!==null&&m>s)return g.FAIL;const p=Number.isFinite(Number(c.warnLower))?Number(c.warnLower):null,b=Number.isFinite(Number(c.warnUpper))?Number(c.warnUpper):null;return p!==null&&m<p||b!==null&&m>b?g.WARN:g.PASS}function r(m,c,f){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&x(`shadow.history.window.kind:${m}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${c.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 s=c.minutes!=null?Number(c.minutes)*6e4:Number(c.span);if(!(s>0))return x(`shadow.history.window.span:${m}`,"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 p=Math.max(2,Math.floor(f)||I);return{span:s,bucketMs:Math.max(1,Math.floor(s/p))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#p=null;#m=null;constructor(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||I),this.#u=Math.max(1,c.max||B),this.#c=c.now||(()=>Date.now()),this.#d=r(this.#e,c.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(c,f){const s=l(f);if(s===null)return;if(!this.#n.has(c)){this.#p=null,this.#m=null,this.#g(),this.#t.set(c,s),this.#n.set(c,s),this.#r.set(c,0),this.#o.set(c,this.#c()),this.#i.set(c,[s]),this.#d&&this.#h.set(c,[s]),this.#s.set(c,0);return}const p=this.#n.get(c);if(p===s)return;this.#p=null,this.#m=null,this.#n.set(c,s),this.#r.set(c,(this.#r.get(c)||0)+1),this.#o.set(c,this.#c());const b=this.#i.get(c)||[];b.push(s),b.length>this.#a&&b.splice(0,b.length-this.#a),this.#i.set(c,b);const A=Math.sign(s-p),k=this.#s.get(c)||0;this.#s.set(c,Math.sign(k)===A?k+A:A)}#g(){if(this.#n.size<this.#u)return;const c=this.#n.keys().next().value;c!==void 0&&(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#o.delete(c),this.#i.delete(c),this.#h.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,f]of this.#n)this.#t.set(c,f);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(c){const f=c instanceof Set?c:new Set(c);let s=0;for(const p of[...this.#n.keys()])f.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#h.delete(p),this.#s.delete(p),s++);return s&&(this.#p=null,this.#m=null),s}advanceHistoryWindow(c=this.#c()){const f=this.#d;if(!f)return 0;const s=Math.floor(c/f.bucketMs),p=s-this.#f;if(!(p>0))return 0;const b=Math.min(p,this.#a);for(const[A,k]of this.#h){const y=this.#n.get(A);for(let S=0;S<b;S++)k.push(y);k.length>this.#a&&k.splice(0,k.length-this.#a)}return this.#f=s,p}read(c,f,s,p){switch(c){case"updates":return this.#r.has(f)?this.#r.get(f):0;case"updatedAt":{const b=this.#o.get(f);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(f);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(f)?this.#t.get(f):null;case"delta":return this.#n.has(f)?this.#n.get(f)-this.#t.get(f):null;case"deltaPercent":{if(!this.#n.has(f))return null;const b=this.#t.get(f);return b?(this.#n.get(f)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(f),A=this.#o.get(f);if(!b||b.length<2||A===void 0)return null;const k=this.#c()-A,y=b[b.length-1]-b[b.length-2];return k>0?y/k*1e3:y}case"history":return this.#d?this.#h.has(f)?[...this.#h.get(f)]:null:this.#i.has(f)?[...this.#i.get(f)]:null;case"streak":return this.#s.has(f)?this.#s.get(f):0;case"specStatus":return this.#n.has(f)?a(this.#n.get(f),p):null;default:return u.includes(c)?this.#O(c,f,s,p):null}}#b(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const f=this.#w(c);return this.#m={only:c,view:f},f}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(c){const f=[];for(const[F,E]of this.#n)c&&!c.has(F)||f.push(E);const s=f.sort((F,E)=>F-E);let p=0,b=0,A=0,k=0;for(const F of s){k+=F,p++;const E=F-b;b+=E/p,A+=E*(F-b)}const y=[];for(const[F,E]of this.#t)c&&!c.has(F)||y.push(E);const S=p?n(s):0,R=s.map(F=>Math.abs(F-S)).sort((F,E)=>F-E),O=p?n(R):0;return{sorted:s,baseline:y.sort((F,E)=>F-E),sum:k,mean:p?b:0,sd:p>1?Math.sqrt(A/(p-1)):0,median:S,mad:O}}#O(c,f,s,p){if(!this.#n.has(f)||s&&!s.has(f))return null;const b=this.#n.get(f),A=this.#b(s),k=A.sorted.length;if(!k)return null;switch(c){case"rank":return k-d(A.sorted,b)+1;case"rankAsc":return o(A.sorted,b)+1;case"rankChange":{if(!this.#t.has(f)||!A.baseline.length)return null;const y=A.baseline.length-d(A.baseline,this.#t.get(f))+1,S=k-d(A.sorted,b)+1;return y-S}case"percentile":return d(A.sorted,b)/k*100;case"quartile":{const y=d(A.sorted,b)/k;return Math.min(4,Math.max(1,Math.ceil(y*4)))}case"zScore":return A.sd?(b-A.mean)/A.sd:null;case"anomalyScore":return A.mad?w*(b-A.median)/A.mad:null;case"anomalyFlag":{if(!A.mad)return null;const y=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):j;return Math.abs(w*(b-A.median)/A.mad)>y}case"shareOfTotal":return A.sum?b/A.sum*100:null;default:return null}}}function n(m){const c=m.length;if(!c)return 0;const f=(c-1)*.5,s=Math.floor(f),p=Math.ceil(f);return s===p?m[s]:m[s]+(f-s)*(m[p]-m[s])}function o(m,c){let f=0,s=m.length;for(;f<s;){const p=f+s>>1;m[p]<c?f=p+1:s=p}return f}function d(m,c){let f=0,s=m.length;for(;f<s;){const p=f+s>>1;m[p]<=c?f=p+1:s=p}return f}function l(m){if(m==null||m==="")return null;if(m instanceof Date){const f=m.getTime();return Number.isFinite(f)?f:null}const c=typeof m=="number"?m:Number(m);return Number.isFinite(c)?c:null}function i(m){const c=[];for(const f of m||[]){const s=f.shadow;if(!s)continue;const p=typeof s=="string"?{kind:s}:s,b=p.kind;V.includes(b)&&(H.includes(b)||z.includes(b)||c.push({colId:f.id||f.field,of:p.of||f.field||f.id,kind:b,depth:p.depth,historyWindow:b==="history"?p.window:void 0}))}return c}}),Le("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return se}});const Q=K("packages/core/src/internal/util.js"),x=Q.expand,B=Q.fail,I=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,V=Q.merge,H=Q.pathGetter,z=Q.pathSetter,w=Q.toArray,j=Q.uid,g=Q.warnOnce,h=K("packages/core/src/format/index.js").compileFormat,a=K("packages/core/src/columns/datatypes.js"),r=a.comparatorFor,t=a.createTypeRegistry,n=a.storageKind,o=K("packages/core/src/columns/infer.js"),d=o.inferColumnType,l=o.DEFAULT_SAMPLE,i=K("packages/core/src/columns/graph.js"),m=i.buildGraph,c=i.affectedBy,s=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),b=p.compileDisplay,A=p.ValuePipeline,k=p.warnImpureUse,S=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,R=Object.freeze({geometry:"geometry",list:"list"}),O={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},F={centre:"center"},E=new Set(["start","center","end","left","right"]);function T(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return F[te]?F[te]:E.has(te)?te:void 0}function L(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return te==="center"||te==="centre"?"middle":te==="top"||te==="middle"||te==="bottom"?te:void 0}const C=["cell","layout","header"];function D(ce){if(!W(ce))return{};const te={...ce},oe=(fe,de)=>{if(ce[fe]===void 0)return;const we=x(ce[fe],de);we&&C.includes(fe)&&!W(ce[fe])&&delete we.enabled,te[fe]=we};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),te}function $(ce,te){const oe={...ce||{}},fe=W(te)&&W(te.layout)&&te.layout.width!==void 0;return oe.fit==="content"&&!fe&&delete oe.width,oe}const P=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"]),v=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function N(ce,te,oe,fe){const de=oe==="columnGroup"?"column group":"column";for(const we of Object.keys(ce))if(!te.has(we)){if(we==="timeZone"&&oe==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${fe}". 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}g(`${oe}.unknown:${we}`,`'${we}' is not a configuration key this grid recognises, so it had no effect on ${de} "${fe}". Check the spelling against the reference.`)}}function G(ce){W(ce.cell)&&ce.cell.autoHeight!==void 0&&g("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${ce.id||ce.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function q(ce,te){const oe=te&&X(ce.defaultsFor)?ce.defaultsFor(te):null,fe={...ce.defaults||{},...W(oe)?oe:{}},de={};return fe.align&&(de.align=fe.align,de.cell={align:fe.align},de.header={align:fe.align}),fe.filter&&(de.filter=fe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:fe.filter}),fe.editor&&(de.edit=fe.editor==="none"?{editor:null}:{editor:fe.editor}),fe.total&&(de.total=fe.total),fe.render&&(de.cell={...de.cell||{},render:fe.render}),ce.export&&(de.export={...ce.export}),de}function Z(ce){if(typeof ce=="string")return ce.trim()?[ce.trim()]:[];if(!Array.isArray(ce))return[];const te=[];for(const oe of ce){if(typeof oe!="string")continue;const fe=oe.trim();fe&&!te.includes(fe)&&te.push(fe)}return te}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(te,oe,fe){const de=this.#d(te,oe,fe);if(typeof de!="string"||!this.#h)return de??null;const we=oe&&oe.totals&&oe.totals.implement;if(we&&X(we[de])){const Ae=we[de];return Ae.totalName=de,Ae}const Te=this.#h.totalFn?.(de);return X(Te)?Te:de}#d(te,oe,fe){if(typeof te!="string")return te;const de=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(de)||de.includes(te))return te;const we=de.length?de.join(", "):"none";return B(`column "${fe}" is typed ${oe.name||"a type"}, for which the total "${te}" is not meaningful. Supported: ${we}. Aggregating it anyway would produce a confident wrong number.`),te}#h;#f;#p;#m;#g;#b;#w=!1;#O;#y;constructor(te={}){this.#i=D(te.columnDefaults||{}),this.#s=te.columnPresets||{},this.#a=te.locale,this.#l=te.timeZone,this.#u=L(te.verticalAlign),this.#h=te.registry||null,this.#f=te.grid||null,this.#p=te.context,this.#O=te.sampleSize??l,this.#y=te.onChange||null,this.#b=X(te.rowKey)?te.rowKey:void 0,this.#o=t(te.dataTypes,this.#h);const{leaves:oe,groups:fe}=se(te.columns||[]);this.#n=fe;for(const de of oe){de.facet!==void 0&&this.#r.set(de.def,de.facet);const we=this.#A(de.def,null);if(we.groupPath=de.path,this.#e.has(we.id)){g(`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}de.column=we,this.#e.set(we.id,we),this.#t.push(we.id)}this.#E(te.stored||null)}#A(te,oe){N(te,P,"column",te.id||te.field||"(unnamed)"),G(te);const fe=D(te),de=w(te.preset),we=de.map(Oe=>{const Ge=this.#s[Oe];return Ge?D(Ge):(g(`preset:${Oe}`,`unknown column preset "${Oe}"; ignoring`),{})}),Te=this.#S(fe,we,oe),Ae=this.#o.get(Te)||this.#o.get("text");if(!this.#o.has(Te)&&te.type){const Oe=R[Te];g(`type:${Te}`,`unknown data type "${Te}"; falling back to "text"`+(Oe?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Oe}'.`:""))}const Ce=X(Ae.items)?this.#C(fe,we,te.id||te.field||"(unnamed)"):null;let pe=O;pe=V(pe,this.#i),te.type!==!1&&(pe=V(pe,q(Ae,Ce)));for(const Oe of we)pe=V(pe,Oe);this.#r.has(te)&&(pe=V(pe,D({facet:this.#r.get(te)}))),pe=V(pe,fe);const be=pe.edit;be&&be.editor&&be.enabled!==!0&&!X(be.enabled)&&(te.edit||{}).editor&&g(`column.editor-not-enabled:${te.id||te.field}`,`column '${te.id||te.field}' names the editor '${be.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=te.id||te.field||j("col");if(te.shadow&&!X(pe.value&&pe.value.compute)){const Oe=typeof te.shadow=="string"?{kind:te.shadow}:te.shadow,Ge=Oe.of||te.field||ge,Ze=S.includes(Oe.kind),rt=Ze?Oe.model||Oe:null,st=Ze&&rt?[...Array.isArray(rt.predictors)?rt.predictors:[],rt.response].filter(Boolean):null;pe.value={...pe.value||{},deps:st&&st.length?st:Oe.orderBy&&Oe.orderBy!==Ge?[Ge,Oe.orderBy]:[Ge],pure:!1,compute:(ht,yt)=>{const Ot=yt.grid&&yt.grid.statistics;if(!Ot)return null;const Ct=yt.row&&yt.row.key||Ot.keyOf(yt.data);if(!Ct)return null;if(Ze){if(!X(Ot.fitShadow))return null;const Tt=Oe.model?{...Oe.model,threshold:Oe.threshold}:Oe;return Ot.fitShadow(Oe.kind,Ct,Tt)}return Ot.shadow(Ge,Oe.kind,Ct,Oe.scope,Oe)}}}if(te.running&&!X(pe.value&&pe.value.compute)){const Oe=typeof te.running=="string"?{kind:te.running}:te.running,Ge=Oe.of||te.field||ge;pe.value={...pe.value||{},deps:[Ge],pure:!1,compute:(Ze,rt)=>{const st=rt.grid&&rt.grid.statistics;if(!st||!X(st.running))return null;const ht=rt.row&&rt.row.key||st.keyOf(rt.data);return ht?st.running(Ge,Oe.kind||"total",ht):null}},te.sort===void 0&&(pe.sort={...pe.sort||{},enabled:!1})}const Ne=te.field??(X(pe.value&&pe.value.compute)?null:te.id??null),$e=X(pe.value&&pe.value.compute),He={id:ge,field:Ne,shadow:te.shadow||null,running:te.running||null,spec:te.spec||null,validation:te.validation||null,volatile:!!(te.shadow||te.running),title:pe.title??_(Ne||ge),type:Ae.name,dataType:Ae,itemType:Ce,nullable:pe.nullable!==!1,align:T(fe.cell&&fe.cell.align||fe.align||pe.cell&&pe.cell.align||pe.align||Ae.defaults&&Ae.defaults.align)||"start",verticalAlign:L(fe.cell&&fe.cell.verticalAlign||fe.verticalAlign||pe.cell&&pe.cell.verticalAlign||pe.verticalAlign)||this.#u,rowSpan:X(pe.rowSpan)?pe.rowSpan:null,colSpan:X(pe.colSpan)?pe.colSpan:null,value:{pure:!0,...pe.value||{}},cell:{...pe.cell||{}},edit:{...pe.edit||{}},sort:{...pe.sort||{}},filter:{...pe.filter||{}},group:{enabled:!1,index:-1,explode:!1,...pe.group||{}},pivot:{enabled:!1,index:-1,...pe.pivot||{}},total:this.#c(pe.total,Ae,te.id||te.field||"(unnamed)"),groupTotal:pe.groupTotal===void 0?null:this.#c(pe.groupTotal,Ae,te.id||te.field||"(unnamed)"),grandTotal:pe.grandTotal===void 0?null:this.#c(pe.grandTotal,Ae,te.id||te.field||"(unnamed)"),tags:Z(pe.tags),typeOptions:pe.typeOptions??null,...W(pe[Te])?{[Te]:pe[Te]}:{},layout:$(pe.layout,fe),header:{...pe.header||{}},contextMenu:pe.contextMenu===void 0?null:pe.contextMenu,facet:{...pe.facet||{}},export:{...pe.export||{}},allowGroup:pe.allowGroup!==!1,allowPivot:pe.allowPivot!==!1,allowTotal:pe.allowTotal!==!1,quickFilter:pe.quickFilter!==!1,def:te,format:pe.format,presets:de,inferred:oe!=null&&!te.type,computed:$e,diff:te.diff===void 0?void 0:!!te.diff,read:Ne?H(Ne):null,write:Ne?z(Ne):null};He.cell.align=T(fe.cell&&fe.cell.align)||He.align,He.header.align=T(fe.header&&fe.header.align)||He.align;const Ye=pe.lookup||null;return He.lookup=Ye?s({id:ge,lookup:Ye},{locale:this.#a,onChange:()=>{this.#y&&this.#y("lookup",{colId:ge})}}):null,He.group.explode&&He.lookup&&He.lookup.multiple&&g(`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.#k(He),He}#k(te){te.formatter=h(te.format,te.dataType,this.#a,this.#l,te.id),te.formatValue=b(te,{locale:this.#a,grid:this.#f,context:this.#p}),te.itemCompare=te.itemType?r(te.itemType,this.#a):null,te.compare=X(te.value.compare)?te.value.compare:te.lookup?te.lookup.comparator():X(te.dataType.compareFor)?te.dataType.compareFor(te):r(te.dataType,this.#a),te.excel=te.formatter&&te.formatter.ooxml||te.dataType&&te.dataType.excel||"General",te.storeKind=n(te.dataType,!!(te.lookup&&te.lookup.multiple))}#C(te,oe,fe){let de=W(te.typeOptions)?te.typeOptions:null;for(let Ce=oe.length-1;!de&&Ce>=0;Ce--)W(oe[Ce].typeOptions)&&(de=oe[Ce].typeOptions);!de&&W(this.#i.typeOptions)&&(de=this.#i.typeOptions);const we=de&&de.of!==void 0?de.of:"text",Te=typeof we=="string"?this.#o.get(we):void 0;return Te&&!X(Te.items)&&Te.storage!=="object"?Te:(g(`type:of:${String(we)}`,`column "${fe}" 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.#o.get("text"))}#S(te,oe,fe){if(te.type===!1)return"text";if(te.type)return te.type;for(let de=oe.length-1;de>=0;de--)if(oe[de].type)return oe[de].type;if(this.#i.type)return this.#i.type;if(te.shadow){const de=typeof te.shadow=="string"?te.shadow:te.shadow.kind;if(de==="fitInfluence")return"boolean";if(de==="fitPredicted"||de==="fitResidual"||de==="fitStdResidual"||de==="fitLeverage"||de==="fitCooksD"||de==="tsTrend"||de==="tsSeasonal"||de==="tsResidual"||de==="tsCoverage"||de==="tsSmoothed"||de==="tsSmoothingAlpha"||de==="tsSmoothingBeta")return"number"}return fe||(te.lookup?"lookup":"text")}#E(te){const oe=this.all();this.#m=m(oe),this.#g?this.#g.setGraph(this.#m):this.#g=new A({columns:this.#e,graph:this.#m,grid:this.#f,context:this.#p,stored:te||null,rowKey:this.#b});const fe=this.#g;for(const de of oe)de.getValue=(we,Te)=>fe.value(de,we,Te)}all(){return this.#t.map(te=>this.#e.get(te))}visible(){return this.all().filter(te=>!te.layout.hidden)}get(te){return this.#e.get(te)}groups(){const te=oe=>{const fe=[];for(const de of oe)Array.isArray(de.columns)?fe.push({...de,columns:te(de.columns)}):de.column&&fe.push(de.column);return fe};return te(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(te){return c(this.#m,te)}value(te,oe,fe){return this.#g.value(te,oe,fe)}text(te,oe,fe){return this.#g.text(te,oe,fe)}checkImpure(te,oe){k(this.#e.get(te),oe)}setLocale(te){this.#a=te;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(te),this.#k(oe);this.#y&&this.#y("locale",{locale:te})}infer(te){const oe={};if(this.#w||!Array.isArray(te)||te.length===0)return oe;this.#w=!0;let fe=!1;for(const de of this.all()){const we=de.def;if(we.type!==void 0||!de.field||de.computed||de.lookup||this.#T(de))continue;const Te=de.read||(pe=>I(pe,de.field)),Ae=d(de.id,te,Te,this.#o,{sampleSize:this.#O});if(Ae===de.type)continue;oe[de.id]=Ae;const Ce=this.#A(we,Ae);Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},this.#e.set(de.id,Ce),he(this.#n,de.id,Ce),fe=!0}return fe&&this.#E(null),oe}redecorate(te,oe,fe={}){const de=this.#e.get(te);if(!de){g(`redecorate:${te}`,`columns.decorate('${te}', …): no column with id '${te}'.`);return}const we=de.def||{},Te={...W(we.cell)?we.cell:{}};Te.decoration=oe??void 0,fe&&"variant"in fe&&(Te.variant=fe.variant);const Ae={...we,cell:Te};this.#r.has(we)&&this.#r.set(Ae,this.#r.get(we));const Ce=this.#A(Ae,de.type);return Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},de.lookup&&de.lookup!==Ce.lookup&&X(de.lookup.destroy)&&de.lookup.destroy(),this.#e.set(te,Ce),he(this.#n,te,Ce),this.#E(null),this.#y&&this.#y("decorate",{colId:te}),Ce}destroy(){for(const te of this.#e.values())te.lookup&&X(te.lookup.destroy)&&te.lookup.destroy()}#T(te){for(const oe of te.presets){const fe=this.#s[oe];if(fe&&fe.type)return!0}return!!this.#i.type}#P(te){return!te.computed&&X(te.dataType&&te.dataType.toStorage)}storeReader(te){if(te.computed)return oe=>this.#g.value(te,oe,null);if(this.#P(te)){const oe=te.dataType.toStorage,fe={timeZone:this.#l,colId:te.id,itemType:te.itemType||null};return de=>oe(te.read(de),fe)}return te.read}storeValue(te,oe){if(!(!te||te.computed)&&X(te.read))return this.storeReader(te)(oe)}storeSchema(){const te=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const fe=this.storeReader(oe);let de=null;!oe.computed&&!this.#P(oe)&&typeof oe.field=="string"&&!oe.lookup&&(de=oe.field);const we={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:fe};de!==null&&(we.field=de),oe.lookup&&(we.dictionary=oe.lookup.dictionary()),te.push(we)}return te}state(){return this.all().map(te=>({id:te.id,width:te.layout.width,flex:te.layout.flex||void 0,hidden:!!te.layout.hidden,pin:te.layout.pin??null,sort:te.sort.direction??null,sortIndex:te.sort.direction?te.sort.order??0:null,groupIndex:te.group.enabled?te.group.index??0:null,pivotIndex:te.pivot.enabled?te.pivot.index??0:null,total:typeof te.total=="string"?te.total:null,groupTotal:typeof te.groupTotal=="string"?te.groupTotal:void 0,grandTotal:typeof te.grandTotal=="string"?te.grandTotal:void 0,decoration:te.cell&&te.cell.decoration!=null?ne(te.cell.decoration):void 0,variant:te.cell&&te.cell.variant!=null?ne(te.cell.variant):void 0}))}applyState(te,oe={}){const fe={applied:[],skipped:[]},de=Array.isArray(te)?te:te&&te.columns||[],we=!Array.isArray(te)&&te&&te.columnOrder||null;for(const Ae of de){if(!Ae||!Ae.id){fe.skipped.push({key:"?",reason:"no id"});continue}let Ce=this.#e.get(Ae.id);if(!Ce){fe.skipped.push({key:Ae.id,reason:"unknown column"});continue}if(Object.hasOwn(Ae,"decoration")||Object.hasOwn(Ae,"variant")){const pe=Ce.cell?Ce.cell.decoration:void 0,be=Ae.decoration??null,ge=Object.hasOwn(Ae,"variant"),Ne=ge&&!ie(Ce.cell?Ce.cell.variant:void 0,Ae.variant);(!ie(pe,be)||Ne)&&(this.redecorate(Ae.id,be,ge?{variant:Ae.variant??void 0}:{}),Ce=this.#e.get(Ae.id)||Ce)}Ae.width!=null&&(Ce.layout.width=Ae.width),Ae.flex!=null&&(Ce.layout.flex=Ae.flex),Ae.hidden!=null&&(Ce.layout.hidden=!!Ae.hidden),Ae.pin!==void 0&&(Ce.layout.pin=Ae.pin),Ae.sort!==void 0&&(Ce.sort.direction=Ae.sort),Ae.sortIndex!=null&&(Ce.sort.order=Ae.sortIndex),Ae.groupIndex!=null&&(Ce.group.enabled=!0,Ce.group.index=Ae.groupIndex),Ae.pivotIndex!=null&&(Ce.pivot.enabled=!0,Ce.pivot.index=Ae.pivotIndex),Ae.total!==void 0&&(Ce.total=Ae.total),Ae.groupTotal!==void 0&&(Ce.groupTotal=Ae.groupTotal),Ae.grandTotal!==void 0&&(Ce.grandTotal=Ae.grandTotal),fe.applied.push(Ae.id)}const Te=we||(oe&&oe.keepOrder?[]:de.map(Ae=>Ae&&Ae.id).filter(Boolean));if(Te.length){const Ae=Te.filter(pe=>this.#e.has(pe)),Ce=this.#t.filter(pe=>!Ae.includes(pe));this.#t=[...Ae,...Ce]}return this.#y&&this.#y("state",fe),fe}move(te,oe){this.#M(te,oe)&&(this.#$(),this.#y&&this.#y("move",{id:te,to:oe}))}reorder(te){const oe={applied:[],skipped:[]},fe=[];let de=0;for(const we of Array.isArray(te)?te:[]){const Te=de++;this.#M(we,Te)&&(oe.applied.push(we),fe.push({id:we,to:Te}))}if(!fe.length)return oe;if(this.#$(),this.#y)for(const we of fe)this.#y("move",we);return oe}#M(te,oe){const fe=this.#t.indexOf(te);if(fe===-1||Math.max(0,Math.min(Number(oe)||0,this.#t.length-1))===fe)return!1;const we=this.#e.get(te);if(we.layout.movable===!1||we.layout.lockPosition)return g(`move:${te}`,`column "${te}" is not movable; the move was ignored`),!1;const Te=this.#N(te,oe);return Te?(g(`move.married:${Te}`,`band "${Te}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(fe,1),this.#t.splice(Math.max(0,Math.min(oe,this.#t.length)),0,te),!0)}#N(te,oe){if(!this.#n||!this.#n.length)return null;const fe=this.#t.filter(Ae=>Ae!==te),de=Math.max(0,Math.min(oe,fe.length)),we=(Ae,Ce)=>{if(Array.isArray(Ae.columns)){for(const be of Ae.columns)we(be,Ce);return Ce}const pe=Ae.column?Ae.column.id:Ae.id;return pe&&Ce.push(pe),Ce},Te=Ae=>{for(const Ce of Ae){if(!Array.isArray(Ce.columns))continue;if(Ce.marryChildren===!0){const be=we(Ce,[]),ge=be.includes(te),Ne=be.map($e=>fe.indexOf($e)).filter($e=>$e>=0);if(Ne.length){const $e=Math.min(...Ne),He=Math.max(...Ne);if(ge?de<$e||de>He+1:de>$e&&de<=He)return Ce.id}}const pe=Te(Ce.columns);if(pe)return pe}return null};return Te(this.#n)}#$(){const te=new Map(this.#t.map((de,we)=>[de,we])),oe=de=>{if(!Array.isArray(de.columns)){const Te=de.column?de.column.id:de.id;return te.has(Te)?te.get(Te):1/0}let we=1/0;for(const Te of de.columns)we=Math.min(we,oe(Te));return we},fe=de=>{de.sort((we,Te)=>oe(we)-oe(Te));for(const we of de)Array.isArray(we.columns)&&fe(we.columns)};fe(this.#n)}#z(te){const oe=fe=>{for(let de=0;de<fe.length;de++){const we=fe[de];if(Array.isArray(we.columns)){const Te=oe(we.columns);if(Te)return Te}else if(we.column&&we.column.id===te)return fe.splice(de,1)[0]}return null};return oe(this.#n)}#H(te){const oe=[];for(let fe=te.length-1;fe>=0;fe--){const de=te[fe];Array.isArray(de.columns)&&(oe.push(...this.#H(de.columns)),de.columns.length===0&&(oe.push(de.id),te.splice(fe,1)))}return oe}#B(){const te=(oe,fe,de)=>{for(const we of oe)Array.isArray(we.columns)?te(we.columns,[...fe,we.id]):we.column&&(we.column.groupPath=fe)};te(this.#n,[])}#L(te){const oe=new Set(te),fe=this.#t.filter(Ae=>oe.has(Ae));if(!fe.length)return;const de=Math.min(...fe.map(Ae=>this.#t.indexOf(Ae))),we=this.#t.slice(0,de).filter(Ae=>!oe.has(Ae)),Te=this.#t.slice(de).filter(Ae=>!oe.has(Ae));this.#t=[...we,...fe,...Te]}#I(te){const oe=[],fe=de=>{if(Array.isArray(de.columns))for(const we of de.columns)fe(we);else de.column&&oe.push(de.column.id)};return fe(te),oe}#D(te){const oe=fe=>{for(const de of fe){if(!Array.isArray(de.columns))continue;if(de.id===te)return{node:de,parent:fe};const we=oe(de.columns);if(we)return we}return null};return oe(this.#n)}groupColumns(te,oe={}){const fe=w(te).filter(Ce=>this.#e.has(Ce));if(!fe.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ce of fe)if(this.#e.get(Ce).layout.lockPosition)return g(`columns.group.locked:${Ce}`,`column "${Ce}" is position-locked and cannot be grouped.`),null;const de=oe.groupId?this.#D(oe.groupId):null;if(oe.groupId&&!de)return g(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let we=null;if(!de&&oe.id!=null&&(we=String(oe.id),this.#D(we)||this.#e.has(we)))return g(`columns.group.idtaken:${we}`,`band id "${we}" is already in use; nothing was grouped.`),null;const Te=fe.map(Ce=>this.#z(Ce)).filter(Boolean);if(!Te.length)return null;let Ae;if(de)de.node.columns.push(...Te),Ae=de.node.id;else{const Ce={id:we||j("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Te},pe=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(pe,0,Ce),Ae=Ce.id}return this.#H(this.#n),this.#L(fe),this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"formed",groupId:Ae,ids:fe}),Ae}ungroupColumn(te){const oe=this.#e.get(te);if(!oe){g(`columns.ungroup.unknown:${te}`,`no column "${te}" to ungroup.`);return}const fe=oe.groupPath||[];if(!fe.length)return;const de=fe[fe.length-1],we=this.#D(de);if(!we)return;const Te=this.#z(te);if(!Te)return;const Ae=we.parent.indexOf(we.node);we.parent.splice(Ae+1,0,Te);const Ce=this.#H(this.#n),pe=this.#I(we.node);if(pe.length){this.#L(pe);const be=Math.max(...pe.map(Ne=>this.#t.indexOf(Ne))),ge=this.#t.filter(Ne=>Ne!==te);ge.splice(be+1,0,te),this.#t=ge}this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"removed",id:te,dissolved:Ce})}renameGroup(te,oe){const fe=this.#D(te);if(!fe){g(`columns.group.rename:${te}`,`no band "${te}" to rename.`);return}fe.node.title=String(oe??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:te,title:fe.node.title})}dissolveGroup(te){const oe=this.#D(te);if(!oe){g(`columns.group.dissolve:${te}`,`no band "${te}" to dissolve.`);return}const fe=oe.parent.indexOf(oe.node);oe.parent.splice(fe,1,...oe.node.columns),this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:te})}moveGroup(te,oe){const fe=this.#D(te);if(!fe){g(`columns.group.move:${te}`,`no band "${te}" to move.`);return}const de=fe.parent,we=de.indexOf(fe.node);we!==-1&&(de.splice(we,1),de.splice(Math.max(0,Math.min(oe,de.length)),0,fe.node),this.#_(),this.#B(),this.#y&&this.#y("columngroup",{action:"moved",groupId:te,to:oe}))}#_(){const te=[],oe=de=>{for(const we of de)Array.isArray(we.columns)?oe(we.columns):we.column&&te.push(we.column.id)};oe(this.#n);const fe=new Set(te);this.#t=[...te,...this.#t.filter(de=>!fe.has(de))]}groupTree(){const te=fe=>fe.map(de=>Array.isArray(de.columns)?{id:de.id,title:de.title||"",collapsible:!!de.collapsible,openByDefault:de.openByDefault!==!1,columns:te(de.columns)}:de.column?de.column.id:null).filter(de=>de!==null),oe=te(this.#n);return oe.some(fe=>fe&&typeof fe=="object")?oe:[]}applyGroupTree(te){if(!Array.isArray(te))return;const oe=new Set,fe=we=>{const Te=[];for(const Ae of we)if(Ae&&typeof Ae=="object"&&Array.isArray(Ae.columns)){const Ce=fe(Ae.columns);if(!Ce.length)continue;Te.push({id:Ae.id||j("grp"),title:Ae.title||"",collapsible:Ae.collapsible===!0,openByDefault:Ae.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ce})}else if(typeof Ae=="string"){const Ce=this.#e.get(Ae);Ce&&!oe.has(Ae)&&(oe.add(Ae),Te.push({column:Ce,path:[]}))}return Te},de=fe(te);for(const we of this.#t){if(oe.has(we))continue;const Te=this.#e.get(we);Te&&de.push({column:Te,path:[]})}this.#n=de,this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"applied"})}show(te){this.#X(te,!1)}hide(te){this.#X(te,!0)}#X(te,oe){const fe=[];for(const de of w(te)){const we=this.#e.get(de);if(we){if(oe&&we.layout.lockVisible){g(`lockVisible:${de}`,`column "${de}" is \`layout.lockVisible\` and cannot be hidden`);continue}we.layout.hidden!==oe&&(we.layout.hidden=oe,fe.push(de))}}fe.length&&this.#y&&this.#y("visible",{ids:fe,hidden:oe})}pin(te,oe){const fe=this.#e.get(te);fe&&(fe.layout.pin=oe??null,this.#y&&this.#y("pin",{id:te,side:fe.layout.pin}))}resize(te,oe){const fe=this.#e.get(te);if(!fe)return;if(fe.layout.resizable===!1){g(`resize:${te}`,`column "${te}" is not resizable; the resize was ignored`);return}const de=fe.layout.min??0,we=fe.layout.max;let Te=Math.max(de,oe);we!=null&&(Te=Math.min(we,Te)),fe.layout.width=Te,fe.layout.flex=0,this.#y&&this.#y("resize",{id:te,width:Te})}}function ee(ce){const te={};return ce.width!=null&&(te.width=ce.width),ce.hidden!=null&&(te.hidden=ce.hidden),ce.pin!==void 0&&(te.pin=ce.pin),te}function ne(ce){if(ce===null||typeof ce!="object")return ce;try{return structuredClone(ce)}catch{}try{return JSON.parse(JSON.stringify(ce))}catch{return ce}}function ie(ce,te){const oe=ce??null,fe=te??null;if(oe===fe)return!0;if(oe===null||fe===null)return!1;if(typeof oe!="object"||typeof fe!="object")return oe===fe;try{return JSON.stringify(oe)===JSON.stringify(fe)}catch{return!1}}function se(ce){const te=[],oe=(de,we,Te)=>{const Ae=[];for(const Ce of de){if(!W(Ce)){B("a column definition must be an object");continue}if(Array.isArray(Ce.columns)){N(Ce,v,"columnGroup",Ce.title||Ce.id||"(unnamed)");const pe={id:Ce.id||j("grp"),title:Ce.title||"",collapsible:Ce.collapsible===!0,openByDefault:Ce.openByDefault!==!1,showWhen:Ce.showWhen||"always",marryChildren:Ce.marryChildren===!0,header:Ce.header||{},def:Ce,columns:[]};pe.columns=oe(Ce.columns,[...we,pe.id],Ce.facet!==void 0?Ce.facet:Te),Ae.push(pe)}else{const pe={def:Ce,path:we,facet:Te};te.push(pe),Ae.push(pe)}}return Ae},fe=oe(ce,[],void 0);return{leaves:te,groups:fe}}function he(ce,te,oe){for(const fe of ce){if(fe.columns){if(he(fe.columns,te,oe))return!0;continue}if(fe.column&&fe.column.id===te)return fe.column=oe,!0}return!1}}),Le("packages/core/src/columns/autogroup.js",function(e,K){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return W}});const x=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",I=240,_=.5;function X(V){const{columns:H,groupBy:z}=V,w=z.map(u=>H.get(u)).filter(Boolean),j=w.length?w.map(u=>u.title||u.id).join(" > "):"Group",g=V.config&&V.config.autoGroupColumnWidth||I;return{id:B,field:null,title:j,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:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:g,min:120,pin:V.config&&V.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(u,h){return h&&h.group?h.groupValue:null},formatValue(u,h){if(!h||!h.group)return"";if(h.grandTotal)return V.config&&V.config.grandTotalLabel||"Total";const a=w[Math.min(h.level||0,w.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(u,h):u==null?"":String(u)}}}function W(V,H,z){!V.length||z<100||H<z*_||x(`grouping.cardinality:${V.join(",")}`,`grouping by ${V.join(", ")} produced ${H} groups for ${z} 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.`)}}),Le("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_select",x=44;function B(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||x;return{id:Q,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:W,min:W,max:W,pin:_.config&&_.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:X.headerCheckbox===!0,def:{},getValue(V,H){return H?H.selected:!1},formatValue(){return""}}}const I=B}),Le("packages/core/src/columns/rownumbercolumn.js",function(e,K){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",I=40,_=9,X=22;function W(z){const w=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(I,w*_+X)}function V(z){const w=z.rowNumbers,j=w&&typeof w=="object"?w:{},g=Number.isFinite(j.start)?j.start:1,u=Number.isFinite(j.width)?j.width:W((z.maxNumber||0)+g),h=x(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof j.title=="string"?j.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:u,min:u,max:u,pin:"start",hidden:!1,resizable:j.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,r){const t=h(r);return t==null?null:t-1+g},formatValue(a){return a==null?"":String(a)}}}const H=V}),Le("packages/core/src/model/detail.js",function(e,K){"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 _}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=240,_=10;function X(H){if(!H)return null;const z=H===!0?{}:H;return z.enabled===!1?null:!x(z.rows)&&!z.render?(B("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:z.render||null,config:z.config||null,rows:x(z.rows)?z.rows:null,height:z.height??I,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:x(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:x(z.onCreate)?z.onCreate:null,path:typeof z.path=="string"?z.path:null}}class W{#e;#t=new Set;#n;#r=0;constructor(z){this.#e=z.config,this.#n=x(z.onChange)?z.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(z){if(!z||z.group||z.detail)return!1;const w=this.#e.isMaster;return w?!!w(z.data,z):!0}isOpen(z){return this.#t.has(z)}keys(){return[...this.#t]}activeKey(){for(const z of this.#t)return z;return null}heightOf(z){const w=this.#e.height;return x(w)?Number(w(z))||I:w==="auto"?I:Number(w)||I}open(z){return this.#t.has(z)?!1:(this.inline||this.#t.clear(),this.#t.add(z),this.#o(),!0)}close(z){return this.#t.delete(z)?(this.#o(),!0):!1}toggle(z){return this.#t.has(z)?(this.close(z),!1):(this.open(z),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(z){if(!this.#t.size||!x(z))return;let w=!1;for(const j of[...this.#t])z(j)||(this.#t.delete(j),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const w=Array.isArray(z)?z:[];for(const j of this.inline?w:w.slice(0,1))this.#t.add(j);this.#o()}#o(){this.#r++,this.#n()}}const V=W}),Le("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),x=3e-12,B=1e-300;function I(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-I(1-r);const t=r-1;let n=.9999999999998099;const o=t+7.5;for(let d=0;d<Q.length;d++)n+=Q[d]/(t+d+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(o)-o+Math.log(n)}function _(r,t,n){const o=r+t,d=r+1,l=r-1;let i=1,m=1-o*n/d;Math.abs(m)<B&&(m=B),m=1/m;let c=m;for(let f=1;f<=300;f++){const s=2*f;let p=f*(t-f)*n/((l+s)*(r+s));m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m,c*=m*i,p=-(r+f)*(o+f)*n/((r+s)*(d+s)),m=1+p*m,Math.abs(m)<B&&(m=B),i=1+p/i,Math.abs(i)<B&&(i=B),m=1/m;const b=m*i;if(c*=b,Math.abs(b-1)<x)break}return c}function X(r,t,n){if(!(r>0)||!(t>0)||!Number.isFinite(n))return Number.NaN;if(n<=0)return 0;if(n>=1)return 1;const o=Math.exp(I(r+t)-I(r)-I(t)+r*Math.log(n)+t*Math.log(1-n));return n<(r+1)/(r+t+2)?o*_(r,t,n)/r:1-o*_(t,r,1-n)/t}function W(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],n=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],d=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],l=.02425;let i,m,c;r<l?(i=Math.sqrt(-2*Math.log(r)),c=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+1)):r<=1-l?(i=r-.5,m=i*i,c=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*i/(((((n[0]*m+n[1])*m+n[2])*m+n[3])*m+n[4])*m+1)):(i=Math.sqrt(-2*Math.log(1-r)),c=-(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+1));const s=(.5*V(-c/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-s/(1+c*s/2)}function V(r){const t=Math.abs(r),n=2/(2+t),o=4*n-2,d=[-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 l=0,i=0,m;for(let f=d.length-1;f>0;f--)m=i,i=o*i-l+d[f],l=m;const c=n*Math.exp(-t*t+.5*(d[0]+o*i)-l);return r>=0?c:2-c}function H(r){return .5*V(-r/Math.SQRT2)}function z(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const n=.5*X(t/2,.5,t/(t+r*r));return r>0?1-n:n}function w(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return W(r);let n=-1e4,o=1e4,d=W(r);const l=I(t/2)+I(.5)-I((t+1)/2);for(let i=0;i<60;i++){const m=z(d,t);m<r?n=d:o=d;const c=Math.exp(-((t+1)/2)*Math.log(1+d*d/t)-l)/Math.sqrt(t),f=c>0?(m-r)/c:0;if(Math.abs(f)<1e-12)break;const s=d-f;if(d=s>n&&s<o&&Number.isFinite(s)?s:(n+o)/2,o-n<1e-12)break}return d}function j(r,t){let n=r,o=1/r,d=o;for(let l=0;l<300&&(n+=1,d*=t/n,o+=d,!(Math.abs(d)<Math.abs(o)*x));l++);return o*Math.exp(-t+r*Math.log(t)-I(r))}function g(r,t){let n=t+1-r,o=1/B,d=1/n,l=d;for(let i=1;i<=300;i++){const m=-i*(i-r);n+=2,d=m*d+n,Math.abs(d)<B&&(d=B),o=n+m/o,Math.abs(o)<B&&(o=B),d=1/d;const c=d*o;if(l*=c,Math.abs(c-1)<x)break}return Math.exp(-t+r*Math.log(t)-I(r))*l}function u(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?j(r,t):1-g(r,t)}function h(r,t){return t>0?u(t/2,r/2):Number.NaN}function a(r,t){const n=h(r,t);return Number.isNaN(n)?Number.NaN:Math.min(1,Math.max(0,1-n))}}),Le("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(W){const V=W.length,H=Array.from({length:V},()=>new Array(V).fill(0));for(let z=0;z<V;z++)for(let w=0;w<=z;w++){let j=W[z][w];for(let g=0;g<w;g++)j-=H[z][g]*H[w][g];if(z===w){if(!(j>0))return null;H[z][w]=Math.sqrt(j)}else H[z][w]=j/H[w][w]}return H}function x(W,V){const H=W.length,z=new Array(H).fill(0);for(let j=0;j<H;j++){let g=V[j];for(let u=0;u<j;u++)g-=W[j][u]*z[u];z[j]=g/W[j][j]}const w=new Array(H).fill(0);for(let j=H-1;j>=0;j--){let g=z[j];for(let u=j+1;u<H;u++)g-=W[u][j]*w[u];w[j]=g/W[j][j]}return w}function B(W){const V=W.length,H=Array.from({length:V},()=>new Array(V).fill(0));for(let z=0;z<V;z++){const w=new Array(V).fill(0);w[z]=1;const j=x(W,w);for(let g=0;g<V;g++)H[g][z]=j[g]}return H}function I(W,V,H){const z=W.length,w=z?W[0].length:0,j=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let u=0;u<z;u++){const h=H?H[u]:1,a=W[u];for(let r=0;r<w;r++){const t=h*a[r];g[r]+=t*V[u];for(let n=r;n<w;n++)j[r][n]+=t*a[n]}}for(let u=0;u<w;u++)for(let h=0;h<u;h++)j[u][h]=j[h][u];return{xtwx:j,xtwy:g}}function _(W,V){return W.map(H=>H.reduce((z,w,j)=>z+w*V[j],0))}function X(W,V){let H=0;for(let z=0;z<W.length;z++){let w=0;for(let j=0;j<W.length;j++)w+=V[z][j]*W[j];H+=W[z]*w}return H}}),Le("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});class Q{#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(u){if(!Number.isFinite(u))return;this.#e++;const h=u-this.#t;this.#t+=h/this.#e,this.#n+=h*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const h=this.#e+u.#e,a=u.#t-this.#t;this.#t+=a*(u.#e/h),this.#n+=u.#n+a*a*(this.#e*u.#e/h),this.#e=h}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 u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class x{#e=[];#t=0;#n;#r;constructor(u,h=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=h}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(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const h=Math.floor(this.#r()*this.#t);h<this.#n&&(this.#e[h]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const h of this.#e)u+=h;return u/this.#e.length}quantile(u){const h=this.#e.length;if(!h)return null;const a=this.#e.slice().sort((o,d)=>o-d);if(h===1)return a[0];const r=(h-1)*Math.min(1,Math.max(0,u)),t=Math.floor(r),n=Math.ceil(r);return t===n?a[t]:a[t]+(r-t)*(a[n]-a[t])}}function B(g){return g^=g>>>16,g=Math.imul(g,2246822507),g^=g>>>13,g=Math.imul(g,3266489909),g^=g>>>15,g>>>0}function I(g){if(typeof g=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,g===0?0:g),B(a.getUint32(0)^a.getUint32(4))}const u=typeof g=="string"?g:String(g);let h=2166136261;for(let a=0;a<u.length;a++)h^=u.charCodeAt(a),h=Math.imul(h,16777619);return B(h)}class _{#e;#t;#n;constructor(u=14){const h=Math.floor(u);if(h<4||h>16)throw new RangeError("HLL precision must be 4..16");this.#e=h,this.#t=1<<h,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const h=1<<Math.floor(u),a=1.04/Math.sqrt(h);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${h} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(u){const h=I(u),a=h&this.#t-1,r=h>>>this.#e|1<<32-this.#e;let t=1,n=r;for(;(n&1)===0;)t++,n>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const u=this.#t,h=32-this.#e,a=new Float64Array(h+2);for(let n=0;n<u;n++)a[this.#n[n]]++;let r=u*V(1-a[h+1]/u);for(let n=h;n>=1;n--)r=.5*(r+a[n]);r+=u*W(a[0]/u);const t=X*u*u/r;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let u=1,h=g,a;do g*=g,a=h,h+=g*u,u+=u;while(h!==a);return h}function V(g){if(g===0||g===1)return 0;let u=1,h=1-g,a;do g=Math.sqrt(g),a=h,u*=.5,h-=(1-g)**2*u;while(h!==a);return h/3}class H{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const h=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:h,statement:`each count overestimates the truth by at most N/m = ${h.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const h=this.#e.get(u);if(h){h.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let a,r=1/0;for(const[t,n]of this.#e)n.count<r&&(r=n.count,a=t);this.#e.delete(a),this.#e.set(u,{count:r+1,error:r})}top(u=this.#t){return[...this.#e.entries()].map(([a,r])=>({item:a,count:r.count,error:r.error})).sort((a,r)=>r.count-a.count).slice(0,Math.max(0,Math.floor(u)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(u=200,h=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=h,this.#o=2/3}static errorBoundFor(u=200){const h=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:h,statement:`queried quantile's true rank within ~${(h*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(u){const a=this.#t.length-1-u,r=Math.ceil(this.#e*this.#o**a);return Math.max(2,r)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(u){const h=this.#t[u];h.sort((t,n)=>t-n),u+1>=this.#t.length&&this.#t.push([]);const a=this.#t[u+1],r=this.#r()<.5?0:1;for(let t=r;t<h.length;t+=2)a.push(h[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const u=[];for(let h=0;h<this.#t.length;h++){const a=1<<h;for(const r of this.#t[h])u.push({v:r,w:a})}return u}quantile(u){const h=this.#l();if(!h.length)return null;h.sort((n,o)=>n.v-o.v);let a=0;for(const n of h)a+=n.w;const r=Math.min(1,Math.max(0,u))*a;let t=0;for(const n of h)if(t+=n.w,t>=r)return n.v;return h[h.length-1].v}rank(u){let h=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const t of this.#t[a])t<=u&&(h+=r)}return h}}const w=Object.freeze({distinct:_.errorBoundFor(14),median:z.errorBoundFor(200),p25:z.errorBoundFor(200),p75:z.errorBoundFor(200),p90:z.errorBoundFor(200),p95:z.errorBoundFor(200),p99:z.errorBoundFor(200),iqr:z.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"})}),j={Welford:Q,Reservoir:x,HyperLogLog:_,SpaceSaving:H,KLL:z,hash32:I,SKETCH_BOUNDS:w}}),Le("packages/core/src/compute/statistics.js",function(e,K){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return qe}});const Q=K("packages/core/src/compute/handle.js"),x=Q.presenceReader,B=Q.valueReader,I=K("packages/core/src/compute/special.js"),_=I.studentTQuantile,X=I.studentT,W=I.normalQuantile,V=I.normalCdf,H=I.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),w=z.cholesky,j=z.choleskySolve,g=z.choleskyInverse,u=z.normalEquations,h=z.quadForm,r=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,n=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"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"}),o=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function d(ye){const ke=ye==="sum"||ye==="avg"||ye==="countValues"||ye==="min"||ye==="max"?"maintained":Object.prototype.hasOwnProperty.call(n,ye)?n[ye]:null,me=Object.prototype.hasOwnProperty.call(o,ye)?o[ye]:null;return{stat:ye,exact:ke,approximate:me}}function l(ye,ke){const me=ke.length,je=new Float64Array(me);let Me=0;if(ye&&(ye.kind==="float64"||ye.kind==="int32")){const De=ye.values,Se=x(ye);for(let xe=0;xe<me;xe++){const Be=ke[xe];if(Se&&Se(Be)!==1)continue;const Je=De[Be];Number.isNaN(Je)||(je[Me++]=Je)}return je.subarray(0,Me)}const _e=B(ye);for(let De=0;De<me;De++){const Se=_e(ke[De]);if(Se==null||Se==="")continue;const xe=typeof Se=="number"?Se:Number(Se);Number.isFinite(xe)&&(je[Me++]=xe)}return je.subarray(0,Me)}function i(ye,ke){const me=new Map,je=B(ye);let Me=0;for(let _e=0;_e<ke.length;_e++){const De=je(ke[_e]);if(De==null||De===""||typeof De=="number"&&Number.isNaN(De))continue;const Se=typeof De=="object"?String(De):De;me.set(Se,(me.get(Se)||0)+1),Me++}const ze=[...me.values()].sort((_e,De)=>De-_e);return{counts:ze,total:Me,distinct:ze.length}}function m(ye){return ye.total>0?ye.counts.map(ke=>ke/ye.total):[]}function c(ye,ke){const me=i(ye,ke);if(!me.total)return null;let je=0;for(const Me of m(me))je+=Me*Me;return je}function f(ye,ke){const me=i(ye,ke);if(!me.total)return null;let je=0;for(const Me of m(me))Me>0&&(je-=Me*Math.log2(Me));return je}function s(ye,ke){const me=i(ye,ke);if(!me.total||me.distinct<2)return me.total?1:null;let je=0;for(const Me of m(me))Me>0&&(je-=Me*Math.log2(Me));return je/Math.log2(me.distinct)}function p(ye,ke,me=3){const je=i(ye,ke);if(!je.total)return null;const Me=Math.max(1,Math.floor(me));let ze=0;for(let _e=0;_e<Math.min(Me,je.counts.length);_e++)ze+=je.counts[_e];return ze/je.total}function b(ye,ke){const me=l(ye,ke),je=me.length;if(!je)return null;const Me=me.slice().sort();if(Me[0]<0)return null;let ze=0,_e=0;for(let De=0;De<je;De++)ze+=Me[De],_e+=(De+1)*Me[De];return ze===0?0:2*_e/(je*ze)-(je+1)/je}function A(ye){let ke=0,me=0,je=0;for(let Me=0;Me<ye.length;Me++){const ze=ye[Me];ke++;const _e=ze-me;me+=_e/ke,je+=_e*(ze-me)}return{n:ke,mean:me,m2:je}}function k(ye,ke){const me=ye.length;if(!me)return NaN;if(me===1)return ye[0];const je=(me-1)*Math.min(1,Math.max(0,ke)),Me=Math.floor(je),ze=Math.ceil(je);return Me===ze?ye[Me]:ye[Me]+(je-Me)*(ye[ze]-ye[Me])}function y(ye,ke){if(!ye.length)return NaN;const me=ye.slice().sort();return k(me,ke)}function S(ye,ke){const me=B(ye);let je=0,Me=0,ze=0;for(let _e=0;_e<ke.length;_e++){const De=me(ke[_e]);if(De==null||De==="")continue;const Se=String(De).toUpperCase();Se==="PASS"?je++:Se==="FAIL"?Me++:Se==="WARN"&&ze++}return{pass:je+ze,fail:Me,warn:ze,judged:je+ze+Me}}const R=Object.freeze({hhi:(ye,ke)=>c(ye,ke),entropy:(ye,ke)=>f(ye,ke),evenness:(ye,ke)=>s(ye,ke),top3Share:(ye,ke)=>p(ye,ke,3),top10Share:(ye,ke)=>p(ye,ke,10),gini:(ye,ke)=>b(ye,ke),trimmedMean:(ye,ke)=>L(l(ye,ke),.1),winsorizedMean:(ye,ke)=>C(l(ye,ke),.1),robustOutliers:(ye,ke)=>D(l(ye,ke),3.5),jarqueBera:(ye,ke)=>$(l(ye,ke)),variance:(ye,ke)=>{const{n:me,m2:je}=A(l(ye,ke));return me>1?je/(me-1):null},varianceP:(ye,ke)=>{const{n:me,m2:je}=A(l(ye,ke));return me>0?je/me:null},stddev:(ye,ke)=>{const{n:me,m2:je}=A(l(ye,ke));return me>1?Math.sqrt(je/(me-1)):null},stddevP:(ye,ke)=>{const{n:me,m2:je}=A(l(ye,ke));return me>0?Math.sqrt(je/me):null},median:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.5):null},p25:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.25):null},p75:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.75):null},p90:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.9):null},p95:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.95):null},p99:(ye,ke)=>{const me=l(ye,ke);return me.length?y(me,.99):null},iqr:(ye,ke)=>{const me=l(ye,ke);if(!me.length)return null;const je=me.slice().sort();return k(je,.75)-k(je,.25)},mad:(ye,ke)=>{const me=l(ye,ke);if(!me.length)return null;const je=y(me,.5),Me=new Float64Array(me.length);for(let ze=0;ze<me.length;ze++)Me[ze]=Math.abs(me[ze]-je);return y(Me,.5)},range:(ye,ke)=>{const me=l(ye,ke);if(!me.length)return null;let je=1/0,Me=-1/0;for(let ze=0;ze<me.length;ze++)me[ze]<je&&(je=me[ze]),me[ze]>Me&&(Me=me[ze]);return Me-je},distinct:(ye,ke)=>{const me=B(ye),je=new Set;for(let Me=0;Me<ke.length;Me++){const ze=me(ke[Me]);ze==null||ze===""||je.add(ze instanceof Date?ze.getTime():ze)}return je.size},mode:(ye,ke)=>{const me=B(ye),je=new Map;for(let _e=0;_e<ke.length;_e++){const De=me(ke[_e]);if(De==null||De==="")continue;const Se=De instanceof Date?De.getTime():De;je.set(Se,(je.get(Se)||0)+1)}let Me=null,ze=1;for(const[_e,De]of je)De>ze&&(ze=De,Me=_e);return Me},skewness:(ye,ke)=>{const me=l(ye,ke),{n:je,mean:Me,m2:ze}=A(me);if(je<3||ze<=0)return null;const _e=Math.sqrt(ze/(je-1));let De=0;for(let Se=0;Se<me.length;Se++)De+=((me[Se]-Me)/_e)**3;return je/((je-1)*(je-2))*De},kurtosis:(ye,ke)=>{const me=l(ye,ke),{n:je,mean:Me,m2:ze}=A(me);if(je<4||ze<=0)return null;const _e=Math.sqrt(ze/(je-1));let De=0;for(let Be=0;Be<me.length;Be++)De+=((me[Be]-Me)/_e)**4;const Se=je*(je+1)/((je-1)*(je-2)*(je-3)),xe=3*(je-1)**2/((je-2)*(je-3));return Se*De-xe},geomean:(ye,ke)=>{const me=l(ye,ke);if(!me.length)return null;let je=0;for(let Me=0;Me<me.length;Me++){if(me[Me]<=0)return null;je+=Math.log(me[Me])}return Math.exp(je/me.length)},harmean:(ye,ke)=>{const me=l(ye,ke);if(!me.length)return null;let je=0;for(let Me=0;Me<me.length;Me++){if(me[Me]===0)return null;je+=1/me[Me]}return me.length/je},sumSquares:(ye,ke)=>{const me=l(ye,ke);let je=0;for(let Me=0;Me<me.length;Me++)je+=me[Me]*me[Me];return je},passRate:(ye,ke)=>{const{pass:me,judged:je}=S(ye,ke);return je?me/je:null},failureCount:(ye,ke)=>S(ye,ke).fail}),O=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",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 F(ye,ke,me){const je=B(ye),Me=B(ke);let ze=0,_e=0;for(let De=0;De<me.length;De++){const Se=me[De],xe=Number(je(Se)),Be=Number(Me(Se));!Number.isFinite(xe)||!Number.isFinite(Be)||(ze+=xe*Be,_e+=Be)}return _e===0?null:ze/_e}function E(ye,ke,me){const je=B(ye);let Me=null,ze=me?-1/0:1/0;for(let _e=0;_e<ke.length;_e++){const De=ke[_e],Se=Number(je(De));Number.isFinite(Se)&&(me?Se>ze:Se<ze)&&(ze=Se,Me=De)}return Me}function T(ye,ke,me){const je=B(ye),Me=B(ke);let ze=0,_e=0,De=0,Se=0,xe=0,Be=0;for(let it=0;it<me.length;it++){const gt=me[it],wt=Number(je(gt)),dt=Number(Me(gt));!Number.isFinite(wt)||!Number.isFinite(dt)||(ze++,_e+=wt,De+=dt,Se+=wt*wt,xe+=dt*dt,Be+=wt*dt)}if(ze<2)return null;const Je=ze*Be-_e*De,Qe=Math.sqrt((ze*Se-_e*_e)*(ze*xe-De*De));if(Qe===0)return null;const at=Je/Qe;return Math.max(-1,Math.min(1,at))}function L(ye,ke=.1){const me=ye.length;if(!me)return null;const je=Array.from(ye).sort((De,Se)=>De-Se),Me=Math.floor(me*Math.min(.49,Math.max(0,ke))),ze=je.slice(Me,me-Me);if(!ze.length)return k(je,.5);let _e=0;for(const De of ze)_e+=De;return _e/ze.length}function C(ye,ke=.1){const me=ye.length;if(!me)return null;const je=Array.from(ye).sort((Se,xe)=>Se-xe),Me=Math.floor(me*Math.min(.49,Math.max(0,ke))),ze=je[Me],_e=je[me-1-Me];let De=0;for(const Se of je)De+=Math.min(_e,Math.max(ze,Se));return De/me}function D(ye,ke=3.5){if(!ye.length)return null;const je=Array.from(ye).sort((Se,xe)=>Se-xe),Me=k(je,.5),ze=je.map(Se=>Math.abs(Se-Me)).sort((Se,xe)=>Se-xe),_e=k(ze,.5);if(_e===0)return null;let De=0;for(const Se of je)Math.abs(.6745*(Se-Me)/_e)>ke&&De++;return De}function $(ye){const ke=ye.length;if(ke<8)return null;let me=0;for(const Se of ye)me+=Se;me/=ke;let je=0,Me=0,ze=0;for(const Se of ye){const xe=Se-me;je+=xe*xe,Me+=xe*xe*xe,ze+=xe*xe*xe*xe}if(je/=ke,Me/=ke,ze/=ke,je===0)return null;const _e=Me/je**1.5,De=ze/(je*je)-3;return ke/6*(_e*_e+De*De/4)}function P(ye,ke,me){const je=[];let Me=0;for(let Se=0;Se<ye.length;Se++){const xe=Number(ye[Se]),Be=Number(ke[Se]);!Number.isFinite(xe)||!Number.isFinite(Be)||Be<=0||(je.push([xe,Be]),Me+=Be)}if(!je.length||Me<=0)return null;if(je.sort((Se,xe)=>Se[0]-xe[0]),je.length===1)return je[0][0];const ze=[];let _e=0;for(const[,Se]of je)ze.push((_e+Se/2)/Me),_e+=Se;const De=Math.max(0,Math.min(1,me));if(De<=ze[0])return je[0][0];if(De>=ze[ze.length-1])return je[je.length-1][0];for(let Se=1;Se<ze.length;Se++){if(De>ze[Se])continue;const xe=ze[Se]-ze[Se-1],Be=xe>0?(De-ze[Se-1])/xe:0;return je[Se-1][0]+(je[Se][0]-je[Se-1][0])*Be}return je[je.length-1][0]}function v(ye,ke,me){const je=B(ye),Me=B(ke),ze=new Float64Array(me.length),_e=new Float64Array(me.length);let De=0;for(let Se=0;Se<me.length;Se++){const xe=me[Se],Be=Number(je(xe)),Je=Number(Me(xe));!Number.isFinite(Be)||!Number.isFinite(Je)||(ze[De]=Be,_e[De]=Je,De++)}return{xs:ze.subarray(0,De),ys:_e.subarray(0,De),n:De}}function N(ye,ke,me,je=!1){const{xs:Me,ys:ze,n:_e}=v(ye,ke,me);if(_e<2)return null;let De=0,Se=0;for(let Be=0;Be<_e;Be++)De+=Me[Be],Se+=ze[Be];De/=_e,Se/=_e;let xe=0;for(let Be=0;Be<_e;Be++)xe+=(Me[Be]-De)*(ze[Be]-Se);return xe/(je?_e:_e-1)}function G(ye,ke,me){const{xs:je,ys:Me,n:ze}=v(ye,ke,me);if(ze<2)return null;let _e=0,De=0;for(let wt=0;wt<ze;wt++)_e+=je[wt],De+=Me[wt];_e/=ze,De/=ze;let Se=0,xe=0,Be=0;for(let wt=0;wt<ze;wt++){const dt=je[wt]-_e,jt=Me[wt]-De;Se+=dt*dt,xe+=dt*jt,Be+=jt*jt}if(Se===0)return null;const Je=xe/Se,Qe=De-Je*_e,at=Be===0?1:Math.max(0,Math.min(1,xe*xe/(Se*Be))),it=Math.max(0,Be-Je*xe),gt=ze>2?Math.sqrt(it/(ze-2)/Se):0;return{slope:Je,intercept:Qe,r2:at,stdError:gt,n:ze}}const q=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function ne(ye,ke,me){const{xtwx:je,xtwy:Me}=u(ye,ke,me),ze=w(je);if(!ze)return null;const _e=j(ze,Me),De=g(ze),Se=ie(ye,_e),xe=ke.map((Be,Je)=>Be-Se[Je]);return{beta:_e,cov:De,fitted:Se,residuals:xe}}function ie(ye,ke){return ye.map(me=>me.reduce((je,Me,ze)=>je+Me*ke[ze],0))}function se(ye,ke){const me=ye.length,je=ye.map(xe=>xe[ke]),Me=ye.map(xe=>[1,...xe.filter((Be,Je)=>Je!==ke)]),ze=ne(Me,je,null);if(!ze)return 1;const _e=je.reduce((xe,Be)=>xe+Be,0)/me;let De=0,Se=0;for(let xe=0;xe<me;xe++)De+=ze.residuals[xe]**2,Se+=(je[xe]-_e)**2;return Se===0?1:Math.max(0,Math.min(1,1-De/Se))}function he(ye){const ke=[...ye].sort((Me,ze)=>Me-ze),me=ce(ke),je=ye.map(Me=>Math.abs(Me-me)).sort((Me,ze)=>Me-ze);return ce(je)/.6745}function ce(ye){const ke=ye.length;if(!ke)return 0;const me=Math.floor(ke/2);return ke%2?ye[me]:(ye[me-1]+ye[me])/2}function te(ye,ke,me={}){const je=me.method||"ols";if(J.has(je))throw new Error(`[lattice] regression method "${je}" is out of scope; use ols, wls or robust.`);if(Z.has(je))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!q.has(je))throw new Error(`[lattice] unknown regression method "${je}"; use ols, wls or robust.`);const Me=Array.isArray(ke)?ke.length:0,ze=Me&&Array.isArray(ye[0])?ye[0].length:0,_e=ze+1;if(!(Me>_e))return null;for(let Mt=0;Mt<Me;Mt++){if(!Number.isFinite(ke[Mt])||!Array.isArray(ye[Mt])||ye[Mt].length!==ze)return null;for(let xt=0;xt<ze;xt++)if(!Number.isFinite(ye[Mt][xt]))return null}let De=null;if(je==="wls"){if(De=me.weights,!Array.isArray(De)||De.length!==Me)return null;for(let Mt=0;Mt<Me;Mt++)if(!(De[Mt]>0)||!Number.isFinite(De[Mt]))return null}const Se=ye.map(Mt=>[1,...Mt]);let xe,Be=null;if(je==="robust"){if(xe=ne(Se,ke,null),!xe)return null;for(let Mt=0;Mt<50;Mt++){const xt=he(xe.residuals);if(!(xt>0))break;const Bt=xe.residuals.map(Yt=>{const Jt=Math.abs(Yt/xt);return Jt<=ee?1:ee/Jt}),Kt=ne(Se,ke,Bt);if(!Kt)return null;const Qt=Kt.beta.reduce((Yt,Jt,nn)=>Math.max(Yt,Math.abs(Jt-xe.beta[nn])),0);if(xe=Kt,Be=Bt,Qt<1e-10)break}}else if(xe=ne(Se,ke,De),!xe)return null;const Je=je==="robust"?Be:De,{beta:Qe,cov:at,fitted:it,residuals:gt}=xe;let wt=0,dt=0,jt=0;for(let Mt=0;Mt<Me;Mt++){const xt=Je?Je[Mt]:1;wt+=xt*gt[Mt]**2,dt+=xt,jt+=xt*ke[Mt]}const Ve=jt/dt;let pt=0;for(let Mt=0;Mt<Me;Mt++){const xt=Je?Je[Mt]:1;pt+=xt*(ke[Mt]-Ve)**2}const ct=Me-_e,ot=wt/ct,St=pt===0?1:Math.max(0,Math.min(1,1-wt/pt)),At=1-(1-St)*(Me-1)/ct,ft=Array.isArray(me.names)&&me.names.length===ze?me.names:ye[0].map((Mt,xt)=>`x${xt+1}`),Nt=Ct(me.confidence),Dt=ct>0?_(1-(1-Nt)/2,ct):1/0,_t=Qe.map((Mt,xt)=>{const Bt=Math.sqrt(Math.max(0,ot*at[xt][xt])),Kt=Bt>0?Mt/Bt:Mt===0?0:1/0,Qt=Number.isFinite(Kt)?2*(1-X(Math.abs(Kt),ct)):0,Yt=Number.isFinite(Dt)?Dt*Bt:null;return{name:xt===0?"(intercept)":ft[xt-1],estimate:Mt,stdError:Bt,t:Kt,p:Math.max(0,Math.min(1,Qt)),lower:Yt===null?null:Mt-Yt,upper:Yt===null?null:Mt+Yt}}),pn=new Array(Me),sn=new Array(Me);for(let Mt=0;Mt<Me;Mt++){const xt=Je?Je[Mt]:1,Bt=Math.max(0,Math.min(1,xt*h(Se[Mt],at)));pn[Mt]=Bt;const Kt=(1-Bt)**2;sn[Mt]=Kt>0&&ot>0?gt[Mt]**2/(_e*ot)*(Bt/Kt):null}const cn=ye[0].map((Mt,xt)=>{if(ze<2)return 1;const Bt=se(ye,xt);return Bt>=1?1/0:1/(1-Bt)});let qt=null;{const Mt=gt.map(Bt=>Bt*Bt),xt=ne(Se,Mt,null);if(xt){const Bt=Mt.reduce((en,un)=>en+un,0)/Me;let Kt=0,Qt=0;for(let en=0;en<Me;en++)Kt+=xt.residuals[en]**2,Qt+=(Mt[en]-Bt)**2;const Yt=Qt===0?0:Math.max(0,Math.min(1,1-Kt/Qt)),Jt=Me*Yt,nn=H(Jt,ze);qt={statistic:Jt,df:ze,p:nn,heteroscedastic:nn<.05}}}let Wt=null;if(ze===1){const Mt=ye.map((xt,Bt)=>Bt).sort((xt,Bt)=>ye[xt][0]-ye[Bt][0]);Wt={confidence:Nt,points:Mt.map(xt=>{const Bt=Se[xt],Kt=Math.sqrt(Math.max(0,ot*h(Bt,at)));return{x:ye[xt][0],yhat:it[xt],lower:it[xt]-Dt*Kt,upper:it[xt]+Dt*Kt}})}}return{method:je,coefficients:_t,r2:St,adjR2:At,n:Me,df:ct,sigma2:ot,fitted:it,residuals:gt,leverage:pn,cooksD:sn,vif:cn,heteroscedasticity:qt,band:Wt,weights:Je?[...Je]:null}}function oe(ye){const ke=ye.length,me=Array.from({length:ke},(ze,_e)=>_e).sort((ze,_e)=>ye[ze]-ye[_e]),je=new Float64Array(ke);let Me=0;for(;Me<ke;){let ze=Me;for(;ze+1<ke&&ye[me[ze+1]]===ye[me[Me]];)ze++;const _e=(Me+ze)/2+1;for(let De=Me;De<=ze;De++)je[me[De]]=_e;Me=ze+1}return je}const fe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function de(ye){const ke=[.01,.05,.1],me=[fe["1%"],fe["5%"],fe["10%"]];if(ye<=me[0]){const ze=(Math.log(ke[1])-Math.log(ke[0]))/(me[1]-me[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ke[0])+ze*(ye-me[0]))))}if(ye>=me[2]){const ze=(Math.log(ke[2])-Math.log(ke[1]))/(me[2]-me[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ke[2])+ze*(ye-me[2]))))}const je=ye<me[1]?0:1,Me=(ye-me[je])/(me[je+1]-me[je]);return Math.exp(Math.log(ke[je])+Me*(Math.log(ke[je+1])-Math.log(ke[je])))}function we(ye,ke,me,je){const Me=me-je,ze=je+3,_e=new Array(Me),De=new Array(Me);let Se=!0,xe=je;for(let it=0;it<Me;it++){const gt=je+it,wt=new Float64Array(ze);wt[0]=1,wt[1]=it+1,wt[2]=ye[gt];for(let dt=1;dt<=je;dt++)wt[2+dt]=ke[gt-dt];for(let dt=1;dt<ze;dt++)Number.isFinite(wt[dt])||(xe=Math.min(xe,dt-3));_e[it]=wt,De[it]=ke[gt],Number.isFinite(De[it])||(Se=!1)}if(!Se)return 0;const{xtwx:Be,xtwy:Je}=u(_e,De,null);let Qe=0,at=1/0;for(let it=0;it<=xe;it++){const gt=it+3;if(!(Me>gt))continue;const wt=new Array(gt);for(let St=0;St<gt;St++)wt[St]=Be[St].slice(0,gt);const dt=w(wt);if(!dt)continue;const jt=j(dt,Je.slice(0,gt));let Ve=0;for(let St=0;St<Me;St++){const At=_e[St];let ft=0;for(let Nt=0;Nt<gt;Nt++)ft+=At[Nt]*jt[Nt];Ve+=(De[St]-ft)**2}const ct=Ve/(Me-gt)*(Me-gt);if(!(ct>0))continue;const ot=Me*Math.log(ct/Me)+2*gt;ot<at&&(at=ot,Qe=it)}return Qe}function Te(ye,ke={}){const me=[];for(let at=0;at<ye.length;at++){const it=Number(ye[at]);Number.isFinite(it)&&me.push(it)}const je=me.length,Me=je-1;if(je<8||Me<6)return null;const ze=new Array(Me);for(let at=0;at<Me;at++)ze[at]=me[at+1]-me[at];let _e=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.ceil(12*(je/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((Me-5)/2)));const De=(at,it)=>{const gt=[],wt=[];for(let dt=it;dt<Me;dt++){const jt=[dt-it+1,me[dt]];for(let Ve=1;Ve<=at;Ve++)jt.push(ze[dt-Ve]);gt.push(jt),wt.push(ze[dt])}return te(gt,wt,{method:"ols"})},Se=we(me,ze,Me,_e),xe=De(Se,Se);if(!xe||!xe.coefficients[2])return null;const Be=xe.coefficients[2].t,Je=de(Be),Qe=Be<fe["5%"];return{statistic:Be,usedLag:Se,nobs:Me-Se,criticalValues:{...fe},pValue:Je,pApproximate:!0,stationary:Qe,verdict:Qe?"stationary":"non-stationary",regression:"ct"}}function Ae(ye,ke={}){const me=[];for(let Qe=0;Qe<ye.length;Qe++){const at=Number(ye[Qe]);Number.isFinite(at)&&me.push(at)}const je=me.length;if(je<3)return null;let Me=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.min(10,je-1);Me=Math.max(1,Math.min(Me,je-1));let ze=0;for(const Qe of me)ze+=Qe;ze/=je;const _e=me.map(Qe=>Qe-ze);let De=0;for(const Qe of _e)De+=Qe*Qe;De/=je;const Se=new Array(Me+1).fill(0);Se[0]=1;for(let Qe=1;Qe<=Me;Qe++){let at=0;for(let it=Qe;it<je;it++)at+=_e[it]*_e[it-Qe];Se[Qe]=De>0?at/je/De:0}const xe=new Array(Me+1).fill(0);xe[0]=1;let Be=[];for(let Qe=1;Qe<=Me;Qe++){let at=Se[Qe];for(let dt=1;dt<Qe;dt++)at-=Be[dt-1]*Se[Qe-dt];let it=1;for(let dt=1;dt<Qe;dt++)it-=Be[dt-1]*Se[dt];const gt=it!==0?at/it:0,wt=new Array(Qe);for(let dt=1;dt<Qe;dt++)wt[dt-1]=Be[dt-1]-gt*Be[Qe-1-dt];wt[Qe-1]=gt,xe[Qe]=gt,Be=wt}const Je=1.96/Math.sqrt(je);return{acf:Se,pacf:xe,bounds:{upper:Je,lower:-Je},n:je,nlags:Me,approximate:!0}}function Ce(ye,ke,me){const{xs:je,ys:Me,n:ze}=v(ye,ke,me);if(ze<2)return null;const _e=oe(je),De=oe(Me);let Se=0,xe=0;for(let at=0;at<ze;at++)Se+=_e[at],xe+=De[at];Se/=ze,xe/=ze;let Be=0,Je=0,Qe=0;for(let at=0;at<ze;at++){const it=_e[at]-Se,gt=De[at]-xe;Be+=it*gt,Je+=it*it,Qe+=gt*gt}return Je===0||Qe===0?null:Math.max(-1,Math.min(1,Be/Math.sqrt(Je*Qe)))}function pe(ye,ke,me){const{xs:je,ys:Me,n:ze}=v(ye,ke,me);if(ze<2||ze>t)return null;let _e=0,De=0,Se=0,xe=0;for(let Qe=0;Qe<ze;Qe++)for(let at=Qe+1;at<ze;at++){const it=Math.sign(je[Qe]-je[at]),gt=Math.sign(Me[Qe]-Me[at]),wt=it*gt;wt>0?_e++:wt<0?De++:it===0&>===0||(it===0?Se++:xe++)}const Be=_e+De+xe,Je=_e+De+Se;return Be===0||Je===0?null:(_e-De)/Math.sqrt(Be*Je)}function be(ye,ke={}){const me=ye.length;if(me<2)return null;const je=ye[0],Me=ye[me-1],ze=[];for(let dt=1;dt<me;dt++){const jt=ye[dt-1];jt!==0&&ze.push((ye[dt]-jt)/Math.abs(jt))}let _e=null;if(ze.length>1){let dt=0;for(const Ve of ze)dt+=Ve;dt/=ze.length;let jt=0;for(const Ve of ze)jt+=(Ve-dt)**2;_e=Math.sqrt(jt/(ze.length-1))}const De=Number(ke.periodsPerYear)>0?Number(ke.periodsPerYear):null;let Se=ye[0],xe=0,Be=0,Je=0,Qe=0;for(let dt=1;dt<me;dt++){if(ye[dt]>Se){Se=ye[dt],xe=dt;continue}if(Se<=0)continue;const jt=(Se-ye[dt])/Se;jt>Be&&(Be=jt,Je=xe,Qe=dt)}let at=null;if(me>2){let dt=0;for(let pt=0;pt<me;pt++)dt+=ye[pt];dt/=me;let jt=0,Ve=0;for(let pt=0;pt<me;pt++){const ct=ye[pt]-dt;Ve+=ct*ct,pt>0&&(jt+=ct*(ye[pt-1]-dt))}at=Ve>0?jt/Ve:null}let it=0,gt=0;for(const dt of ze)dt>0?it++:dt<0&>++;let wt=null;if(je>0&&Me>0){const dt=(Me/je)**(1/(me-1))-1;wt=De?(1+dt)**De-1:dt}return{n:me,first:je,last:Me,change:Me-je,changePercent:je===0?null:(Me-je)/Math.abs(je)*100,volatility:_e,annualisedVolatility:_e!==null&&De?_e*Math.sqrt(De):null,growth:wt,maxDrawdown:Be,maxDrawdownFrom:Je,maxDrawdownTo:Qe,autocorrelation:at,upDays:it,downDays:gt}}const ge=1.128,Ne=3.267;function $e(ye){const ke=ye.length;if(ke<2)return null;const me=[];for(let Me=1;Me<ke;Me++)me.push(Math.abs(ye[Me]-ye[Me-1]));const je=me.reduce((Me,ze)=>Me+ze,0)/me.length;return{ranges:me,centre:je,upper:Ne*je,lower:0}}function He(ye){const ke=ye.length;if(ke<2)return null;let me=0;for(let Me=1;Me<ke;Me++)me+=Math.abs(ye[Me]-ye[Me-1]);const je=me/(ke-1);return{sigma:je/ge,meanRange:je}}function Ye(ye,ke){const me=ye.length;if(me<2||!ke)return null;const je=Number.isFinite(Number(ke.lower))?Number(ke.lower):null,Me=Number.isFinite(Number(ke.upper))?Number(ke.upper):null;if(je===null&&Me===null)return null;let ze=0;for(let it=0;it<me;it++)ze+=ye[it];ze/=me;let _e=0;for(let it=0;it<me;it++)_e+=(ye[it]-ze)**2;const De=Math.sqrt(_e/(me-1)),Se=He(ye),xe=Se?Se.sigma:null,Be=it=>{if(!it||it<=0)return{index:null,k:null};const wt=je!==null&&Me!==null?(Me-je)/(6*it):null,dt=Me!==null?(Me-ze)/(3*it):1/0,jt=je!==null?(ze-je)/(3*it):1/0;return{index:wt,k:Math.min(dt,jt)}},Je=Be(xe),Qe=Be(De);let at=0;for(let it=0;it<me;it++){if(je!==null&&ye[it]<je){at++;continue}Me!==null&&ye[it]>Me&&at++}return{n:me,mean:ze,lower:je,upper:Me,target:Number.isFinite(Number(ke.target))?Number(ke.target):null,sigmaWithin:xe,sigmaOverall:De,cp:Je.index,cpk:Je.k,pp:Qe.index,ppk:Qe.k,outOfSpec:at,defectRate:me?at/me:null}}function Oe(ye){const ke=ye.length;if(ke<2)return null;const me=He(ye);if(!me||!(me.sigma>0))return null;let je=0;for(let Me=0;Me<ke;Me++)je+=ye[Me];return je/=ke,{centre:je,sigma:me.sigma,upper:je+3*me.sigma,lower:je-3*me.sigma}}function Ge(ye,ke){if(!ke||!(ke.sigma>0))return[];const me=ye.length,{centre:je,sigma:Me}=ke,ze=De=>(ye[De]-je)/Me,_e=[];for(let De=0;De<me;De++){if(Math.abs(ze(De))>3&&_e.push({index:De,rule:1,description:"beyond three sigma"}),De>=2)for(const Se of[1,-1]){let xe=0;for(let Be=De-2;Be<=De;Be++)ze(Be)*Se>2&&xe++;if(xe>=2){_e.push({index:De,rule:2,description:"two of three past two sigma"});break}}if(De>=4)for(const Se of[1,-1]){let xe=0;for(let Be=De-4;Be<=De;Be++)ze(Be)*Se>1&&xe++;if(xe>=4){_e.push({index:De,rule:3,description:"four of five past one sigma"});break}}if(De>=7)for(const Se of[1,-1]){let xe=!0;for(let Be=De-7;Be<=De;Be++)if(ze(Be)*Se<=0){xe=!1;break}if(xe){_e.push({index:De,rule:4,description:"eight in a row on one side"});break}}}return _e}function Ze(ye,ke){if(!ke||!(ke.sigma>0))return[];const me=ye.length,{centre:je,sigma:Me}=ke,ze=Se=>(ye[Se]-je)/Me,_e=(Se,xe,Be,Je)=>{for(const Qe of[1,-1]){let at=0;for(let it=Se;it<=xe;it++)ze(it)*Qe>Be&&at++;if(at>=Je)return!0}return!1},De=[];for(let Se=0;Se<me;Se++){if(Math.abs(ze(Se))>3&&De.push({index:Se,rule:1,description:"beyond three sigma"}),Se>=8)for(const xe of[1,-1]){let Be=!0;for(let Je=Se-8;Je<=Se;Je++)if(ze(Je)*xe<=0){Be=!1;break}if(Be){De.push({index:Se,rule:2,description:"nine in a row on one side"});break}}if(Se>=5)for(const xe of[1,-1]){let Be=!0;for(let Je=Se-4;Je<=Se;Je++)if((ye[Je]-ye[Je-1])*xe<=0){Be=!1;break}if(Be){De.push({index:Se,rule:3,description:xe>0?"six rising":"six falling"});break}}if(Se>=13){let xe=!0;for(let Be=Se-12;Be<=Se;Be++){const Je=ye[Be]-ye[Be-1],Qe=ye[Be+1<=Se?Be+1:Be]-ye[Be];if(Be+1>Se)break;if(Je===0||Qe===0||Je>0==Qe>0){xe=!1;break}}xe&&De.push({index:Se,rule:4,description:"fourteen alternating"})}if(Se>=2&&_e(Se-2,Se,2,2)&&De.push({index:Se,rule:5,description:"two of three past two sigma"}),Se>=4&&_e(Se-4,Se,1,4)&&De.push({index:Se,rule:6,description:"four of five past one sigma"}),Se>=14){let xe=!0;for(let Be=Se-14;Be<=Se;Be++)if(Math.abs(ze(Be))>=1){xe=!1;break}xe&&De.push({index:Se,rule:7,description:"fifteen within one sigma"})}if(Se>=7){let xe=!0;for(let Be=Se-7;Be<=Se;Be++)if(Math.abs(ze(Be))<=1){xe=!1;break}xe&&De.push({index:Se,rule:8,description:"eight beyond one sigma"})}}return De}const rt=Object.freeze(["westernElectric","nelson"]);function st(ye,ke,me="westernElectric"){return String(me)==="nelson"?Ze(ye,ke):Ge(ye,ke)}function ht(ye,ke,me){let je=0;for(let Me=0;Me<ye.length;Me++)(ye[Me]<ke||ye[Me]>me)&&je++;return je}function yt(ye,ke,me,je=20){const Me=ye.length;if(!Me)return[];const ze=ye[0],_e=ye[Me-1];if(_e===ze)return[{from:ze,to:_e,count:Me}];const De=me-ke,Se=1.5*De;let xe=De>0?Math.max(ze,ke-Se):ze,Be=De>0?Math.min(_e,me+Se):_e;Be>xe||(xe=ze,Be=_e);const Je=De>0?2*De/Math.cbrt(Me):(Be-xe)/(Math.ceil(Math.log2(Me))+1),Qe=Je>0?Math.min(je,Math.max(1,Math.ceil((Be-xe)/Je))):1,at=(Be-xe)/Qe,it=[];for(let gt=0;gt<Qe;gt++)it.push({from:xe+gt*at,to:xe+(gt+1)*at,count:0});for(let gt=0;gt<Me;gt++){const wt=Math.min(Qe-1,Math.max(0,Math.floor((ye[gt]-xe)/at)));it[wt].count++}return it[0].from=ze,it[Qe-1].to=_e,it}const Ot=.95;function Ct(ye){const ke=Number(ye);return Number.isFinite(ke)&&ke>0&&ke<1?ke:Ot}function Tt(ye,ke=Ot){const me=ye.length;if(me<2)return null;let je=0;for(let Be=0;Be<me;Be++)je+=ye[Be];const Me=je/me;let ze=0;for(let Be=0;Be<me;Be++){const Je=ye[Be]-Me;ze+=Je*Je}const _e=Math.sqrt(ze/(me-1)),De=Ct(ke),xe=_(1-(1-De)/2,me-1)*_e/Math.sqrt(me);return{mean:Me,lower:Me-xe,upper:Me+xe,margin:xe,n:me,confidence:De}}function Et(ye,ke,me=Ot){const je=Number(ye),Me=Number(ke);if(!(Me>0)||!(je>=0)||je>Me)return null;const ze=Ct(me),_e=W(1-(1-ze)/2),De=je/Me,Se=_e*_e,xe=1+Se/Me,Be=(De+Se/(2*Me))/xe,Je=_e/xe*Math.sqrt(De*(1-De)/Me+Se/(4*Me*Me));return{proportion:De,lower:Math.max(0,Be-Je),upper:Math.min(1,Be+Je),n:Me,confidence:ze}}function zt(ye,ke=Ot){if(!ye||!(ye.n>2)||!Number.isFinite(ye.stdError))return null;const me=Ct(ke),Me=_(1-(1-me)/2,ye.n-2)*ye.stdError;return{slope:ye.slope,lower:ye.slope-Me,upper:ye.slope+Me,margin:Me,confidence:me}}function It(ye,ke,me=Ot){const je=Number(ye),Me=Number(ke);if(!Number.isFinite(je)||!(Me>1))return null;const ze=Ct(me),De=W(1-(1-ze)/2)*Math.sqrt(1/(9*Me)+je*je/(2*(Me-1)));return{index:je,lower:je-De,upper:je+De,margin:De,n:Me,confidence:ze}}function ut(ye,ke){return!ye||!(ye.sd>0)||!Number.isFinite(ke)||!Number.isFinite(ye.mean)?null:(ke-ye.mean)/ye.sd}function nt(ye){return Number.isFinite(ye)?Math.min(1,Math.max(0,2*V(Math.abs(ye)/2)-1)):0}function le(ye,ke){const me=new Map,je=B(ye);let Me=0;for(let ze=0;ze<ke.length;ze++){const _e=je(ke[ze]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const De=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;me.set(De,(me.get(De)||0)+1),Me++}return{map:me,total:Me}}function ve(ye,ke,me,je){if(!(ke>0)||!(je>0))return null;let Me=0;const ze=new Set(ye.keys());for(const _e of me.keys())ze.add(_e);for(const _e of ze){const De=(ye.get(_e)||0)/ke,Se=(me.get(_e)||0)/je;Me+=Math.abs(De-Se)}return Me/2}const Re=10;function We(ye,ke,me){if(me&&me.numeric){const De=l(ye,ke),{n:Se,mean:xe}=A(De),Be=Se>0?ut({mean:me.mean,sd:me.sd},xe):null;return{measure:"standardizedMeanDifference",magnitude:Be,distance:Be===null?0:nt(Be),direction:Be===null?0:Math.sign(Be),subsetN:Se,populationN:me.n||0,reliable:Se>=Re}}const{map:Me,total:ze}=le(ye,ke),_e=ve(Me,ze,me.map,me.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:ze,populationN:me.total||0,reliable:ze>=Re}}function Ie(ye,ke){if(ye&&(ye.kind==="float64"||ye.kind==="int32"))return!0;const me=B(ye);let je=0,Me=0;for(let ze=0;ze<ke.length&&je<200;ze++){const _e=me(ke[ze]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;je++;const De=typeof _e=="number"?_e:Number(_e);Number.isFinite(De)&&Me++}return je===0?!1:Me/je>=.9}function qe(ye,ke){if(Ie(ye,ke)){const Me=l(ye,ke),{n:ze,mean:_e,m2:De}=A(Me);return{numeric:!0,mean:_e,sd:ze>0?Math.sqrt(De/ze):0,n:ze}}const{map:me,total:je}=le(ye,ke);return{numeric:!1,map:me,total:je}}}),Le("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/compute/handle.js"),_=I.presenceReader,X=I.valueComparator,W=I.valueReader,V=K("packages/core/src/compute/statistics.js"),H=V.STAT_FNS,z=V.STAT_LABELS;function w(A){return!!A&&(A.kind==="float64"||A.kind==="int32")}function j(A,k){const y=k.length;let S=0;if(w(A)){const O=A.values,F=_(A);if(!F){for(let E=0;E<y;E++){const T=O[k[E]];Number.isNaN(T)||(S+=T)}return S}for(let E=0;E<y;E++){const T=k[E];if(F(T)===1){const L=O[T];Number.isNaN(L)||(S+=L)}}return S}const R=W(A);for(let O=0;O<y;O++){const F=d(R(k[O]));F!==null&&(S+=F)}return S}j.kernel=!0;function g(A,k){const y=k.length;let S=0;if(w(A)){const O=A.values,F=_(A);if(!F){for(let E=0;E<y;E++)Number.isNaN(O[k[E]])||S++;return S}for(let E=0;E<y;E++){const T=k[E];F(T)===1&&!Number.isNaN(O[T])&&S++}return S}const R=W(A);for(let O=0;O<y;O++){const F=R(k[O]);F!=null&&!(typeof F=="number"&&Number.isNaN(F))&&S++}return S}g.kernel=!0;function u(A,k){return k.length}u.kernel=!0;function h(A,k){const y=g(A,k);return y===0?null:j(A,k)/y}h.kernel=!0;function a(A,k,y,S){const R=k.length;if(w(A)){const T=A.values,L=_(A);let C=null;if(!L){for(let D=0;D<R;D++){const $=T[k[D]];Number.isNaN($)||(C===null||(y<0?$<C:$>C))&&(C=$)}return C}for(let D=0;D<R;D++){const $=k[D];if(L($)===0)continue;const P=T[$];Number.isNaN(P)||(C===null||(y<0?P<C:P>C))&&(C=P)}return C}const O=W(A),F=X(S);let E=null;for(let T=0;T<R;T++){const L=O(k[T]);L==null||typeof L=="number"&&Number.isNaN(L)||(E===null||(y<0?F(L,E)<0:F(L,E)>0))&&(E=L)}return E}function r(A,k,y){return a(A,k,-1,y&&y.locale)}r.kernel=!0;function t(A,k,y){return a(A,k,1,y&&y.locale)}t.kernel=!0;function n(A,k){return k.length===0?null:W(A)(k[0])}n.kernel=!0;function o(A,k){return k.length===0?null:W(A)(k[k.length-1])}o.kernel=!0;function d(A){if(typeof A=="number")return Number.isNaN(A)?null:A;if(A==null||A===""||typeof A=="boolean")return null;if(A instanceof Date)return A.getTime();const k=Number(A);return Number.isNaN(k)?null:k}const l={sum:j,min:r,max:t,avg:h,count:u,first:n,last:o,countValues:g,...H},i=Object.freeze({...z,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function m(A){return A?typeof A=="string"?i[A]||A:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function f(A){const k=A&&A.dataType&&A.dataType.totals&&A.dataType.totals.supported;if(Array.isArray(k))return k.slice();const y=c.filter(S=>S in l);for(const S of Object.keys(l))y.includes(S)||y.push(S);return y}function s(A,k){return typeof k!="string"?!0:f(A).includes(k)}function p(A,k){const y=W(A),S=[];for(let R=0;R<k.length;R++){const O=y(k[R]);O!=null&&S.push(O)}return S}function b(A,k,y,S){const R=k||[];if(typeof y=="string"){const O=l[y];return O?O(A,R,S):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return x(y)?y.kernel===!0?y(A,R,S):y(p(A,R),S||{}):null}}),Le("packages/core/src/compute/windowed.js",function(e,K){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(V,H=0,z=Date.now){if(V!=="count"&&V!=="time"&&V!=="session")throw new RangeError(`unknown window kind: ${V}`);if((V==="count"||V==="time")&&!(H>0))throw new RangeError(`a ${V} window needs a positive span`);this.#e=V,this.#t=Math.floor(H),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(V,H=this.#r()){Number.isFinite(V)&&(this.#n.push({t:H,v:V}),this.#i(H))}#i(V){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const H=V-this.#t;for(;this.#n.length&&this.#n[0].t<H;)this.#n.shift()}}spec(){const V=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:V,size:this.#n.length}}values(){return this.#n.map(V=>V.v)}aggregate(){const V=this.spec();if(!this.#n.length)return{over:V,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const H=new x;let z=0,w=1/0,j=-1/0;for(const{v:g}of this.#n)z+=g,g<w&&(w=g),g>j&&(j=g),H.add(g);return{over:V,count:this.#n.length,sum:z,mean:H.mean(),min:w,max:j,variance:H.variance(),stddev:H.stddev()}}reduce(V){const H=this.aggregate(),z={sum:H.sum,avg:H.mean,mean:H.mean,min:H.min,max:H.max,count:H.count,variance:H.variance,stddev:H.stddev};if(!(V in z))throw new RangeError(`unknown windowed aggregate: ${V}`);return{value:z[V],over:H.over}}}const I=Object.freeze(["count","time","session"]);function _(W,V=Date.now){const H=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new B(W.kind,H,V)}const X={Window:B,WINDOW_KINDS:I,openWindow:_}}),Le("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const x=K("packages/core/src/compute/windowed.js").openWindow,I=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(i,m,c,f){if(i.kind==="count"){const s=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,m/s),partial:m<s}}if(i.kind==="time"){const s=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(s>0))return{coverage:1,partial:!1};const p=c-f;return{coverage:Math.min(1,p/s),partial:p<s}}return{coverage:null,partial:!1}}function W(i,m){const c=x(m),f=new Map,s=i.length?i[0].at:0;for(let p=0;p<i.length;p++){const{key:b,at:A,value:k}=i[p];Number.isFinite(k)&&c.push(k,A);const y=c.aggregate(),S=X(m,y.count,A,s);b!=null&&f.set(String(b),{sum:y.sum,avg:y.mean,min:y.min,max:y.max,count:y.count,coverage:S.coverage,partial:S.partial})}return f}function V(i){const m=new Map;let c=0;for(const{key:f,value:s}of i)Number.isFinite(s)&&(c+=s),f!=null&&m.set(String(f),c);return m}function H(i,m=1){const c=new Map,f=Math.max(1,Math.floor(m));for(let s=0;s<i.length;s++){const{key:p,value:b}=i[s];if(p==null)continue;const A=s>=f?i[s-f].value:null,k=Number.isFinite(b)?b:null,y=Number.isFinite(A)?A:null;c.set(String(p),k!==null&&y!==null?k-y:null)}return c}const z=4096;function w(i){let m=i>>>0;return()=>{m+=1831565813;let c=m;return c=Math.imul(c^c>>>15,c|1),c^=c+Math.imul(c^c>>>7,c|61),((c^c>>>14)>>>0)/4294967296}}function j(i,m){const c=i.length;if(c===1)return i[0];const f=(c-1)*m,s=Math.floor(f),p=Math.ceil(f);return s===p?i[s]:i[s]+(f-s)*(i[p]-i[s])}function g(i,m,c={}){const f=Math.min(1,Math.max(0,c.q==null?.5:c.q)),s=Math.max(1,Math.floor(c.cap==null?z:c.cap)),p=w(c.seed==null?2654435769:c.seed),b=new Map,A=i.length?i[0].at:0;if(m.kind==="session"){const y=new I(200,p);let S=0;for(const{key:R,value:O}of i)Number.isFinite(O)&&(y.add(O),S++),R!=null&&b.set(String(R),{value:S?y.quantile(f):null,approx:S>0,count:S,coverage:null,partial:!1});return b}const k=x(m);for(const{key:y,at:S,value:R}of i){Number.isFinite(R)&&k.push(R,S);const O=k.values(),F=O.length;let E=null,T=!1;if(F)if(F<=s)E=j([...O].sort((C,D)=>C-D),f);else{const C=new I(200,p);for(const D of O)C.add(D);E=C.quantile(f),T=!0}const L=X(m,F,S,A);y!=null&&b.set(String(y),{value:E,approx:T,count:F,coverage:L.coverage,partial:L.partial})}return b}function u(i,m){const c=i.length,f=new Array(c).fill(null),s=Math.floor(m/2),p=m%2===0;for(let b=0;b<c;b++){if(b-s<0||b+s>=c)continue;let A=0,k=!0;if(p)for(let y=-s;y<=s;y++){const S=i[b+y];if(!Number.isFinite(S)){k=!1;break}A+=y===-s||y===s?S*.5:S}else for(let y=-s;y<=s;y++){const S=i[b+y];if(!Number.isFinite(S)){k=!1;break}A+=S}k&&(f[b]=A/m)}return f}function h(i,m){const c=new Map,f=Math.floor(Number(m&&m.period));if(!(f>=2))return c;const s=m&&m.model==="multiplicative",p=i.length,b=i.map(T=>Number.isFinite(T.value)?T.value:null),A=u(b,f),k=new Array(p).fill(null);for(let T=0;T<p;T++){const L=A[T],C=b[T];L===null||C===null||(s?L!==0&&(k[T]=C/L):k[T]=C-L)}const y=new Array(f).fill(0),S=new Array(f).fill(0);for(let T=0;T<p;T++){if(k[T]===null)continue;const L=T%f;y[L]+=k[T],S[L]+=1}const R=s?1:0,O=y.map((T,L)=>S[L]?T/S[L]:R),F=O.reduce((T,L)=>T+L,0)/f,E=s?O.map(T=>F!==0?T/F:1):O.map(T=>T-F);for(let T=0;T<p;T++){const{key:L}=i[T];if(L==null)continue;const C=A[T],D=E[T%f],$=b[T];let P=null;C!==null&&$!==null&&(P=s?C*D!==0?$/(C*D):null:$-C-D),c.set(String(L),{trend:C,seasonal:$===null?null:D,residual:P,coverage:C===null?0:1,partial:C===null})}return c}function a(i,m,c,f=80){const s=(Math.sqrt(5)-1)/2;let p=m,b=c,A=b-s*(b-p),k=p+s*(b-p),y=i(A),S=i(k);for(let R=0;R<f;R++)y<S?(b=k,k=A,S=y,A=b-s*(b-p),y=i(A)):(p=A,A=k,y=S,k=p+s*(b-p),S=i(k));return(p+b)/2}const r=1e-4,t=1-1e-4;function n(i,m){const c=i.length,f=new Array(c).fill(null),s=new Array(c).fill(null);let p=null,b=0;for(let A=0;A<c;A++){const k=i[A];if(!Number.isFinite(k)){p!==null&&(s[A]=p,f[A]=p);continue}if(p===null){p=k,s[A]=k,f[A]=k;continue}s[A]=p,b+=(k-p)**2,p=m*k+(1-m)*p,f[A]=p}return{smoothed:f,fitted:s,sse:b}}function o(i,m,c){const f=i.length,s=new Array(f).fill(null),p=new Array(f).fill(null);let b=null,A=null,k=0;for(let y=0;y<f;y++){const S=i[y];if(!Number.isFinite(S)){b!==null&&(b+=A,s[y]=b);continue}if(b===null){b=S,s[y]=S;continue}if(A===null){A=S-b;const F=b+A;p[y]=F,k+=(S-F)**2;const E=b;b=m*S+(1-m)*(E+A),A=c*(b-E)+(1-c)*A,s[y]=b;continue}const R=b+A;p[y]=R,k+=(S-R)**2;const O=b;b=m*S+(1-m)*(O+A),A=c*(b-O)+(1-c)*A,s[y]=b}return{smoothed:s,fitted:p,sse:k}}function d(i,m={}){const c=new Map,f=m.method==="holt",s=i.map(R=>Number.isFinite(R.value)?R.value:null),p=s.filter(R=>R!==null).length,b=R=>Math.min(t,Math.max(r,R)),A=()=>{for(const{key:R}of i)R!=null&&c.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(p<(f?2:1))return A();let k=Number.isFinite(m.alpha)?b(m.alpha):null,y=f&&Number.isFinite(m.beta)?b(m.beta):null;if(f){if(k===null||y===null){let R=k===null?.5:k,O=y===null?.5:y;for(let F=0;F<6;F++)k===null&&(R=a(E=>o(s,E,O).sse,r,t)),y===null&&(O=a(E=>o(s,R,E).sse,r,t));k=k===null?R:k,y=y===null?O:y}}else k===null&&(k=a(R=>n(s,R).sse,r,t));const S=f?o(s,k,y):n(s,k);for(let R=0;R<i.length;R++){const{key:O}=i[R];O!=null&&c.set(String(O),{smoothed:S.smoothed[R],fitted:S.fitted[R],alpha:k,beta:f?y:null,sse:S.sse})}return c}const l={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:W,rollingQuantile:g,cumulativeToDate:V,periodOverPeriod:H,seasonalDecompose:h,exponentialSmoothing:d}}),Le("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/compute/statistics.js"),x=Q.numbers,B=Q.moments,I=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,V=Q.SUBSET_RELIABILITY_FLOOR,H=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(h,a){if(!h||!a||!(h.n>0)||!(a.n>0)||!Number.isFinite(h.mean)||!Number.isFinite(a.mean))return null;const r=(h.n*h.sd*h.sd+a.n*a.sd*a.sd)/(h.n+a.n);return r>0?(h.mean-a.mean)/Math.sqrt(r):null}function w(h,a){const r=x(h,a),{n:t,mean:n,m2:o}=B(r),d=t>0?Math.sqrt(o/t):0;return{mean:n,sd:d,n:t}}function j(h,a,r,t){return W(h,a)&&W(r,t)}function g(h,a,r,t){if(j(h,a,r,t)){const l=w(h,a),i=w(r,t),m=z(l,i);return{measure:H.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:l.n,nB:i.n,reliable:l.n>=V&&i.n>=V}}const n=I(h,a),o=I(r,t),d=_(n.map,n.total,o.map,o.total);return{measure:H.categorical,magnitude:d,distance:d===null?0:d,direction:0,nA:n.total,nB:o.total,reliable:n.total>=V&&o.total>=V}}function u(h,a,r={}){const t=new Set(h.columns),n=new Set(a.columns),o=h.columns.filter(c=>n.has(c)),d=Array.isArray(r.columns)&&r.columns.length?o.filter(c=>r.columns.includes(c)):o,l=h.indices(),i=a.indices(),m=[];for(const c of d){const f=h.handle(c),s=a.handle(c);if(!f||!s)continue;const p=g(f,l,s,i);m.push({column:c,name:h.name&&h.name(c)||a.name&&a.name(c)||c,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return m.sort((c,f)=>f.distance-c.distance||Math.abs(f.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:m,nA:l.length,nB:i.length,unmatched:{onlyA:h.columns.filter(c=>!n.has(c)),onlyB:a.columns.filter(c=>!t.has(c))},measures:H}}}),Le("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l}});const x=K("packages/core/src/compute/statistics.js").quantileSorted,I=K("packages/core/src/compute/special.js").logGamma,_=.6745,X=3.5,W=1.5,V=.975,H=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(i){if(!i.length)return null;const c=Array.from(i,Number).sort((b,A)=>b-A),f=x(c,.5),s=c.map(b=>Math.abs(b-f)).sort((b,A)=>b-A),p=x(s,.5);return{median:f,mad:p}}function w(i,m={}){const c=Number.isFinite(m.threshold)?m.threshold:X,f=i.length,s=new Array(f).fill(null),p=new Array(f).fill(!1),b=[];for(let y=0;y<f;y++){const S=Number(i[y]);Number.isFinite(S)&&b.push(S)}if(!b.length)return{median:null,mad:null,threshold:c,scores:s,flags:p,flagged:0};const A=z(b);if(A.mad===0)return{median:A.median,mad:0,threshold:c,scores:s,flags:p,flagged:0};let k=0;for(let y=0;y<f;y++){const S=Number(i[y]);if(!Number.isFinite(S))continue;const R=_*(S-A.median)/A.mad;s[y]=R,Math.abs(R)>c&&(p[y]=!0,k++)}return{median:A.median,mad:A.mad,threshold:c,scores:s,flags:p,flagged:k}}function j(i,m={}){const c=Number.isFinite(m.k)?m.k:W,f=[];for(let k=0;k<i.length;k++){const y=Number(i[k]);Number.isFinite(y)&&f.push(y)}if(!f.length)return null;const s=f.sort((k,y)=>k-y),p=x(s,.25),b=x(s,.75),A=b-p;return{q1:p,q3:b,iqr:A,lower:p-c*A,upper:b+c*A,k:c}}function g(i,m){if(m<=0)return 0;const c=I(i);if(m<i+1){let y=i,S=1/i,R=S;for(let O=0;O<1e3&&(y+=1,R*=m/y,S+=R,!(Math.abs(R)<Math.abs(S)*1e-15));O++);return S*Math.exp(-m+i*Math.log(m)-c)}const f=1e-300;let s=m+1-i,p=1/f,b=1/s,A=b;for(let y=1;y<1e3;y++){const S=-y*(y-i);s+=2,b=S*b+s,Math.abs(b)<f&&(b=f),p=s+S/p,Math.abs(p)<f&&(p=f),b=1/b;const R=b*p;if(A*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+i*Math.log(m)-c)*A}function u(i,m){return i<=0?0:g(m/2,i/2)}function h(i,m=V){if(!(m>0)||!(m<1))return NaN;let c=0,f=Math.max(1,i);for(;u(f,i)<m;)f*=2;for(let s=0;s<200;s++){const p=(c+f)/2;if(u(p,i)<m?c=p:f=p,f-c<1e-10)break}return(c+f)/2}function a(i){const m=i.length,c=i.map((f,s)=>{const p=f.slice();for(let b=0;b<m;b++)p.push(s===b?1:0);return p});for(let f=0;f<m;f++){let s=f;for(let b=f+1;b<m;b++)Math.abs(c[b][f])>Math.abs(c[s][f])&&(s=b);if(Math.abs(c[s][f])<1e-12)return null;if(s!==f){const b=c[s];c[s]=c[f],c[f]=b}const p=c[f][f];for(let b=0;b<2*m;b++)c[f][b]/=p;for(let b=0;b<m;b++){if(b===f)continue;const A=c[b][f];if(A!==0)for(let k=0;k<2*m;k++)c[b][k]-=A*c[f][k]}}return c.map(f=>f.slice(m))}function r(i,m){const c=i.length,f=new Array(m).fill(0);for(const b of i)for(let A=0;A<m;A++)f[A]+=b[A];for(let b=0;b<m;b++)f[b]/=c;const s=Array.from({length:m},()=>new Array(m).fill(0));for(const b of i)for(let A=0;A<m;A++){const k=b[A]-f[A];for(let y=A;y<m;y++)s[A][y]+=k*(b[y]-f[y])}const p=c>1?c-1:1;for(let b=0;b<m;b++)for(let A=b;A<m;A++)s[b][A]/=p,s[A][b]=s[b][A];return{mean:f,cov:s}}function t(i,m={}){const c=Number.isFinite(m.p)?m.p:V,f=Number.isFinite(m.ridge)?m.ridge:1e-6,s=i.length;if(!s)return null;const p=i[0].length;if(!p)return null;const b=new Array(s).fill(null),A=new Array(s).fill(null),k=new Array(s).fill(!1),y=[],S=[];for(let D=0;D<s;D++){const $=i[D];let P=$.length===p;const v=new Array(p);for(let N=0;P&&N<p;N++){const G=Number($[N]);Number.isFinite(G)?v[N]=G:P=!1}P&&(y.push(D),S.push(v))}const R=p,O=h(R,c);if(S.length<=p)return{center:[],df:R,cutoff:O,singular:!0,used:S.length,distances:b,squared:A,flags:k,flagged:0};const{mean:F,cov:E}=r(S,p);let T=a(E),L=!1;if(!T){L=!0;let D=0;for(let v=0;v<p;v++)D+=E[v][v];const $=D/p*f||f,P=E.map((v,N)=>v.map((G,q)=>N===q?G+$:G));if(T=a(P),!T)return{center:F,df:R,cutoff:O,singular:!0,used:S.length,distances:b,squared:A,flags:k,flagged:0}}let C=0;for(let D=0;D<S.length;D++){const $=S[D],P=new Array(p);for(let G=0;G<p;G++)P[G]=$[G]-F[G];let v=0;for(let G=0;G<p;G++){let q=0;for(let Z=0;Z<p;Z++)q+=T[G][Z]*P[Z];v+=P[G]*q}v<0&&(v=0);const N=y[D];A[N]=v,b[N]=Math.sqrt(v),v>O&&(k[N]=!0,C++)}return{center:F,df:R,cutoff:O,singular:L,used:S.length,distances:b,squared:A,flags:k,flagged:C}}const n=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function d(i,m={}){const c=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",f=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):n,s=Number.isFinite(m.threshold)?m.threshold:X,p=Number.isFinite(m.k)?m.k:W,b=Number.isFinite(m.minPeriods)&&m.minPeriods>=1?Math.floor(m.minPeriods):f,A=i.length,k=new Array(A).fill(null),y=new Array(A).fill(!1);let S=0;for(let R=0;R<A;R++){const O=Number(i[R]);if(!Number.isFinite(O))continue;const F=Math.max(0,R-f+1),E=[];for(let T=F;T<=R;T++){const L=Number(i[T]);Number.isFinite(L)&&E.push(L)}if(!(E.length<b))if(c==="rollingIqr"){const T=j(E,{k:p});if(!T)continue;(O<T.lower||O>T.upper)&&(y[R]=!0,S++)}else{const T=z(E);if(!T||T.mad===0)continue;const L=_*(O-T.median)/T.mad;k[R]=L,Math.abs(L)>s&&(y[R]=!0,S++)}}return{method:c,windowLen:f,minPeriods:b,threshold:s,k:p,scores:k,flags:y,flagged:S}}function l(i={}){const m=i||{},c=m.field;if(typeof c!="string"||!c)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const f=m.method||"modifiedZScore";if(!(H.includes(f)||o.includes(f))||f==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${f}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,b=m.latest===!0,A=o.includes(f),k=y=>Number(y==null?NaN:y[c]);return y=>{const S=Array.isArray(y)?y.slice():[...y];p&&S.sort((T,L)=>{const C=T?.[p],D=L?.[p];return C===D?0:C==null?-1:D==null?1:C<D?-1:1});const R=S.map(k);let O,F;if(A)({flags:O,scores:F}=d(R,{method:f,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(f==="iqr"){const T=j(R,{k:m.k});O=R.map(L=>T?Number.isFinite(L)&&(L<T.lower||L>T.upper):!1),F=R.map(()=>null)}else({flags:O,scores:F}=w(R,{threshold:m.threshold}));if(b){const T=O.length-1;return T<0||!O[T]?!1:{method:f,field:c,flagged:[{row:S[T],score:F[T]}]}}const E=[];for(let T=0;T<O.length;T++)O[T]&&E.push({row:S[T],score:F[T]});return E.length?{method:f,field:c,flagged:E}:!1}}}),Le("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/compute/special.js"),x=Q.normalQuantile,B=Q.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),W=1e-4,V=1-1e-4;function H(m){const c=[];for(let f=0;f<m.length;f++){const s=m[f];if(s!==null&&typeof s=="object"){const p=Number.isFinite(s.at)?s.at:f,b=Number.isFinite(s.value)?s.value:null;c.push({at:p,value:b})}else c.push({at:f,value:Number.isFinite(s)?Number(s):null})}return c}function z(m){const c=m.filter(A=>A.value!==null),f=c[0],s=c[c.length-1],p=s.at-f.at,b=c.length>1&&p>0?p/(c.length-1):1;return{lastAt:s.at,step:b}}function w(m){return Math.min(V,Math.max(W,m))}function j(m,c=W,f=V,s=80){const p=(Math.sqrt(5)-1)/2;let b=c,A=f,k=A-p*(A-b),y=b+p*(A-b),S=m(k),R=m(y);for(let O=0;O<s;O++)S<R?(A=y,y=k,R=S,k=A-p*(A-b),S=m(k)):(b=k,k=y,S=R,y=b+p*(A-b),R=m(y));return(b+A)/2}function g(m,c){let f=null,s=0,p=0;for(let b=0;b<m.length;b++){const A=m[b];if(A!==null){if(f===null){f=A;continue}s+=(A-f)**2,p+=1,f=c*A+(1-c)*f}}return{level:f,sse:s,m:p}}function u(m,c,f){let s=null,p=null,b=0,A=0;for(let k=0;k<m.length;k++){const y=m[k];if(y===null){s!==null&&p!==null&&(s+=p);continue}if(s===null){s=y;continue}p===null&&(p=y-s);const S=s+p;b+=(y-S)**2,A+=1;const R=s;s=c*y+(1-c)*(R+p),p=f*(s-R)+(1-f)*p}return{level:s,trend:p,sse:b,m:A}}function h(m,c,f,s,p){const b=m.length;if(b<2*c)return null;const A=L=>{let C=0,D=0;for(let $=L;$<L+c&&$<b;$++)m[$]!==null&&(C+=m[$],D+=1);return D?C/D:null},k=A(0),y=A(c);if(k===null||y===null)return null;let S=k,R=(y-k)/c;const O=new Array(c).fill(0);for(let L=0;L<c;L++)O[L]=m[L]===null?0:m[L]-S;const F=O.reduce((L,C)=>L+C,0)/c;for(let L=0;L<c;L++)O[L]-=F;let E=0,T=0;for(let L=c;L<b;L++){const C=L%c,D=O[C],$=m[L];if($===null){S+=R;continue}const P=S+R+D;E+=($-P)**2,T+=1;const v=S;S=f*($-D)+(1-f)*(S+R),R=s*(S-v)+(1-s)*R,O[C]=p*($-S)+(1-p)*D}return{level:S,trend:R,season:O,phase:(b-1)%c,sse:E,count:T}}function a(m,c,f){let s=1;for(const b of c)s+=b*b;const p=Math.sqrt(m*s);return{se:p,margin:f*p}}function r(m,c={}){if(!m||typeof m.length!="number"||m.length===0)return null;const f=X.includes(c.method)?c.method:"linear",s=Math.max(1,Math.floor(Number(c.horizon)||1)),p=Number.isFinite(c.confidence)&&c.confidence>0&&c.confidence<1?c.confidence:.95,b=1-(1-p)/2,A=H(m),k=A.map(E=>E.value),y=k.filter(E=>E!==null),S=y.length,{lastAt:R,step:O}=S?z(A):{lastAt:0,step:1},F=E=>R+E*O;return f==="linear"?t(A,S,s,p,b,F):f==="movingAverage"?n(y,S,s,p,b,c,F):f==="ses"?o(k,S,s,p,b,c,F):f==="holt"?d(k,S,s,p,b,c,F):l(k,S,s,p,b,c,F)}function t(m,c,f,s,p,b){if(c<2)return null;let A=0,k=0;for(const $ of m)$.value!==null&&(A+=$.at,k+=$.value);A/=c,k/=c;let y=0,S=0,R=0;for(const $ of m){if($.value===null)continue;const P=$.at-A,v=$.value-k;y+=P*P,S+=P*v,R+=v*v}if(y===0)return null;const O=S/y,F=k-O*A,E=R===0?1:Math.max(0,Math.min(1,S*S/(y*R))),T=Math.max(0,R-O*S),L=c>2?Math.sqrt(T/(c-2)):null,C=c>2?B(p,c-2):null,D=[];for(let $=1;$<=f;$++){const P=b($),v=F+O*P;let N=null,G=null,q=null,Z=null,J=null;if(L!==null){const ee=1/c+(P-A)**2/y,ne=L*Math.sqrt(1+ee),ie=L*Math.sqrt(ee);J=ne,N=v-C*ne,G=v+C*ne,q=v-C*ie,Z=v+C*ie}D.push({step:$,at:P,mean:v,lower:N,upper:G,lowerMean:q,upperMean:Z,se:J})}return{method:"linear",horizon:f,confidence:s,n:c,sigma:L,r2:E,params:{slope:O,intercept:F},points:D}}function n(m,c,f,s,p,b,A){if(c<1)return null;const k=Math.max(1,Math.min(c,Math.floor(Number(b.windowLen)||c))),y=m.slice(c-k);let S=0;for(const L of y)S+=L;const R=S/k;let O=null,F=null;if(k>1){let L=0;for(const D of y)L+=(D-R)**2;O=Math.sqrt(L/(k-1))*Math.sqrt(1+1/k),F=B(p,k-1)}const E=O===null?null:F*O,T=[];for(let L=1;L<=f;L++)T.push({step:L,at:A(L),mean:R,lower:E===null?null:R-E,upper:E===null?null:R+E,se:O});return{method:"movingAverage",horizon:f,confidence:s,n:c,sigma:O===null?null:O,params:{windowLen:k},points:T}}function o(m,c,f,s,p,b,A){if(c<1)return null;let k=Number.isFinite(b.alpha)?w(b.alpha):null;k===null&&(k=j(F=>g(m,F).sse));const y=g(m,k),S=x(p),R=y.m>0?y.sse/y.m:null,O=[];for(let F=1;F<=f;F++){const E=y.level;let T=null,L=null,C=null;if(R!==null){const D=[];for(let P=1;P<F;P++)D.push(k);const $=a(R,D,S);C=$.se,T=E-$.margin,L=E+$.margin}O.push({step:F,at:A(F),mean:E,lower:T,upper:L,se:C})}return{method:"ses",horizon:f,confidence:s,n:c,sigma:R===null?null:Math.sqrt(R),params:{alpha:k},points:O}}function d(m,c,f,s,p,b,A){if(c<2)return null;let k=Number.isFinite(b.alpha)?w(b.alpha):null,y=Number.isFinite(b.beta)?w(b.beta):null;if(k===null||y===null){let T=k===null?.5:k,L=y===null?.5:y;for(let C=0;C<6;C++)k===null&&(T=j(D=>u(m,D,L).sse)),y===null&&(L=j(D=>u(m,T,D).sse));k=k===null?T:k,y=y===null?L:y}const S=u(m,k,y),R=x(p),O=S.m>0?S.sse/S.m:null,F=k*y,E=[];for(let T=1;T<=f;T++){const L=S.level+T*S.trend;let C=null,D=null,$=null;if(O!==null){const P=[];for(let N=1;N<T;N++)P.push(k+N*F);const v=a(O,P,R);$=v.se,C=L-v.margin,D=L+v.margin}E.push({step:T,at:A(T),mean:L,lower:C,upper:D,se:$})}return{method:"holt",horizon:f,confidence:s,n:c,sigma:O===null?null:Math.sqrt(O),params:{alpha:k,beta:y},points:E}}function l(m,c,f,s,p,b,A){const k=Math.floor(Number(b.period));if(!(k>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(c<2*k)return null;let y=Number.isFinite(b.alpha)?w(b.alpha):null,S=Number.isFinite(b.beta)?w(b.beta):null,R=Number.isFinite(b.gamma)?w(b.gamma):null;const O=($,P,v)=>{const N=h(m,k,$,P,v);return N?N.sse:1/0};if(y===null||S===null||R===null){let $=y===null?.5:y,P=S===null?.5:S,v=R===null?.5:R;for(let N=0;N<8;N++)y===null&&($=j(G=>O(G,P,v))),S===null&&(P=j(G=>O($,G,v))),R===null&&(v=j(G=>O($,P,G)));y=y===null?$:y,S=S===null?P:S,R=R===null?v:R}const F=h(m,k,y,S,R);if(!F)return null;const E=x(p),T=F.count>0?F.sse/F.count:null,L=y*S,C=R*(1-y),D=[];for(let $=1;$<=f;$++){const P=F.season[(F.phase+$)%k],v=F.level+$*F.trend+P;let N=null,G=null,q=null;if(T!==null){const Z=[];for(let ee=1;ee<$;ee++)Z.push(y+ee*L+(ee%k===0?C:0));const J=a(T,Z,E);q=J.se,N=v-J.margin,G=v+J.margin}D.push({step:$,at:A($),mean:v,lower:N,upper:G,se:q})}return{method:"holtWinters",horizon:f,confidence:s,n:c,sigma:T===null?null:Math.sqrt(T),params:{alpha:y,beta:S,gamma:R,period:k},points:D}}const i={FORECAST_METHODS:X,forecast:r}}),Le("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return E}});const x=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),X=_.numbers,W=_.moments,V=_.frequencyMap,H=_.categoricalDistance,z=_.isNumericColumn,w=_.jarqueBera,j=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,h=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=K("packages/core/src/compute/special.js"),r=a.studentT,t=a.studentTQuantile,n=a.normalCdf,o=a.normalQuantile,d=a.chiSquareUpperTail,l=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,m=2e6;function c(T){const L=Number(T);return Number.isFinite(L)&&L>0&&L<1?L:.95}function f(T){const{n:L,mean:C,m2:D}=W(T);return{mean:C,sd:L>0?Math.sqrt(D/L):0,n:L}}function s(T,L){const C=T.length;if(C<2)return 0;let D=0;for(let $=0;$<C;$++){const P=T[$]-L;D+=P*P}return D/(C-1)}function p(T,L){return{name:"pooledStandardMeanDifference",value:h(f(T),f(L))}}function b(T,L,C){const D=T.length,$=L.length;if(D<2||$<2)return null;const P=c(C),{mean:v}=W(T),{mean:N}=W(L),G=s(T,v),q=s(L,N),Z=G/D+q/$;if(!(Z>0))return null;const J=Math.sqrt(Z),ee=(v-N)/J,ne=G/D*(G/D)/(D-1),ie=q/$*(q/$)/($-1),se=Z*Z/(ne+ie),he=Math.min(1,Math.max(0,2*(1-r(Math.abs(ee),se)))),ce=v-N,te=t(1-(1-P)/2,se)*J;return{test:l.WELCH,statistic:ee,statisticName:"t",df:se,pValue:he,interval:{estimate:ce,lower:ce-te,upper:ce+te,confidence:P,method:"welch-t (difference of means)"},effectSize:p(T,L),nA:D,nB:$,reliable:D>=g&&$>=g,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function A(T){const L=T.length;if(L===0)return Number.NaN;const C=L>>1;return L%2?T[C]:(T[C-1]+T[C])/2}function k(T,L,C){const D=T.length,$=L.length,P=D*$;if(P===0||P>m)return null;const v=new Float64Array(P);let N=0;for(let ne=0;ne<D;ne++)for(let ie=0;ie<$;ie++)v[N++]=T[ne]-L[ie];v.sort();const G=A(v),q=Math.sqrt(D*$*(D+$+1)/12),Z=o(1-(1-C)/2);let J=Math.round(P/2-Z*q);J>=0||(J=0);const ee=Math.floor((P-1)/2);return J>ee&&(J=ee),{estimate:G,lower:v[J],upper:v[P-1-J],confidence:C,method:"hodges-lehmann (normal approximation)"}}function y(T,L,C){const D=T.length,$=L.length;if(D<1||$<1)return null;const P=c(C),v=D+$,N=new Array(v);for(let he=0;he<D;he++)N[he]={v:T[he],g:0};for(let he=0;he<$;he++)N[D+he]={v:L[he],g:1};N.sort((he,ce)=>he.v-ce.v);let G=0,q=0,Z=0;for(;Z<v;){let he=Z;for(;he<v&&N[he].v===N[Z].v;)he++;const ce=he-Z,te=(Z+1+he)/2;for(let oe=Z;oe<he;oe++)N[oe].g===0&&(G+=te);q+=ce*ce*ce-ce,Z=he}const J=G-D*(D+1)/2,ee=D*$/2,ne=D*$/12*(v+1-q/(v*(v-1)));let ie=1;if(ne>0){const he=Math.max(0,Math.abs(J-ee)-.5);ie=Math.min(1,2*n(-he/Math.sqrt(ne)))}const se=k(T,L,P);return{test:l.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ie,interval:se,effectSize:p(T,L),nA:D,nB:$,reliable:D>=g&&$>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function S(T,L,C,D,$){const P=j(T,L,$),v=j(C,D,$);if(!P||!v)return null;const N=P.proportion-v.proportion,G=N-Math.sqrt((P.proportion-P.lower)**2+(v.upper-v.proportion)**2),q=N+Math.sqrt((P.upper-P.proportion)**2+(v.proportion-v.lower)**2);return{lower:G,upper:q}}function R(T,L,C,D,$,P={}){if(!(L>0)||!(D>0))return null;const v=new Set([...T.keys(),...C.keys()]),N=v.size;if(N<2)return null;const G=L+D;let q=0;for(const ie of v){const se=T.get(ie)||0,he=C.get(ie)||0,ce=se+he,te=L*ce/G,oe=D*ce/G;te>0&&(q+=(se-te)*(se-te)/te),oe>0&&(q+=(he-oe)*(he-oe)/oe)}const Z=N-1,J=d(q,Z);let ee=null;P.category!==void 0&&v.has(P.category)?ee=P.category:N===2&&([ee]=[...v]);let ne=null;if(ee!==null){const ie=S(T.get(ee)||0,L,C.get(ee)||0,D,c($));ie&&(ne={estimate:(T.get(ee)||0)/L-(C.get(ee)||0)/D,lower:ie.lower,upper:ie.upper,confidence:c($),method:"newcombe (difference in this category's share)",category:ee})}return{test:l.CHI_SQUARE,statistic:q,statisticName:"chiSquare",df:Z,pValue:J,interval:ne,effectSize:{name:"categoricalTotalVariation",value:H(T,L,C,D)},nA:L,nB:D,reliable:L>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(T){return T==null||T===""||typeof T=="number"&&Number.isNaN(T)?null:T instanceof Date?T.getTime():typeof T=="object"?String(T):T}function F(T,L,C){if(C===l.WELCH||C===l.MANN_WHITNEY)return{test:C,chosenBy:"override",reason:`caller override: ${C}`};const D=w(T),$=w(L),P=D===null?null:Math.exp(-D/2),v=$===null?null:Math.exp(-$/2);return P!==null&&P<i||v!==null&&v<i?{test:l.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:l.WELCH,chosenBy:"auto",reason:P!==null||v!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(T,L,C,D={}){if(!T||!L)return null;const $=c(D.confidence),P=I(L);let v;if(Array.isArray(D.groups)&&D.groups.length===2)v=[O(D.groups[0]),O(D.groups[1])];else{const{map:he}=V(L,C),ce=[...he.entries()].sort((te,oe)=>oe[1]-te[1]).slice(0,2).map(te=>te[0]);if(ce.length<2)return x("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;v=ce}const[N,G]=v;if(N===null||G===null||N===G)return x("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const q=[],Z=[];for(let he=0;he<C.length;he++){const ce=O(P(C[he]));ce===N?q.push(C[he]):ce===G&&Z.push(C[he])}if(q.length===0||Z.length===0)return x("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=D.test&&D.test!=="auto"?String(D.test):null,ee=z(T,q.concat(Z));let ne,ie,se;if(J===l.CHI_SQUARE||!J&&!ee){ie=J?"override":"auto",se=J?"caller override: chiSquare":"column family: categorical";const he=V(T,q),ce=V(T,Z);ne=R(he.map,he.total,ce.map,ce.total,$,{category:D.category})}else{if((J===l.WELCH||J===l.MANN_WHITNEY)&&!ee)return x("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const he=X(T,q),ce=X(T,Z),te=F(he,ce,J);ie=te.chosenBy,se=te.reason,ne=te.test===l.MANN_WHITNEY?y(he,ce,$):b(he,ce,$)}return ne?{...ne,chosenBy:ie,reason:se,groups:[N,G]}:(x("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Le("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="__lattice_detail",x=36;function B(_){const X=_.config&&_.config.detailColumnWidth||x;return{id:Q,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:X,min:X,max:X,pin:_.config&&_.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(W,V){return!!(V&&V.expanded)},formatValue(){return""}}}const I=B}),Le("packages/core/src/columns/treecolumn.js",function(e,K){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",I=260;function _(W){const V=W.tree||{},H=W.config&&W.config.treeColumnWidth||I,z=()=>(W.columns&&x(W.columns.visible)?W.columns.visible():[]).find(u=>!u.generated)||null,w=(g,u)=>{if(u&&u.group)return u.groupValue;if(x(V.label))return V.label(g,u);if(typeof V.label=="string")return g==null?null:g[V.label];const h=z();return h&&x(h.getValue)?h.getValue(g,u):null},j=()=>{if(V.title)return V.title;const g=typeof V.label=="string"?W.columns&&x(W.columns.get)?W.columns.get(V.label):null:z();return g&&(g.title||g.id)||"Hierarchy"};return{id:B,get title(){return j()},field:null,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:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:140,pin:W.config&&W.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(g,u){return w(g,u)},formatValue(g,u){if(u&&u.grandTotal)return W.config&&W.config.grandTotalLabel||"Total";if(g==null)return"";if(!V.label){const h=z();if(h&&x(h.formatValue))return h.formatValue(g,u)}return String(g)}}}const X=_}),Le("packages/core/src/columns/pivotcolumns.js",function(e,K){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",I=500;function _(H){const{pivot:z,valueColumns:w,config:j}=H,g=z&&z.paths||[],u=H.separator||j&&j.pivot&&j.pivot.separator||" | ",h=j&&j.pivot&&j.pivot.maxColumns||I;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const a=X(j),r=g.length*w.length+(a?w.length:0);if(r>h){const o=`pivot would generate ${r} columns, above the limit of ${h}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return x(`pivot.maxColumns:${r}`,o),{tree:[],leaves:[],error:o}}const t=[],n=[];for(const o of g){const d=[];for(const l of w){const i=V(o,l,u);d.push(i),n.push(i)}d.length===1?(d[0].title=String(o),t.push(d[0])):t.push({id:`${B}:group:${o}`,title:String(o),columns:d,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const o=w.map(l=>W(l,j));n.push(...o);const d=j&&j.pivot&&j.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=d,a==="before"?t.unshift(o[0]):t.push(o[0]);else{const l={id:`${B}:group:__totals`,title:d,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(l):t.push(l)}}return{tree:t,leaves:n,error:null}}function X(H){const z=H&&H.pivot&&H.pivot.groupTotals;return z==="before"||z==="after"?z:null}function W(H,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${H.id}`,field:null,title:H.title||H.id,type:H.type,dataType:H.dataType,nullable:!0,align:H.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:H.id,total:!0},value:{pure:!0},cell:{align:H.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:H.total,lookup:null,layout:{width:H.layout&&H.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(w,j){const g=j&&j.totals;return g&&Object.hasOwn(g,H.id)?g[H.id]:null},formatValue(w,j){return w==null?"":H.formatValue?H.formatValue(w,j):String(w)}}}function V(H,z,w){return{id:`${B}:${H}${w}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,path:H,sourceId:z.id},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.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(j,g){return j==null?"":z.formatValue?z.formatValue(j,g):String(j)}}}}),Le("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return j}});const Q=K("packages/core/src/compute/handle.js"),x=Q.dictSize,B=Q.identity,I=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",V="\0",H=1<<20;function z(g,u,h,a){const r=g.length,t=g.map(m=>X(m)),n=Array.isArray(a)&&a.some(Boolean),o=n?t.map((m,c)=>a[c]?f=>a[c](m(f)):m):t;if(!n&&r>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(f=>x(f.dict)+1);let c=1;for(let f=0;f<r;f++)c*=m[f];if(c<=Number.MAX_SAFE_INTEGER){const f=g.map(A=>A.values),s=g.map(A=>I(A)),p=A=>{let k=0;for(let y=0;y<r;y++){const S=s[y],R=S&&S(A)===0?m[y]-1:f[y][A];k=k*m[y]+R}return k},b=new Float64Array(h);for(let A=0;A<h;A++)b[A]=p(u[A]);return{packed:b,strings:null,product:c,readers:o,keyOf:p}}}const l=m=>{let c="";for(let f=0;f<r;f++){const s=o[f](m);c+=(f===0?"":W)+(s==null?V:String(s))}return c},i=new Array(h);for(let m=0;m<h;m++)i[m]=l(u[m]);return{packed:null,strings:i,product:1/0,readers:o,keyOf:l}}function w(g,u,h,a){const r=new Uint32Array(a+1);for(let d=0;d<h;d++)r[u[d]+1]++;for(let d=0;d<a;d++)r[d+1]+=r[d];const t=new Uint32Array(h),n=r.slice(0,a);for(let d=0;d<h;d++)t[n[u[d]]++]=g[d];const o=new Array(a);for(let d=0;d<a;d++)o[d]=t.subarray(r[d],r[d+1]);return o}function j(g,u,h={}){const a=g||[],r=u||B(_(a[0],h)),t=r.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:n,strings:o,product:d,readers:l}=z(a,r,t,h.project),i=new Uint32Array(t);let m=0,c=null;if(n&&d<=Math.max(1024,Math.min(H,t*4))){const b=d,A=new Int32Array(b).fill(-1);for(let k=0;k<t;k++)A[n[k]]=0;for(let k=0;k<b;k++)A[k]===0&&(A[k]=m++);for(let k=0;k<t;k++)i[k]=A[n[k]];c=new Float64Array(m);for(let k=0;k<b;k++)A[k]>=0&&(c[A[k]]=k)}else if(n){const b=new Map;for(let A=0;A<t;A++){const k=n[A];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),i[A]=y}c=new Float64Array(m);for(const[A,k]of b)c[k]=A}else{const b=new Map;for(let A=0;A<t;A++){const k=o[A];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),i[A]=y}}const f=w(r,i,t,m),s=new Array(m);for(let b=0;b<m;b++){const A=f[b][0],k=new Array(l.length);for(let y=0;y<l.length;y++)k[y]=l[y](A);s[b]=k}const p={keys:s,buckets:f};return c&&(p.packed=c),p}}),Le("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const x=K("packages/core/src/internal/util.js").warnOnce,I=K("packages/core/src/compute/handle.js").valueComparator,X=K("packages/core/src/compute/group.js").packKeys,V=K("packages/core/src/compute/total.js").total,H="|",z="/",w=2e3;function j(d,l,i){return`${d}${H}${l}${H}${i}`}function g(d,l){let i="";for(let m=0;m<d.length;m++){const c=d[m];i+=(m===0?"":l)+(c==null?"":String(c))}return i}function u(d,l,i={}){const m=i.separator||z,c=l.length,{keyOf:f,readers:s}=X(d,l,0),p=new Map,b=[],A=[];for(let E=0;E<c;E++){const T=l[E],L=f(T);if(p.has(L))continue;p.set(L,b.length),A.push(L);const C=new Array(s.length);for(let D=0;D<s.length;D++)C[D]=s[D](T);b.push(C)}const k=I(i.locale),y=b.map((E,T)=>T);y.sort((E,T)=>{const L=b[E],C=b[T];for(let D=0;D<L.length;D++){const $=h(L[D],C[D],k);if($!==0)return $}return E-T});const S=new Array(y.length),R=new Array(y.length),O=new Map;for(let E=0;E<y.length;E++){const T=y[E];S[E]=b[T],R[E]=g(b[T],m),O.set(A[T],E)}return{keys:S,paths:R,idOf:E=>{const T=O.get(f(E));return T===void 0?-1:T}}}function h(d,l,i){const m=d==null,c=l==null;return m||c?m&&c?0:m?1:-1:i(d,l)}function a(d){const l=d.values||d.totals||[];if(l.length&&typeof l[0]=="object"&&l[0]!==null)return l.filter(f=>f&&f.handle);const i=typeof d.handle=="function"?d.handle:null;if(!i)return l.length&&x("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 m=typeof d.totalOf=="function"?d.totalOf:null,c=[];for(const f of l){const s=i(f);s&&c.push({colId:f,handle:s,fn:m?m(f):"sum"})}return c}function r(d,l,i){if(Array.isArray(d)){const m=i||{};return{...m,pivotHandles:d,order:l||null,groups:m.groups||null}}return d||{}}function t(d,l,i){const m=r(d,l,i),c=m.separator||z,f=a(m),s=m.maxColumns===void 0?w:m.maxColumns,p=m.groups&&m.groups.buckets?m.groups:null,b=p?p.buckets:[m.order||new Uint32Array(0)],A=m.groupPaths||(p?p.keys.map(L=>g(L,c)):[""]),k=o(b),{keys:y,paths:S,idOf:R}=u(m.pivotHandles||[],k,m),O=S.length*Math.max(1,f.length),F=n(S,f,c);if(s&&O>s){const L=new Map;return{keys:y,paths:S,fields:F,groupPaths:A,columns:O,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:s}}}const E=new Map,T=S.length;for(let L=0;L<b.length;L++){const C=b[L],D=A[L]===void 0?"":A[L],$=C.length;if($===0)continue;const P=new Int32Array($),v=new Uint32Array(T+1);for(let q=0;q<$;q++){const Z=R(C[q]);P[q]=Z,Z>=0&&v[Z+1]++}for(let q=0;q<T;q++)v[q+1]+=v[q];const N=new Uint32Array($),G=v.slice(0,T);for(let q=0;q<$;q++){const Z=P[q];Z>=0&&(N[G[Z]++]=C[q])}for(let q=0;q<T;q++){const Z=v[q],J=v[q+1];if(J===Z)continue;const ee=N.subarray(Z,J);for(let ne=0;ne<f.length;ne++){const ie=f[ne],se=V(ie.handle,ee,ie.fn,m.totalContext||{locale:m.locale});E.set(j(D,S[q],ie.colId),se)}}}return{keys:y,paths:S,fields:F,groupPaths:A,columns:O,values:E,cells:E,error:null}}function n(d,l,i){if(l.length===0)return d.slice();const m=[];for(const c of d)for(const f of l)m.push(`${c}${i}${f.colId}`);return m}function o(d){if(d.length===1)return d[0]||new Uint32Array(0);let l=0;for(const c of d)l+=c?c.length:0;const i=new Uint32Array(l);let m=0;for(const c of d)!c||c.length===0||(i.set(c,m),m+=c.length);return i}}),Le("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return x}});const Q=8;class x{static#e=new Uint8Array(256);static{for(let I=1;I<256;I++)x.#e[I]=x.#e[I>>1]+(I&1)}#t;#n;constructor(I=0){const _=Math.max(0,I|0);this.#n=_,this.#t=new Uint8Array(Math.ceil(_/Q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(I){return I<0||I>=this.#n?0:this.#t[I>>3]>>(I&7)&1}set(I){return I>=0&&I<this.#n&&(this.#t[I>>3]|=1<<(I&7)),this}clear(I){return I>=0&&I<this.#n&&(this.#t[I>>3]&=~(1<<(I&7))),this}assign(I,_){return _?this.set(I):this.clear(I)}fill(I=!1){return this.#t.fill(I?255:0),I&&this.#r(),this}grow(I){const _=Math.max(0,I|0);if(_<=this.#n)return this;const X=Math.ceil(_/Q);if(X>this.#t.length){const W=new Uint8Array(X);W.set(this.#t),this.#t=W}return this.#n=_,this}count(){const I=this.#t,_=x.#e;let X=0;for(let W=0;W<I.length;W++)X+=_[I[W]];return X}and(I){const _=I instanceof x?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let V=0;V<W;V++)X[V]&=_[V];for(let V=W;V<X.length;V++)X[V]=0;return this}or(I){const _=I instanceof x?I.words:I,X=this.#t,W=Math.min(X.length,_.length);for(let V=0;V<W;V++)X[V]|=_[V];return this}not(){const I=this.#t;for(let _=0;_<I.length;_++)I[_]=~I[_]&255;return this.#r(),this}clone(){const I=new x(this.#n);return I.words.set(this.#t.subarray(0,I.words.length)),I}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const I=this.#n&7;if(I===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<I)-1)}static from(I){const _=Array.isArray(I)?I:Array.from(I),X=new x(_.length);for(let W=0;W<_.length;W++)_[W]&&X.set(W);return X}}}),Le("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,B=Q.defaultCompare;class I{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(X=[]){this.#e=[];for(let W=0;W<X.length;W++){const V=X[W];this.#t.has(V)||(this.#t.set(V,this.#e.length),this.#e.push(V))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let X=this.#e.length*8;for(let W=0;W<this.#e.length;W++){const V=this.#e[W];typeof V=="string"&&(X+=V.length*2),X+=16}return X}codeOf(X){const W=this.#t.get(X);if(W!==void 0)return W;const V=this.#e.length;return this.#e.push(X),this.#t.set(X,V),this.#n++,V}lookup(X){const W=this.#t.get(X);return W===void 0?-1:W}has(X){return this.#t.has(X)}valueOf(X){return this.#e[X]}values(){return this.#e}ranks(X){const W=X||"";if(this.#r&&this.#o===this.#n&&this.#i===W)return this.#r;const V=this.#e.length,H=new Array(V);for(let g=0;g<V;g++)H[g]=g;const z=x(X).compare,w=this.#e;H.sort((g,u)=>this.#s(w[g],w[u],z));const j=new Uint32Array(V);for(let g=0;g<V;g++)j[H[g]]=g;return this.#r=j,this.#o=this.#n,this.#i=W,j}#s(X,W,V){return typeof X=="string"&&typeof W=="string"?V(X,W):B(X,W)}}}),Le("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Q}});class Q{#e;#t;#n=0;#r=0;constructor(B={}){const I=Math.max(1,B.rows??16),_=Math.max(1,B.values??I);this.#e=new Int32Array(_),this.#t=new Uint32Array(I+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(B){return B<0||B>=this.#n?0:this.#t[B+1]-this.#t[B]}at(B){return B<0||B>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[B],this.#t[B+1])}has(B,I){if(B<0||B>=this.#n)return!1;const _=this.#e,X=this.#t[B+1];for(let W=this.#t[B];W<X;W++)if(_[W]===I)return!0;return!1}hasAny(B,I){for(let _=0;_<I.length;_++)if(this.has(B,I[_]))return!0;return!1}hasAll(B,I){for(let _=0;_<I.length;_++)if(!this.has(B,I[_]))return!1;return!0}hasNone(B,I){return!this.hasAny(B,I)}push(B){const I=this.#n,_=B.length;this.#o(I+1),this.#i(this.#r+_);const X=this.#r;for(let W=0;W<_;W++)this.#e[X+W]=B[W]|0;return this.#r+=_,this.#n=I+1,this.#t[I]=X,this.#t[I+1]=this.#r,I}write(B,I){if(B===this.#n){this.push(I);return}if(B<0||B>this.#n)return;const _=this.#t[B],X=this.#t[B+1],W=I.length;if(X-_===W){for(let V=0;V<W;V++)this.#e[_+V]=I[V]|0;return}this.#s(B,I)}compact(B,I,_){const X=this.#e,W=this.#t,V=this.#n,H=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(I+1);let w=0;for(let j=0;j<V;j++){if(B[j]===_)continue;const g=W[j],u=W[j+1];z[B[j]]=w;for(let h=g;h<u;h++)H[w++]=X[h];z[B[j]+1]=w}this.#e=H,this.#t=z,this.#n=I,this.#r=w}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(B){if(B+1<=this.#t.length)return;let I=this.#t.length-1;for(;I<B;)I=I*2||16;const _=new Uint32Array(I+1);_.set(this.#t),this.#t=_}#i(B){if(B<=this.#e.length)return;let I=this.#e.length;for(;I<B;)I=I*2||16;const _=new Int32Array(I);_.set(this.#e),this.#e=_}#s(B,I){const _=this.#e,X=this.#t,W=this.#n,V=I.length-(X[B+1]-X[B]),H=new Int32Array(Math.max(1,this.#r+V)),z=new Uint32Array(X.length);let w=0;for(let j=0;j<W;j++){if(z[j]=w,j===B)for(let g=0;g<I.length;g++)H[w++]=I[g]|0;else for(let g=X[j];g<X[j+1];g++)H[w++]=_[g];z[j+1]=w}this.#e=H,this.#t=z,this.#r=w}}}),Le("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/compute/handle.js"),x=Q.bitReader,B=Q.dictRanks,I=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,V=Q.rowCount,H=Q.valueComparator,z=Q.valueReader,w=new Uint32Array(0),j=new ArrayBuffer(8),g=new Float64Array(j),u=new Uint32Array(j),h=(g[0]=-1,(u[1]&2147483648)!==0?1:0),a=h===1?0:1;function r(C,D){g[0]=C;let $=u[h],P=u[a];($&2147483648)!==0?($=~$>>>0,P=~P>>>0):$=($^2147483648)>>>0,D[0]=P,D[1]=$}function t(C,D,$,P){if(P<2)return C;const v=new Uint32Array(256*8);for(let ie=0;ie<P;ie++){const se=D[ie],he=$[ie];v[se&255]++,v[256+(se>>>8&255)]++,v[512+(se>>>16&255)]++,v[768+(se>>>24&255)]++,v[1024+(he&255)]++,v[1280+(he>>>8&255)]++,v[1536+(he>>>16&255)]++,v[1792+(he>>>24&255)]++}let N=C,G=D,q=$,Z=new Uint32Array(P),J=new Uint32Array(P),ee=new Uint32Array(P);const ne=new Uint32Array(256);for(let ie=0;ie<8;ie++){const se=ie<<8,he=(ie&3)<<3,ce=ie>=4;let te=!1;for(let de=0;de<256;de++)if(v[se+de]===P){te=!0;break}if(te)continue;let oe=0;for(let de=0;de<256;de++)ne[de]=oe,oe+=v[se+de];for(let de=0;de<P;de++){const we=G[de],Te=q[de],Ae=(ce?Te:we)>>>he&255,Ce=ne[Ae]++;Z[Ce]=N[de],J[Ce]=we,ee[Ce]=Te}let fe=N;N=Z,Z=fe,fe=G,G=J,J=fe,fe=q,q=ee,ee=fe}return N}function n(C,D,$){if($<2)return C;const P=new Uint32Array(256*4);for(let J=0;J<$;J++){const ee=D[J];P[ee&255]++,P[256+(ee>>>8&255)]++,P[512+(ee>>>16&255)]++,P[768+(ee>>>24&255)]++}let v=C,N=D,G=new Uint32Array($),q=new Uint32Array($);const Z=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,ne=J<<3;let ie=!1;for(let ce=0;ce<256;ce++)if(P[ee+ce]===$){ie=!0;break}if(ie)continue;let se=0;for(let ce=0;ce<256;ce++)Z[ce]=se,se+=P[ee+ce];for(let ce=0;ce<$;ce++){const te=N[ce],oe=Z[te>>>ne&255]++;G[oe]=v[ce],q[oe]=te}let he=v;v=G,G=he,he=N,N=q,q=he}return v}function o(C,D,$,P){const v=new Uint32Array(P+1);for(let q=0;q<$;q++)v[D[q]]++;let N=0;for(let q=0;q<=P;q++){const Z=v[q];v[q]=N,N+=Z}const G=new Uint32Array($);for(let q=0;q<$;q++)G[v[D[q]]++]=C[q];return G}function d(C,D,$,P){return $<2?C:P<=65536||P<=$*2?o(C,D,$,P):n(C,D,$)}function l(C,D){return C.length===D&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,D)}function i(C,D,$=!1){const P=D||_(C.length),v=P.length;if(v<2)return Uint32Array.from(P);const N=new Uint32Array(v),G=new Uint32Array(v),q=new Uint32Array(v),Z=new Uint32Array(v),J=new Uint32Array(2);let ee=0,ne=0;for(let he=0;he<v;he++){const ce=P[he],te=C[ce];if(Number.isNaN(te)){Z[ne++]=ce;continue}r(te,J),$?(G[ee]=~J[0]>>>0,q[ee]=~J[1]>>>0):(G[ee]=J[0],q[ee]=J[1]),N[ee++]=ce}const ie=t(N.subarray(0,ee),G.subarray(0,ee),q.subarray(0,ee),ee);if(ne===0)return l(ie,ee);const se=new Uint32Array(v);return se.set(ie.subarray(0,ee),0),se.set(Z.subarray(0,ne),ee),se}function m(C,D,$=!1){const P=D||_(C.length),v=P.length;if(v<2)return Uint32Array.from(P);const N=Uint32Array.from(P),G=new Uint32Array(v);for(let q=0;q<v;q++){const Z=(C[N[q]]^2147483648)>>>0;G[q]=$?~Z>>>0:Z}return l(n(N,G,v),v)}function c(C,D,$={}){const P=D||_(V(C,$)),v=P.length;if(v<2)return Uint32Array.from(P);const N=B(C.dict,$.locale),G=C.values,q=W(C),Z=Math.max(I(C.dict),N.length),J=Z,ee=Uint32Array.from(P),ne=new Uint32Array(v),ie=!!$.descending;for(let se=0;se<v;se++){const he=ee[se];let ce=q&&q(he)===0?J:N[G[he]];ce===void 0&&(ce=J),ne[se]=ie?J-ce:ce}return l(d(ee,ne,v,Z+1),v)}function f(C,D,$){const P=D.length;let v=Uint32Array.from(D);if(P<2)return v;let N=new Uint32Array(P);for(let G=1;G<P;G<<=1){for(let Z=0;Z<P;Z+=G<<1){const J=Math.min(Z+G,P),ee=Math.min(Z+(G<<1),P);let ne=Z,ie=J,se=Z;for(;ne<J&&ie<ee;)N[se++]=$(C[v[ne]],C[v[ie]])<=0?v[ne++]:v[ie++];for(;ne<J;)N[se++]=v[ne++];for(;ie<ee;)N[se++]=v[ie++]}const q=v;v=N,N=q}return v}function s(C,D,$){const P=x(C.values),v=D.length,N=new Uint32Array(v),G=$?1:0;let q=0;for(let Z=0;Z<v;Z++)P(D[Z])===G&&(N[q++]=D[Z]);for(let Z=0;Z<v;Z++)P(D[Z])!==G&&(N[q++]=D[Z]);return N}function p(C,D){const $=C.values,P=C.kind;if((P==="object"||P===void 0)&&(Array.isArray($)||ArrayBuffer.isView($))&&!C.presence)return $;const N=z(C),G=new Array(V(C)||0);for(let q=0;q<D.length;q++){const Z=D[q];G[Z]=N(Z)}return G}function b(C,D){for(let $=0;$<D.length;$++)if(typeof C[D[$]]!="string")return!1;return!0}function A(C,D,$,P,v){const N=C.length,G=Uint32Array.from(C);if(N<2||P<1)return G;const q=new Uint32Array(N),Z=P-1;for(let J=0;J<N;J++){const ee=$[D[J]];q[J]=v?Z-ee:ee}return l(d(G,q,N,P),N)}function k(C,D,$){const P=H($),v=new Array(D);for(let G=0;G<D;G++)v[G]=G;v.sort((G,q)=>P(C[G],C[q])||G-q);const N=new Uint32Array(D);for(let G=0;G<D;G++)N[v[G]]=G;return N}function y(C,D,$){const P=D.length,v=new Map,N=[],G=new Uint32Array(P);for(let J=0;J<P;J++){const ee=C[D[J]];let ne=v.get(ee);ne===void 0&&(ne=N.length,v.set(ee,ne),N.push(ee)),G[J]=ne}const q=N.length,Z=k(N,q,$.locale);return A(D,G,Z,q,!!$.descending)}function S(C,D,$){const P=p(C,D);if(D.length>=2&&b(P,D)){const G=C.stringRank;return G&&G.version===C.version&&G.usable(D,P,$.locale)?G.sort(D,$):y(P,D,$)}const v=H($.locale),N=$.descending?(G,q)=>v(q,G):v;return f(P,D,N)}function R(C,D,$){const P=p(C,D),v=$.compare,G=!!$.descending?(q,Z)=>-v(q,Z,void 0,void 0,!0):(q,Z)=>v(q,Z,void 0,void 0,!1);return f(P,D,G)}function O(C,D){const $=D.length,P=W(C),v=C.values,N=C.kind==="float64"&&!!v,G=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!P&&!N&&!G)return{present:D,absent:w};const q=new Uint32Array($),Z=new Uint32Array($);let J=0,ee=0;if(P&&N)for(let ne=0;ne<$;ne++){const ie=D[ne];P(ie)===1&&!Number.isNaN(v[ie])?q[J++]=ie:Z[ee++]=ie}else if(N&&!P)for(let ne=0;ne<$;ne++){const ie=D[ne];Number.isNaN(v[ie])?Z[ee++]=ie:q[J++]=ie}else if(P&&!G)for(let ne=0;ne<$;ne++){const ie=D[ne];P(ie)===1?q[J++]=ie:Z[ee++]=ie}else{const ne=z(C);for(let ie=0;ie<$;ie++){const se=D[ie];X(ne(se))?Z[ee++]=se:q[J++]=se}}return ee===0?{present:D,absent:w}:{present:q.subarray(0,J),absent:Z.subarray(0,ee)}}function F(C,D,$){if(D.length===0)return C;const P=new Uint32Array(C.length+D.length);return $?(P.set(D,0),P.set(C,D.length)):(P.set(C,0),P.set(D,C.length)),P}function E(C,D,$={}){const P=D||_(V(C,$));if(!C||P.length<2)return Uint32Array.from(P);const{present:v,absent:N}=O(C,P);if(v.length===0)return Uint32Array.from(P);const G=!!$.descending;let q;if(typeof $.compare=="function")q=R(C,v,$);else switch(C.kind){case"float64":q=i(C.values,v,G);break;case"int32":q=m(C.values,v,G);break;case"dictionary":q=c(C,v,$);break;case"bitset":q=s(C,v,G);break;default:q=S(C,v,$);break}return F(q,N,!!$.nullsFirst)}function T(C,D,$,P={}){const v=D||[],N=v.length&&(v[0].handle||L(C,v[0].col))||C&&C[0];let G=$||_(V(N,P));for(let q=v.length-1;q>=0;q--){const Z=v[q],J=Z.handle||L(C,Z.col)||C&&C[q];J&&(G=E(J,G,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:P.locale,compare:Z.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function L(C,D){if(!(!C||D===void 0)){for(let $=0;$<C.length;$++)if(C[$]&&C[$].id===D)return C[$]}}}),Le("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/compute/sort.js"),x=Q.collateStringRanks,B=Q.rankSortStrings,I=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(W=I){this.#s=W>0?W:I,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(W){this.#i=W}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let W=this.#n.byteLength;const V=this.#e;for(let H=0;H<V.length;H++)W+=V[H].length*2+24;return W}#d(W,V){const H=this.#t.get(W);if(H!==void 0)return H;if(this.#l)return-1;if(V&&this.#e.length>=this.#s)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(W),this.#t.set(W,z),this.#o++,z}build(W,V){const H=V|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(H);for(let z=0;z<H;z++){const w=W[z],j=typeof w=="string"?this.#d(w,!1):-1;this.#n[z]=j<0?0:j}this.#r=H}append(W,V,H){const z=(V|0)+(H|0);if(z>this.#n.length){const w=new Uint32Array(z);w.set(this.#n.subarray(0,this.#r)),this.#n=w}for(let w=V|0;w<z;w++){const j=W[w],g=typeof j=="string"?this.#d(j,!0):-1;this.#n[w]=g<0?0:g}this.#r=Math.max(this.#r,z)}ranks(W){const V=W||"";if(this.#a&&this.#u===this.#o&&this.#c===V)return this.#a;const H=x(this.#e,this.#e.length,W);return this.#a=H,this.#u=this.#o,this.#c=V,H}usable(W,V,H){if(this.#l||this.#e.length===0)return!1;const z=this.#n,w=this.#e,j=this.#r;for(let g=0;g<W.length;g++){const u=W[g];if(u>=j||w[z[u]]!==V[u])return!1}return!0}sort(W,V){const H=this.ranks(V.locale),z=this.#e.length,w=W.length,j=new Uint32Array(w),g=this.#n;for(let u=0;u<w;u++)j[u]=g[W[u]];return B(W,j,H,z,!!V.descending)}}}),Le("packages/core/src/store/columnstore.js",function(e,K){"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 m}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isFunction,I=Q.pathGetter,X=K("packages/core/src/store/bitset.js").Bitset,V=K("packages/core/src/store/dictionary.js").Dictionary,z=K("packages/core/src/store/multivalue.js").MultiValue,j=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,u=1024,h=5e3,a=.2,r=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(f){return f==null}function n(f){if(typeof f=="number")return f;if(f instanceof Date)return f.getTime();if(typeof f=="boolean")return f?1:0;const s=Number(f);return Number.isNaN(s)&&typeof f=="string"?Date.parse(f):s}function o(f){const s=n(f);return Number.isFinite(s)?s|0:0}function d(f){return t(f)?[]:Array.isArray(f)?f:[f]}function l(f,s){switch(f.kind){case"float64":case"int32":return f.buf[s];case"bitset":return f.bits.get(s)===1;case"dictionary":return f.dict.valueOf(f.buf[s]);case"multi":{const p=f.mv.at(s),b=new Array(p.length);for(let A=0;A<p.length;A++)b[A]=f.dict.valueOf(p[A]);return b}default:return f.buf[s]}}function i(f,s){switch(f.kind){case"float64":case"int32":return f.values[s];case"bitset":return(f.values[s>>3]&1<<(s&7))!==0;case"dictionary":return(f.table||[])[f.values[s]];case"multi":{const p=f.offsets[s],b=f.offsets[s+1],A=f.table||[],k=new Array(b-p);for(let y=p;y<b;y++)k[y-p]=A[f.values[y]];return k}default:return f.values[s]}}class m{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#p;#m=-1;#g=null;#b=0;#w=0;#O=null;#y=null;#A=!1;constructor(s,p){this.#e=s.id;const b=r.has(s.kind)?s.kind:"object";s.kind&&!r.has(s.kind)&&x(`store.kind.${s.id}`,`column "${s.id}" declares unknown storage kind "${s.kind}"; falling back to object`),this.#n=b,this.#t=b,this.#r=s.nullable!==!1,this.#s=s.dictionary??null,this.#i=p,this.#o=B(s.read)?s.read:I(s.field||s.id),this.#f=s.stringRankIndex!=="off",this.#p=typeof s.stringRankMaxDistinct=="number"?s.stringRankMaxDistinct:0,this.#O=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.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#P().values}get presence(){return this.#A||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#A||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#A||!this.#f||this.kind!=="object")return null;const s=this.values,p=this.#i.physical();if(!s||p===0)return null;if(this.#h===null){if(typeof s[0]!="string")return null;const b=new j(this.#k());return b.build(s,p),b.version=this.#w,this.#h=b,this.#m=this.#w,b.capped?null:b}return this.#h.length<p&&this.#h.append(s,this.#h.length,p-this.#h.length),this.#h.version=this.#w,this.#m=this.#w,this.#h.capped?null:this.#h}#k(){return this.#p}#C(){this.#h=null,this.#m=-1}get offsets(){return this.#A||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#w}get bytes(){let s=0;return this.#a&&(s+=this.#a.byteLength??this.#a.length*8),this.#u&&(s+=this.#u.bytes),this.#c&&(s+=this.#c.bytes),this.#g&&(s+=this.#g.bytes),this.#d&&(s+=this.#d.bytes),this.#O&&(s+=this.#O.size*24),s}get(s){if(!this.#A&&!(s<0||s>=this.#i.physical())){if(!this.#l)return this.#T(s);if(this.#r&&this.#g.get(s)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[s];case"bitset":return this.#u.get(s)===1;case"dictionary":return this.#d.valueOf(this.#a[s]);case"multi":{const p=this.#c.at(s),b=new Array(p.length);for(let A=0;A<p.length;A++)b[A]=this.#d.valueOf(p[A]);return b}default:return this.#a[s]}}}set(s,p){this.#A||(this.#l?this.#E(s,p):this.#O.set(s,p===void 0?null:p),this.#h&&this.#C(),this.#w++)}read(s){return this.#o(s)}appendColumn(s,p,b){if(this.#A||b<=0)return;if(!this.#l){this.#w++;return}const A=this.#o,k=this.#r,y=this.#g;let S=!1;switch(this.#t){case"float64":{const R=this.#a;for(let O=0;O<b;O++){const F=A(s[O]);if(typeof F=="number"){k&&y.set(p+O),R[p+O]=F;continue}const E=F==null;k?y.assign(p+O,!E):E&&(S=!0),R[p+O]=E?NaN:n(F)}break}case"int32":{const R=this.#a;for(let O=0;O<b;O++){const F=A(s[O]),E=F==null;k?y.assign(p+O,!E):E&&(S=!0),R[p+O]=E?0:o(F)}break}case"bitset":{const R=this.#u;for(let O=0;O<b;O++){const F=A(s[O]),E=F==null;k?y.assign(p+O,!E):E&&(S=!0),R.assign(p+O,!E&&!!F)}break}case"dictionary":{const R=this.#a,O=this.#d;for(let F=0;F<b;F++){const E=A(s[F]),T=E==null;k?y.assign(p+F,!T):T&&(S=!0),R[p+F]=T?0:O.codeOf(E)}break}case"multi":{const R=this.#c,O=this.#d;for(let F=0;F<b;F++){const E=A(s[F]),T=E==null;k?y.assign(p+F,!T):T&&(S=!0);const L=d(E),C=new Array(L.length);for(let D=0;D<L.length;D++)C[D]=O.codeOf(L[D]);R.write(p+F,C)}break}default:{const R=this.#a;for(let O=0;O<b;O++){const F=A(s[O]),E=F==null;k?y.assign(p+O,!E):E&&(S=!0),R[p+O]=E?null:F}break}}S&&x(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,p,b),this.#h.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(s,p,b){if(this.#A||b<=0||!s)return;if(!this.#l){this.#w++;return}const A=this.#g,k=s.presence;if(A)if(k)for(let S=0;S<b;S++)A.assign(p+S,(k[S>>3]&1<<(S&7))!==0);else for(let S=0;S<b;S++)A.set(p+S);const y=s.kind===this.#t;if(y&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(s.values,p),this.#w++;return}if(y&&this.#t==="bitset"){const S=s.values;for(let R=0;R<b;R++)this.#u.assign(p+R,(S[R>>3]&1<<(R&7))!==0);this.#w++;return}if(y&&this.#t==="dictionary"){const S=s.table||[],R=new Uint32Array(S.length);for(let T=0;T<S.length;T++)R[T]=this.#d.codeOf(S[T]);const O=s.values,F=this.#a,E=A;for(let T=0;T<b;T++){if(E&&(k&&(k[T>>3]&1<<(T&7))===0)){F[p+T]=0;continue}F[p+T]=R[O[T]]??0}this.#w++;return}if(y&&this.#t==="multi"){const S=s.table||[],R=new Uint32Array(S.length);for(let E=0;E<S.length;E++)R[E]=this.#d.codeOf(S[E]);const O=s.values,F=s.offsets;for(let E=0;E<b;E++){const T=F[E],L=F[E+1],C=new Array(L-T);for(let D=T;D<L;D++)C[D-T]=R[O[D]]??0;this.#c.write(p+E,C)}this.#w++;return}for(let S=0;S<b;S++){const R=k?(k[S>>3]&1<<(S&7))===0:s.kind==="object"?s.values[S]===null:!1;this.#E(p+S,R?null:i(s,S))}this.#w++}touch(){this.#w++}columnarise(s,p){if(this.#l||this.#A)return;const b=new Array(p);for(let A=0;A<p;A++)b[A]=this.#T(A);this.#t=this.#n,this.#l=!0,this.#S(s);for(let A=0;A<p;A++)this.#E(A,b[A]);this.#O.clear(),this.#y=null,this.#C(),this.#w++}grow(s){if(!(!this.#l||this.#A||s<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(s);p.set(this.#a),this.#a=p;break}case"bitset":this.#u.grow(s);break;case"multi":break;default:this.#a.length=s;break}this.#g&&this.#g.grow(s),this.#b=s,this.#w++}}convert(s){if(this.#A||!r.has(s)||(this.#n=s,!this.#l||s===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},b=this.#i.physical(),A=this.#g;this.#t=s,this.#S(this.#b);for(let k=0;k<b;k++){const y=A!==null&&A.get(k)===0;y&&s!=="multi"||this.#E(k,y?null:l(p,k))}return this.#C(),this.#w++,!0}compact(s,p,b){if(!this.#A){if(this.#C(),!this.#l){const A=this.#O;if(A.size){const k=new Map;for(const[y,S]of A)s[y]!==g&&k.set(s[y],S);this.#O=k}this.#y=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const A=this.#a;for(let k=0;k<p;k++)s[k]!==g&&(A[s[k]]=A[k]);if(this.#t==="object")for(let k=b;k<p;k++)A[k]=void 0;break}case"bitset":{const A=this.#u;for(let k=0;k<p;k++)s[k]!==g&&A.assign(s[k],A.get(k)===1);for(let k=b;k<p;k++)A.clear(k);break}case"multi":this.#c.compact(s,b,g);break;default:break}if(this.#g){const A=this.#g;for(let k=0;k<p;k++)s[k]!==g&&A.assign(s[k],A.get(k)===1);for(let k=b;k<p;k++)A.clear(k)}this.#w++}}release(){this.#A||(this.#A=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#O=new Map,this.#y=null,this.#b=0,this.#w++)}#S(s){const p=Math.max(1,s);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#u=new X(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#d=this.#d??new V(this.#s??[]);break;case"multi":this.#c=new z({rows:p,values:p}),this.#d=this.#d??new V(this.#s??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new X(p)),this.#b=p}#E(s,p){const b=t(p);switch(this.#r?this.#g.assign(s,!b):b&&x(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[s]=b?NaN:n(p);break;case"int32":this.#a[s]=b?0:o(p);break;case"bitset":this.#u.assign(s,!b&&!!p);break;case"dictionary":this.#a[s]=b?0:this.#d.codeOf(p);break;case"multi":{const A=d(p),k=new Array(A.length);for(let y=0;y<A.length;y++)k[y]=this.#d.codeOf(A[y]);this.#c.write(s,k);break}default:this.#a[s]=b?null:p;break}}#T(s){if(this.#O.has(s))return this.#O.get(s);const p=this.#o(this.#i.rowAt(s));return p===void 0?null:p}#P(){if(this.#y&&this.#y.version===this.#w)return this.#y;const s=this.#i.physical(),p=new Array(s),b=this.#r?new X(s):null;for(let A=0;A<s;A++){const k=this.#T(A);p[A]=k,b&&!t(k)&&b.set(A)}return this.#y={version:this.#w,values:p,presence:b},this.#y}}class c{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new X(0);#u=!1;#c=!0;#d;#h;#f;#p=!1;constructor(s,p={}){this.#e=Array.isArray(s)?s:[],this.#h=Math.max(1,p.initialCapacity??u),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??h:0,this.#f=p.compactRatio??a;const b={rowAt:A=>this.#r[A],physical:()=>this.#o};for(const A of this.#e){if(!A||!A.id)continue;if(this.#t.has(A.id)){x(`store.dup.${A.id}`,`duplicate column id "${A.id}" in the store schema; ignoring the second`);continue}const k=new m(A,b);this.#t.set(A.id,k),this.#n.push(k)}this.#d<=0&&this.#b()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let s=this.#a.bytes+this.#r.length*8;for(const p of this.#n)s+=p.bytes;return s}append(s){const p=this.#o;if(this.#p||!s)return{from:p,to:p};const b=s.length|0;if(b===0)return{from:p,to:p};if(this.#c)for(let k=0;k<b;k++)this.#r[p+k]=s[k];if(this.#o=p+b,this.#s+=b,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#b();else for(const k of this.#n)k.touch();return{from:p,to:this.#o}}this.#m(this.#o);const A=this.#n;for(let k=0;k<A.length;k++)A[k].appendColumn(s,p,b);return{from:p,to:this.#o}}appendPacked(s,p){const b=this.#o;if(this.#p||!s)return{from:b,to:b};const A=s.count|0;if(A===0)return{from:b,to:b};if(this.#c&&p)for(let y=0;y<A;y++)this.#r[b+y]=p[y];this.#o=b+A,this.#s+=A,this.#a.grow(this.#o),this.#u||this.#b(),this.#m(this.#o);const k=new Map;for(const y of s.columns)k.set(y.id,y);for(const y of this.#n){const S=k.get(y.id);S?y.appendPacked(S,b,A):y.grow(this.#i)}return{from:b,to:this.#o}}source(s){if(this.#c)return this.#r[s];if(!(s<0||s>=this.#o))return this.#g(s)}setSource(s,p){this.#p||s<0||s>=this.#o||this.#c&&(this.#r[s]=p)}get(s,p){const b=this.#t.get(s);return b?b.get(p):void 0}set(s,p,b){if(this.#p||p<0||p>=this.#o)return;const A=this.#t.get(s);if(!A){x(`store.set.${s}`,`set() on unknown column "${s}"`);return}A.set(p,b)}remove(s){return this.#p||s<0||s>=this.#o||this.#a.get(s)===1?!1:(this.#a.set(s),this.#l++,this.#s--,!0)}live(s){return s<0||s>=this.#o?!1:this.#a.get(s)===0}compact(s={}){if(this.#p||this.#l===0||!s.force&&this.#l/this.#o<this.#f)return null;const p=this.#o,b=new Uint32Array(p);let A=0;for(let k=0;k<p;k++)b[k]=this.#a.get(k)===1?g:A++;for(const k of this.#n)k.compact(b,p,A);if(this.#c){const k=this.#r;for(let y=0;y<p;y++)b[y]!==g&&(k[b[y]]=k[y]);k.length=A}return this.#o=A,this.#s=A,this.#l=0,this.#a=new X(Math.max(this.#i,A)),b}column(s){return this.#t.get(s)}columns(){return this.#n.slice()}liveIndices(){const s=new Uint32Array(this.#s);if(this.#l===0){for(let b=0;b<this.#o;b++)s[b]=b;return s}let p=0;for(let b=0;b<this.#o;b++)this.#a.get(b)===0&&(s[p++]=b);return s}convert(s,p){const b=this.#t.get(s);return b?b.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const s of this.#n)s.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(s){if(s<=this.#i)return;let p=this.#i||this.#h;for(;p<s;)p*=2;for(const b of this.#n)b.grow(p);this.#a.grow(p),this.#i=p}#g(s){const p={};for(const b of this.#n)p[b.id]=b.get(s);return p}#b(){if(this.#u)return;let s=this.#h;for(;s<this.#o;)s*=2;this.#u=!0,this.#i=s,this.#a.grow(s);for(const p of this.#n)p.columnarise(s,this.#o)}}}),Le("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const Q=64,x=8;function B(W){let V=Q;for(;V<W;)V*=2;return V}class I{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(V={}){this.#n=V.limit??x}get bytes(){return this.#r}mask(V){const H=new Uint8Array(this.#i(V),0,V);return H.fill(0),H}indices(V){return new Uint32Array(this.#i(V*4),0,V)}release(V){if(!V||!V.buffer)return!1;const H=V.buffer;if(!this.#t.has(H))return!1;this.#t.delete(H),this.#o.released++;const z=H.byteLength;let w=this.#e.get(z);return w||this.#e.set(z,w=[]),w.length>=this.#n||(w.push(H),this.#r+=z),!0}releaseAll(V){for(const H of V)this.release(H)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(V){const H=B(V),z=this.#e.get(H);this.#o.acquired++;let w;return z&&z.length?(w=z.pop(),this.#r-=H,this.#o.reused++):w=new ArrayBuffer(H),this.#t.add(w),w}}function _(){return X??=new I,X}let X=null}),Le("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return _}});function Q(X){return{locale:X===void 0?void 0:String(X),numeric:!0,sensitivity:"variant"}}function x(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!x(X[W]))return!1;return!0}function I(X,W){const V=X.col!==void 0?X.col:X.handle&&X.handle.id,H=X.locale!==void 0?X.locale:W;return{col:V,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(H)}}function _(X,W){const V=X||[],H=new Array(V.length);for(let z=0;z<V.length;z++)H[z]=I(V[z],W);return H}}),Le("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const Q=K("packages/core/src/compute/handle.js"),x=Q.presenceReader,B=Q.valueReader,I=Q.dictSize,_=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),W=Object.freeze(["hour","day","week","month","quarter","year"]),V=20,H=50,z=1e4;function w(k,y){if(!k)return"none";const S=y;if(S&&(S.multi===!0||typeof S.items=="function"))return"category";const R=y&&y.base;if(R==="date"||R==="datetime"||R==="time"||R==="dateString")return"date";switch(k.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return R==="number"?"numeric":R==="boolean"?"boolean":R==="text"?"category":"none"}}function j(k){const y=k.values,S=k.kind;if((S==="float64"||S==="int32")&&y)return O=>y[O];const R=B(k);return O=>g(R(O))}function g(k){if(typeof k=="number")return k;if(k instanceof Date)return k.getTime();if(k==null||k==="")return NaN;if(typeof k=="boolean")return k?1:0;if(typeof k=="string"){const y=Number(k);if(Number.isFinite(y))return y;const S=Date.parse(k);return Number.isFinite(S)?S:NaN}return NaN}function u(k,y,S,R=H){if(!k)return{cardinality:0,exact:!0};if(k.dict)return{cardinality:I(k.dict),exact:!0};if(k.kind==="bitset")return{cardinality:2,exact:!0};const O=B(k),F=y?y.length:S,E=new Set;for(let T=0;T<F;T++){const L=O(y?y[T]:T);if(L!=null&&(E.add(L),E.size>R))return{cardinality:E.size,exact:!1}}return{cardinality:E.size,exact:!0}}const h=36e5,a=864e5;function r(k,y=V){const S=Number.isFinite(k)&&k>0?k:0,R=Math.max(1,y)*2;return S/h<=R?"hour":S/a<=R?"day":S/(7*a)<=R?"week":S/(30*a)<=R?"month":S/(91*a)<=R?"quarter":"year"}function t(k,y){if(!Number.isFinite(k))return NaN;const S=new Date(k);switch(y){case"hour":return S.setMinutes(0,0,0),S.getTime();case"day":return S.setHours(0,0,0,0),S.getTime();case"week":{S.setHours(0,0,0,0);const R=(S.getDay()+6)%7;return S.setDate(S.getDate()-R),S.getTime()}case"month":return S.setDate(1),S.setHours(0,0,0,0),S.getTime();case"quarter":return S.setMonth(Math.floor(S.getMonth()/3)*3,1),S.setHours(0,0,0,0),S.getTime();default:return S.setMonth(0,1),S.setHours(0,0,0,0),S.getTime()}}function n(k,y){const S=new Date(k);switch(y){case"hour":S.setHours(S.getHours()+1);break;case"day":S.setDate(S.getDate()+1);break;case"week":S.setDate(S.getDate()+7);break;case"month":S.setMonth(S.getMonth()+1);break;case"quarter":S.setMonth(S.getMonth()+3);break;default:S.setFullYear(S.getFullYear()+1);break}return S.getTime()}function o(k,y,S){const R=j(k),O=x(k),F=y?y.length:S;let E=1/0,T=-1/0,L=0,C=0;for(let D=0;D<F;D++){const $=y?y[D]:D;if(O&&!O($)){L++;continue}const P=R($);if(!Number.isFinite(P)){L++;continue}P<E&&(E=P),P>T&&(T=P),C++}return{min:E,max:T,nulls:L,finite:C}}function d(k,y,S,R){const O=j(k),F=x(k),E=y?y.length:S,T=E>R?E/R:1,L=[];for(let D=0;D<E;D+=T){const $=y?y[Math.floor(D)]:Math.floor(D);if(F&&!F($))continue;const P=O($);Number.isFinite(P)&&L.push(P)}const C=Float64Array.from(L);return C.sort(),C}function l(k,y,S,R={}){const O=R.kind||w(k,R.type);return O==="none"||!k?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?i(k,y,S):O==="category"?m(k,y,S,R):c(k,y,S,O,R)}function i(k,y,S){const R=x(k);let O=0;if(R){const E=y?y.length:S;for(let T=0;T<E;T++)R(y?y[T]:T)||O++}const F=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&F.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:F}}function m(k,y,S,R){const O=R.cardinalityLimit??H,{cardinality:F}=u(k,y,S,O);if(F>O&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:F};const E=B(k),T=y?y.length:S,L=new Map;let C=0;for(let N=0;N<T;N++){const G=E(y?y[N]:N);if(G==null||G===""){C++;continue}if(Array.isArray(G)){if(!G.length){C++;continue}for(const q of G)L.set(q,(L.get(q)||0)+1);continue}L.set(G,(L.get(G)||0)+1)}let D=[...L.entries()];R.order==="alpha"?D.sort((N,G)=>String(N[0]).localeCompare(String(G[0]))):D.sort((N,G)=>G[1]-N[1]);let $=0,P=0;if(D.length>O){P=D.length-O;for(let N=O;N<D.length;N++)$+=D[N][1];D=D.slice(0,O)}const v=D.map(([N])=>({value:N,label:String(N)}));return $>0&&v.push({remainder:!0,label:`Other (${P} values)`}),C>0&&v.push({null:!0,label:"Empty"}),{kind:"category",buckets:v,cardinality:F}}function c(k,y,S,R,O){const{min:F,max:E,nulls:T,finite:L}=o(k,y,S);if(!L)return{kind:R,buckets:T?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(O.buckets||V));let D=[];if(R==="date"){const P=W.includes(O.granularity)?O.granularity:r(E-F,C);let v=t(F,P);for(;v<=E&&D.length<4096;){const N=n(v,P);if(!(N>v))break;D.push({from:v,to:N}),v=N}return{kind:R,buckets:f(D,T),granularity:P}}const $=X.includes(O.strategy)?O.strategy:"equal";if($==="quantile"){const P=d(k,y,S,z);if(P.length){const v=[P[0]];for(let N=1;N<C;N++){const G=P[Math.min(P.length-1,Math.floor(N/C*P.length))];G>v[v.length-1]&&v.push(G)}v.push(E);for(let N=0;N<v.length-1;N++)D.push({from:v[N],to:v[N+1]})}}else if($==="log"&&F>0){const P=Math.log10(F),N=(Math.log10(E)-P)/C||1;for(let G=0;G<C;G++)D.push({from:10**(P+G*N),to:10**(P+(G+1)*N)})}if(!D.length){const P=(E-F)/C||1;for(let v=0;v<C;v++)D.push({from:F+v*P,to:F+(v+1)*P})}return D[D.length-1].to=E,{kind:R,buckets:f(D,T),strategy:$,min:F,max:E}}function f(k,y){return y>0?[...k,{null:!0,label:"Empty"}]:k}function s(k,y,S,R,O){const F=R&&R.buckets||[],E=O&&O.length>=F.length?O.subarray(0,F.length):new Uint32Array(F.length);if(E.fill(0),!k||!F.length)return E;const T=F.length-1,L=!!F[T]&&F[T].null===!0,C=y?y.length:S;if(R.kind==="boolean"){const N=B(k);for(let G=0;G<C;G++){const q=N(y?y[G]:G);if(q==null){L&&E[T]++;continue}E[q?1:0]++}return E}if(R.kind==="category"){const N=new Map;for(let Z=0;Z<F.length;Z++)!F[Z].null&&!F[Z].remainder&&N.set(F[Z].value,Z);const G=F.findIndex(Z=>Z.remainder),q=B(k);for(let Z=0;Z<C;Z++){const J=q(y?y[Z]:Z);if(J==null||J===""){L&&E[T]++;continue}if(Array.isArray(J)){if(!J.length){L&&E[T]++;continue}for(const ne of J){const ie=N.get(ne);ie!==void 0?E[ie]++:G>=0&&E[G]++}continue}const ee=N.get(J);ee!==void 0?E[ee]++:G>=0&&E[G]++}return E}const D=L?F.length-1:F.length,$=new Float64Array(D+1);for(let N=0;N<D;N++)$[N]=F[N].from;$[D]=D?F[D-1].to:0;const P=j(k),v=x(k);for(let N=0;N<C;N++){const G=y?y[N]:N;if(v&&!v(G)){L&&E[T]++;continue}const q=P(G);if(!Number.isFinite(q)){L&&E[T]++;continue}const Z=p($,D,q);Z>=0&&E[Z]++}return E}function p(k,y,S){if(!y||S<k[0])return-1;if(S>=k[y])return S===k[y]?y-1:-1;let R=0,O=y-1;for(;R<O;){const F=R+O+1>>>1;S>=k[F]?R=F:O=F-1}return R}function b(k,y,S,R={}){const O=R.bounds||l(k,R.boundsIndices??y,S,R);return{bounds:O,counts:s(k,y,S,O)}}const A=b}),Le("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const x=K("packages/core/src/compute/handle.js").valueComparator,I=K("packages/core/src/compute/total.js").total,X=K("packages/core/src/compute/group.js").packKeys,W=K("packages/core/src/compute/pivot.js"),V=W.joinPath,H=W.DEFAULT_PATH_SEPARATOR,z=W.DEFAULT_MAX_COLUMNS,w="";function j(n,o,d={}){const l=d.separator||H,i=n||[],m=o instanceof Uint32Array?o:Uint32Array.from(o||[]),c=m.length;if(i.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:f,readers:s}=X(i,m,0),p=new Map,b=[],A=[],k=[];for(let E=0;E<c;E++){const T=m[E],L=f(T);let C=p.get(L);if(C===void 0){C=b.length,p.set(L,C),A.push(L);const D=new Array(s.length);for(let $=0;$<s.length;$++)D[$]=s[$](T);b.push(D),k.push([])}k[C].push(T)}const y=x(d.locale),S=b.map((E,T)=>T);S.sort((E,T)=>{const L=b[E],C=b[T];for(let D=0;D<L.length;D++){const $=g(L[D],C[D],y);if($!==0)return $}return E-T});const R=new Array(S.length),O=new Array(S.length),F=new Array(S.length);for(let E=0;E<S.length;E++){const T=S[E];R[E]=b[T],O[E]=V(b[T],l),F[E]=Uint32Array.from(k[T])}return{tuples:R,paths:O,buckets:F}}function g(n,o,d){const l=n==null,i=o==null;return l||i?l&&i?0:l?1:-1:d(n,o)}function u(n,o,d){const l=[];for(let i=0;i<n.length;i++)d.has(n[i])&&l.push(n[i]);return Uint32Array.from(l)}function h(n,o,d,l){return{value:o.length?I(n,o,d,l):null,leaves:o,count:o.length}}function a(n){const o=n&&n.opts||{},d=o.separator||H,l=o.totalContext||{locale:o.locale},i=(n.measures||[]).filter(O=>O&&O.handle),m=n.leaves instanceof Uint32Array?n.leaves:Uint32Array.from(n.leaves||[]),c=j(n.rowHandles||[],m,{...o,separator:d}),f=j(n.columnHandles||[],m,{...o,separator:d}),s=o.maxColumns===void 0?z:o.maxColumns,p=f.paths.length*Math.max(1,i.length),b=new Map;if(s&&p>s)return{rowAxis:c,columnAxis:f,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:b,rowMargin:b,columnMargin:b,grand:b,columns:p,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${p} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:p,maxColumns:s}};const A=new Map,k=new Map,y=new Map,S=new Map,R=f.buckets.map(O=>new Set(O));for(let O=0;O<f.paths.length;O++){const F=f.buckets[O],E=f.paths[O];for(const T of i)y.set(t(E,T.colId),h(T.handle,F,T.fn,l))}for(let O=0;O<c.paths.length;O++){const F=c.buckets[O],E=c.paths[O];for(const T of i)k.set(t(E,T.colId),h(T.handle,F,T.fn,l));for(let T=0;T<f.paths.length;T++){const L=u(F,f.buckets[T],R[T]);if(L.length===0)continue;const C=f.paths[T];for(const D of i)A.set(r(E,C,D.colId),h(D.handle,L,D.fn,l))}}for(const O of i)S.set(O.colId,h(O.handle,m,O.fn,l));return{rowAxis:c,columnAxis:f,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:A,rowMargin:k,columnMargin:y,grand:S,columns:p,error:null}}function r(n,o,d){return`${n}\0${o}\0${d}`}function t(n,o){return`${n}\0${o}`}}),Le("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const x=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),I=B.isMissing,_=B.valueComparator,W=K("packages/core/src/compute/filter.js").testValue,V="",H="\0";function z(n,o){const d=o.includes(".")?x(n,o):n?.[o];return d===void 0?null:d}function w(n,o,d={}){const l=o||[];let i=n.map((m,c)=>c);if(l.length===0)return i;for(let m=l.length-1;m>=0;m--)i=j(n,i,l[m],d);return i}function j(n,o,d,l){const i=d.locale!==void 0?d.locale:l.locale,m=_(i),c=d.descending!==void 0?!!d.descending:d.dir==="desc",f=[],s=[];for(const A of o){const k=z(n[A],d.col);I(k)?s.push(A):f.push(A)}const p=new Map;for(let A=0;A<f.length;A++)p.set(f[A],A);const b=(A,k)=>{const y=z(n[A],d.col),S=z(n[k],d.col);let R;return typeof d.compare=="function"?(R=d.compare(y,S,n[A],n[k],c),c&&(R=-R)):R=c?m(S,y):m(y,S),R!==0?R:p.get(A)-p.get(k)};return f.sort(b),d.nullsFirst?s.concat(f):f.concat(s)}function g(n,o,d={}){const l=[];for(let i=0;i<n.length;i++)u(n[i],o,d,i)&&l.push(i);return l}function u(n,o,d,l){if(!o)return!0;if(Array.isArray(o.conditions)){const i=o.conditions.filter(c=>c!=null);if(i.length===0)return!0;if(o.op==="or")return i.some(c=>u(n,c,d,l));const m=i.every(c=>u(n,c,d,l));return o.op==="not"?!m:m}return o.col===void 0&&typeof d.custom=="function"?!!d.custom(o,n,l):W(z(n,o.col),o,d.locale)}function h(n,o,d,l){const i=d||n.map((s,p)=>p),m=new Map,c=[],f=[];for(const s of i){const p=o.map((k,y)=>{const S=z(n[s],k);return l&&l[y]?l[y](S):S}),b=p.map(k=>k==null?H:String(k)).join(V);let A=m.get(b);A===void 0&&(A=c.length,m.set(b,A),c.push(p),f.push([])),f[A].push(s)}return{keys:c,buckets:f}}function a(n,o,d={}){const l=_(d.locale),i=n.filter(c=>!I(c)),m=i.map(r).filter(c=>c!==null);switch(o){case"count":return n.length;case"countValues":return i.length;case"sum":return m.reduce((c,f)=>c+f,0);case"avg":return i.length===0?null:m.reduce((c,f)=>c+f,0)/i.length;case"min":return i.length===0?null:i.reduce((c,f)=>l(f,c)<0?f:c);case"max":return i.length===0?null:i.reduce((c,f)=>l(f,c)>0?f:c);case"first":return n.length===0?null:t(n[0]);case"last":return n.length===0?null:t(n[n.length-1]);default:return null}}function r(n){if(typeof n=="number")return Number.isNaN(n)?null:n;if(n==null||n===""||typeof n=="boolean")return null;if(n instanceof Date)return n.getTime();const o=Number(n);return Number.isNaN(o)?null:o}function t(n){return n===void 0?null:n}}),Le("packages/core/src/compute/index.js",function(e,K){"use strict";const Q=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Q.rankSortStrings}});const x=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return x.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return x.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return x.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return x.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return x.describeSort}});const B=K("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return B.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return B.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return B.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return B.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return B.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return B.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return B.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return B.mentionsColumn}});const I=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return I.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return I.packKeys}});const _=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const X=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return X.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return X.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return X.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return X.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return X.collectValues}});const W=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return W.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return W.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return W.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return W.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return W.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return W.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return W.DEFAULT_MAX_COLUMNS}});const V=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return V.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return V.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return V.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return V.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return V.GRAND_PATH}});const H=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return H.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return H.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return H.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return H.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return H.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return H.referenceValue}});const z=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return z.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return z.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return z.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return z.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return z.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return z.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return z.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return z.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return z.isMissing}});const w=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return w.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return w.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return w.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return w.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return w.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return w.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w.SKETCH_BOUNDS}});const j=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return j.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return j.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return j.openWindow}});const g=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return g.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return g.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return g.maintenanceOf}});const u=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const h=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return h.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return h.forecast}})}),Le("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isFunction,I=32,_="\0";function X(h){return new W(h)}class W{#e;#t;constructor(a){this.#e=B(a&&a.rowKey)?a.rowKey:null;const r=a&&a.config?a.config.rowHeight:void 0;this.#t=typeof r=="number"||B(r)?r:I}get keyed(){return this.#e!==null}keyOf(a,r){if(this.#e){const t=this.#e(a);if(t!=null)return String(t)}else x("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${r}`}heightOf(a){return B(this.#t)?Number(this.#t(a))||I:this.#t}leaf(a,r,t=0,n=null){const o={key:this.keyOf(a,r),data:a,level:t,parent:n,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:r};return o.height=this.heightOf(o),o}group(a){const r={key:g(a.keyPath||a.path),data:null,level:a.level,parent:a.parent||null,children:[],group:!0,expanded:a.expanded!==!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.column,groupValue:a.value,groupPath:a.path,hasChildren:a.hasChildren!==!1};return a.totals&&(r.totals=a.totals),r.height=this.heightOf(r),r}footer(a){const r={key:`${a.key}${_}footer`,data:null,level:a.level,parent:a,group:!0,footer:!0,expanded:!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.groupColumn,groupValue:a.groupValue,groupPath:a.groupPath,hasChildren:!1,totals:a.totals};return r.height=this.heightOf(r),r}detail(a,r){return{key:`${a.key}${_}detail`,data:a.data,level:a.level+1,parent:a,group:!1,detail:!0,expanded:!1,leafCount:0,height:r,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:a.key}}grandTotal(a,r){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:r,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:a};return t.height=this.heightOf(t),t}skeleton(a,r=0,t=!1){const n={key:`${_}pending${_}${a}`,data:null,level:r,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:a,selected:!1,physical:null,pending:!0};return t&&(n.loadError=!0),n.height=this.heightOf(n),n}}function V(h,a,r,t){return{key:`${_}pinned${_}${r}${_}${a}`,data:h,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:r}}function H(h,a){return new Proxy([],{get(r,t,n){if(t==="length")return h();if(typeof t=="string"){const o=Number(t);if(Number.isInteger(o)&&o>=0)return a(o)}return Reflect.get(r,t,n)},has(r,t){if(typeof t=="string"){const n=Number(t);if(Number.isInteger(n)&&n>=0)return n<h()}return Reflect.has(r,t)}})}function z(h){return h==null?"":String(h)}const w="";function j(h){if(h==null)return w;const a=String(h);return a.startsWith(w)?w+a:a}function g(h){const a=h||[];let r="g";for(let t=0;t<a.length;t++)r+=_+j(a[t]);return r}function u(h){const a=new Array(h.length),r=[];for(let t=0;t<h.length;t++)r.push(h[t]),a[t]=g(r);return a}}),Le("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce;class I{#e;#t;#n;#r=new Map;#o=0;constructor(W,V,H){this.#e=W,this.#t=V,this.#n=x(H)?H:()=>!1}get store(){const W=this.#e.store;return W&&x(W.column)?W:null}invalidate(){this.#o++}handle(W){const V=this.store;if(V){const j=V.column(W);if(j)return j}const H=this.#r.get(W);if(H&&H.builtAt===this.#o)return H.handle;const z=this.#i(W);if(!z)return;if(V&&this.#n()){B(`source.dropped.${W}`,`column "${W}" 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 w=this.#s(z);return this.#r.set(W,{handle:w,builtAt:this.#o}),w}#i(W){const V=this.#e.columns;return V&&x(V.get)?V.get(W):void 0}#s(W){const V=this.#t()||[],H=V.length,z=new Array(H),w=x(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<H;g++)z[g]=V[g]===void 0?void 0:w(V[g]);const j=this.#o;return{id:W.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(g){return z[g]},version:j}}}function _(X,W,V){return new I(X,W,V)}}),Le("packages/core/src/compute/incremental.js",function(e,K){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),I=Object.freeze(["float64"]),_=1e15;function X(z,w){return typeof z!="string"||!B.includes(z)?!1:!!w&&I.includes(w.kind)}function W(z){if(z==null)return null;const w=x(z);return Number.isNaN(w)?null:w}class V{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(w){this.#e=w}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(w){this.#a();for(let j=0;j<w.length;j++){const g=W(w[j]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,j,g){this.#a();for(let u=0;u<g.length;u++){const h=g[u];if(j&&j(h)===0)continue;const a=w[h];Number.isNaN(a)||this.#u(a)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(w){if(!Number.isFinite(w)){this.#l=!0;return}const j=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-j+w:w-j+this.#t,this.#t=j,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const j=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-j-w:-w-j+this.#t,this.#t=j,this.#r--}update(w,j){if(!this.#s)return!1;const g=W(w),u=W(j);return g===null&&u===null?!0:g!==null&&!Number.isFinite(g)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?g===null||u===null?!1:this.#e==="min"?u<this.#o?(this.#o=u,!0):g>this.#o:u>this.#i?(this.#i=u,!0):g<this.#i:Math.abs(this.#t)>_?!1:(g!==null&&this.#c(g),u!==null&&this.#u(u),!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.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const H=V}),Le("packages/core/src/source/filterwire.js",function(e,K){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return y}});const x=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",I="source.where.pageRelative";function _(O,F){!Array.isArray(O)||!O.length||x(I,`filters.where (${O.join(", ")}) runs over the rows the ${F} 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 X(O){const F=(O||{}).config;!F||!F.hostFilter||x(B,"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 W="source.where.notApplied";function V(O,F){x(`${W}:${O}`,`filters.where("${O}") is registered but the ${F} 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 H="source.where.overThreshold";function z(O,F,E,T){!Array.isArray(O)||!O.length||x(`${H}:${F}`,`filters.where (${O.join(", ")}) is not applied to the ${F} pushdown source:`,E===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${E.toLocaleString()} rows, at or past the whereRowLimit of ${T.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 w=new Map;function j(O){let F=w.get(O);return F||(F=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(O,F)),F}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(O,F){const E=j(F).formatToParts(new Date(O)),T={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of E)L.type==="year"?T.y=+L.value:L.type==="month"?T.m=+L.value:L.type==="day"?T.d=+L.value:L.type==="hour"?T.h=+L.value%24:L.type==="minute"?T.mi=+L.value:L.type==="second"&&(T.s=+L.value);return T}function h(O,F){const E=u(O,F);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(O/1e3)*1e3}function a(O,F,E,T){const L=Date.UTC(O,F-1,E),C=L-h(L,T);return L-h(C,T)}function r(O,F,E){const T=new Date(Date.UTC(O.y,O.m-1,O.d+F));return a(T.getUTCFullYear(),T.getUTCMonth()+1,T.getUTCDate(),E)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function n(O,F){if(typeof O!="string")return null;const E=O.trim().toLowerCase().replace(/[\s_-]+/g,""),T=/^last(\d*|n)days?$/.exec(E);if(T){const L=T[1]==="n"?"":T[1],C=Number(L||F);return!Number.isFinite(C)||C<=0?null:{kind:"lastNDays",n:Math.floor(C)}}switch(E){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 o(O,F={}){const E=n(O,F.n);if(!E)return null;const T=F.tz||g(),L=F.now instanceof Date?F.now.getTime():typeof F.now=="number"?F.now:Date.now(),C=u(L,T),D=a(C.y,C.m,C.d,T),$=r(C,1,T);let P=D,v=$;switch(E.kind){case"today":break;case"yesterday":P=r(C,-1,T),v=D;break;case"lastNDays":v=F.includeToday?$:D,P=r(C,F.includeToday?-(E.n-1):-E.n,T);break;case"thisWeek":{const N=Number.isFinite(F.weekStartsOn)?Number(F.weekStartsOn):1,q=(new Date(Date.UTC(C.y,C.m-1,C.d)).getUTCDay()-N+7)%7;P=r(C,-q,T),v=r(C,-q+7,T);break}case"thisMonth":P=a(C.y,C.m,1,T),v=a(C.m===12?C.y+1:C.y,C.m===12?1:C.m+1,1,T);break;case"thisQuarter":case"quarterToDate":{const N=Math.floor((C.m-1)/3)*3+1;P=a(C.y,N,1,T),v=E.kind==="quarterToDate"?$:N===10?a(C.y+1,1,1,T):a(C.y,N+3,1,T);break}case"thisYear":case"yearToDate":P=a(C.y,1,1,T),v=E.kind==="yearToDate"?$:a(C.y+1,1,1,T);break;default:return null}return{from:new Date(P).toISOString(),to:new Date(v).toISOString(),bounds:"[)",tz:T,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function d(O){if(!O||typeof O!="object")return null;const F=O.value;if(F&&typeof F=="object"&&!Array.isArray(F)&&"relative"in F)return{token:String(F.relative),n:typeof F.n=="number"?F.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const E=O.meta;return E&&typeof E.relative=="string"&&O.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.n:void 0}:null}function l(){return`Known tokens: ${t.filter(F=>F!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(O){const F=d(O);return F?n(F.token,F.n)!==null:!1}function m(O,F={}){const E=d(O);if(!E)return O;const T=o(E.token,{...F,n:E.n});return T?{...O,type:O.type||"date",op:"between",value:[T.from,T.to],bounds:O.bounds||T.bounds,meta:{...O.meta||{},relative:T.relative,tz:T.tz}}:(x(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,l()),O)}function c(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function f(O,F){if(O){if(c(O)){for(const E of O.conditions)f(E,F);return}F(O)}}function s(O,F){if(!O)return null;if(!c(O))return F(O);const E=O;let T=!1;const L=[];for(const C of E.conditions){const D=s(C,F);D!==C&&(T=!0),D&&L.push(D)}return!T&&L.length===E.conditions.length?O:L.length?{...E,conditions:L}:null}function p(O){if(!O)return null;if(!c(O))return O;const F=O,E=[];for(const T of F.conditions){const L=p(T);L&&E.push(L)}return E.length?{op:F.op,conditions:E}:null}function b(O){const F=p(O);return F?c(F)&&F.op==="and"?F:{op:"and",conditions:[F]}:null}function A(O){const F=(O||[]).filter(Boolean);return F.length?{op:"and",conditions:F}:null}function k(O,F={}){const E=s(O,T=>m(T,F));return b(E)}function y(O){const F=S(O.filters??null);return JSON.stringify([F,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,R(O.context)])}function S(O){if(!O)return null;if(c(O)){const T=O;return{op:T.op,conditions:T.conditions.map(S)}}const F=O,E=F.meta&&typeof F.meta.relative=="string"?F.meta.relative:d(F)?.token;return{col:F.col,op:F.op,bounds:F.bounds??null,caseSensitive:F.caseSensitive??!1,value:E?`rel:${E}`:F.value??null}}function R(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return x("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Le("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I="",_="\0tree:";function X(u,h){return{physical:u,key:h,level:0,children:[],value:void 0}}function W(u,h){const a=[],r=new Map;for(let t=0;t<u.length;t++){const n=u[t],o=h.pathOf(n),d=Array.isArray(o)?o.map(i=>String(i)):[];if(!d.length){const i=X(n,h.keyOf(n));a.push(i);continue}let l=null;for(let i=0;i<d.length;i++){const m=d.slice(0,i+1).join(I),c=i===d.length-1;let f=r.get(m);f&&c&&f.physical===-1&&(f.physical=n,f.key=h.keyOf(n)),f||(f=X(c?n:-1,c?h.keyOf(n):_+m),f.level=i,f.value=d[i],r.set(m,f),l?l.children.push(f):a.push(f)),l=f}}return{roots:a,nodes:r}}function V(u,h){const a=new Map,r=[];for(let d=0;d<u.length;d++){const l=u[d],i=h.keyOf(l),m=X(l,i);a.set(i,m);const c=h.parentOf(l);c!=null&&c!==""&&r.push({node:m,parent:String(c)})}let t=null;const n=new Map;for(const{node:d,parent:l}of r){const i=a.get(l);if(i){n.set(d.key,i);continue}h.orphans&&h.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=h.orphans),n.set(d.key,t))}const o=[];for(const d of a.values()){const l=n.get(d.key);l?l.children.push(d):o.push(d)}return t&&t.children.length&&o.push(t),{roots:H(o,a,h.orphans,t),nodes:a}}function H(u,h,a,r){const t=new Set,n=[...u];for(;n.length;){const m=n.pop();if(!t.has(m.key)){t.add(m.key);for(const c of m.children)n.push(c)}}const o=[];for(const m of h.values())t.has(m.key)||o.push(m);if(!o.length)return u;const d=!!a&&a!=="root";B("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(d?`they are shown under "${a}".`:"they are shown at the root."));for(const m of o)m.children=m.children.filter(c=>t.has(c.key));if(!d)return[...u,...o];let l=r;const i=[...u];return l||(l=X(-1,`${_}orphans`),l.value=a,i.push(l)),l.children.push(...o),i}function z(u){let h=0;const a=(r,t)=>{for(const n of r)n.level=t,t>h&&(h=t),n.children.length&&a(n.children,t+1)};return a(u,0),h}function w(u,h){if(!u||typeof u!="object")return null;const a=u.path,r=u.parentKey,t=x(u.hasChildren)?n=>!!u.hasChildren(h.dataAt(n)):null;if(x(a))return{mode:"path",pathOf:n=>a(h.dataAt(n)),keyOf:h.keyOf,declaresChildren:t};if(r!=null){const n=x(r)?r:o=>o?.[r];return{mode:"parentKey",parentOf:o=>n(h.dataAt(o)),keyOf:h.keyOf,orphans:u.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function j(u,h){const a=h.mode==="path"?W(u,h):V(u,h),r=z(a.roots);return{...a,depth:r}}function g(u,h){const a=new Map,r=t=>{for(let n=0;n<t.length;n++){const o=t[n];if(o.physical>=0){const d=h?h(o.physical):!1,l=d&&o.children.length===0;a.set(o.physical,{level:o.level,posinset:n+1,setsize:t.length,hasChildren:o.children.length>0||d,lazy:l})}o.children.length&&r(o.children)}};return r(u),a}}),Le("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.warnOnce,I=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,V=K("packages/core/src/source/rows.js"),H=V.createRowFactory,z=V.groupKey,w=V.groupPathElement,j=V.groupPrefixKeys,g=V.lazyRowView,h=K("packages/core/src/source/handles.js").createHandleProvider,a=K("packages/core/src/compute/incremental.js"),r=a.RunningTotal,t=a.isIncremental,o=K("packages/core/src/compute/handle.js").presenceReader,d=K("packages/core/src/source/filterwire.js"),l=d.querySignature,i=d.mapConditions,m=d.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),f=c.buildTree,s=c.resolveTree,p=c.indexTree,b=Object.freeze(["filter","sort","group","total","pivot","flatten"]),A=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function k(P){const v=P&&typeof P=="object"?P.reason:null;return typeof v=="string"&&A.includes(v)}const y=Object.freeze([]);function S(P,v){if(!P)return null;const N=v==="grand"?P.grandTotal:P.groupTotal;return N??P.total}function R(P){return!!P&&!P.running}function O(P){if(P)return P.value&&_(P.value.compare)?P.value.compare:_(P.compare)?P.compare:void 0}function F(P){const v=P&&P.dataType;return!v||!_(v.items)?null:{items:v.items,type:P.itemType&&P.itemType.name||"text"}}function E(P){return!!P&&(typeof P=="object"||typeof P=="function")&&_(P.then)}const T=new Uint32Array(0),L=4096;function C(P,v){return new $(P,v)}function D(P,v){if(v==="regex")try{const N=new RegExp(P,"iu");return G=>N.test(G)}catch{return N=>N.includes(P)}if(v==="fuzzy"){const N=[...P].filter(G=>G!==" ");return N.length?G=>{let q=0;for(let Z=0;Z<G.length&&q<N.length;Z++)G[Z]===N[q]&&q++;return q===N.length}:()=>!0}if(v==="words"){const N=P.split(/\s+/).filter(Boolean);return N.length?G=>N.every(q=>G.includes(q)):()=>!0}return N=>N.includes(P)}class ${mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#p=null;#m=$.#g();static#g(){return{slots:[],groupHeadings:y,unnumbered:y,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#w=null;#O=new Map;#y=-1;#A=[];#k=new Map;#C=-1;#S=[];#E=null;#T=null;#P=null;#M=null;#N=null;#$=null;#z=null;#H=null;#B=Symbol("unset");#L=new Map;#I=null;get#D(){return this.#m.slots}set#D(v){this.#m.slots=v}get#_(){return this.#m.inlineLeaves}set#_(v){this.#m.inlineLeaves=v}get#X(){return this.#m.groupHeadings}set#X(v){this.#m.groupHeadings=v}get#ue(){return this.#m.unnumbered}set#ue(v){this.#m.unnumbered=v}get#se(){return this.#m.pivot}set#se(v){this.#m.pivot=v}constructor(v,N){this.#t=v||{mode:"memory"},this.#e=N||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=H(this.#e),this.#s=h(this.#e,()=>this.#n,()=>this.#r),this.#f=new x(Number(G.rowCacheSize)||L);for(const q of b)this.#l.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#Z();const v=this.#ae();return v?v.length:this.#D.length}#ae(){const v=Number(this.#G("pageSize",0))||0;if(v<=0)return null;const N=this.#D.length,G=Math.max(1,Math.ceil(N/v)),Z=Math.min(Math.max(0,Number(this.#G("page",0))||0),G-1)*v;return{offset:Z,length:Math.max(0,Math.min(v,N-Z))}}pageInfo(){this.#Z();const v=Number(this.#G("pageSize",0))||0,N=this.#D.length;if(v<=0)return{page:0,pageSize:0,total:N,pageCount:1};const G=Math.max(1,Math.ceil(N/v));return{page:Math.min(Math.max(0,Number(this.#G("page",0))||0),G-1),pageSize:v,total:N,pageCount:G}}totalCount(){return this.#Ie().length}matchCount(){return this.#Z(),this.#m.matchCount}at(v){this.#Z();const N=this.#ae();if(N)return v<0||v>=N.length?void 0:this.#qe(N.offset+v,v);if(!(v<0||v>=this.#D.length))return this.#qe(v,v)}byKey(v){this.#Z(),this.#p||this.#J();const N=this.#p.get(v);if(N!==void 0)return this.#Ee(N);for(let G=0;G<this.#D.length;G++){const q=this.#D[G];if(typeof q!="number"&&q&&q.key===v)return this.#qe(G)}}loaded(v){return v>=0&&v<this.count()}hint(v,N){}display(){return this.#Z(),this.#I||(this.#I=this.#Lt()),this.#I}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(v){const N=b.indexOf(v);N<0&&I(`unknown pipeline stage "${v}"; expected one of ${b.join(", ")}`);for(let G=N;G<b.length;G++){const q=this.#l.get(b[G]);q.key=null,q.computed=!1}this.#I=null}apply(v){const N=[],G={added:[],updated:[],removed:[],rejected:N};if(!v)return G;let q=!1;const Z=new Set;if(v.remove&&v.remove.length)for(const J of v.remove){const ee=this.#Y(J);if(ee===void 0){N.push({operation:"remove",id:this.#me(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#Ne(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#f.delete(ee),this.#L.delete(ee),q=!0}if(v.update&&v.update.length){const J=this.#O.size||this.#ot()?this.#ut():null,ee=this.#k.size?this.#ft():null,ne=ee&&ee.length?this.#ut():null;for(const ie of v.update){const se=this.#Y(ie);if(se===void 0){N.push({operation:"update",id:this.#te(ie),reason:"unknown-id"});continue}const he=this.#r?this.#o&&this.#o.has(se)?this.#o.get(se):this.#Ne(se):this.#n[se],ce=W(he,ie);for(const te of this.#q(he,ce))Z.add(te);if(this.#r||(this.#n[se]=ce),J&&this.#Ct(J,se,he,ce),ne&&this.#et(ee,ne,se,he,ce),this.#p){const te=this.#i.keyOf(he,se),oe=this.#i.keyOf(ce,se);te!==oe&&(this.#p.delete(te),this.#p.set(oe,se))}this.#f.delete(se),this.#L.delete(se),G.updated.push(this.#Ee(se))}}if(v.add&&v.add.length&&this.#r){typeof v.at=="number"&&v.at<this.#at()&&(this.#f.clear(),this.#L.clear()),this.#p=null;for(const J of v.add){const ee=this.#V(this.#te(J));ee!==void 0&&G.added.push(this.#Ee(ee))}q=!0}else if(v.add&&v.add.length){const J=typeof v.at=="number"?v.at:this.#n.length,ee=this.#n.length;let ne=v.add===this.#n?v.add.slice():v.add;if(this.#i.keyed){const ie=[];for(const se of ne){const he=this.#te(se);if(this.#Y(he)!==void 0){N.push({operation:"add",id:he,reason:"duplicate-id"});continue}ie.push(se)}ie.length!==ne.length&&(ne=ie)}if(!ne.length)return G;if(J>=ee)for(let ie=0;ie<ne.length;ie++)this.#n.push(ne[ie]);else this.#n.splice(J,0,...ne),this.#f.clear(),this.#L.clear();for(let ie=0;ie<ne.length;ie++)G.added.push(this.#Ee(J>=ee?ee+ie:J+ie));q=!0}return this.#u++,q&&(this.#p=null,this.#xe()),this.#s.invalidate(),this.#I=null,q||this.#ne(Z)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Ve("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(v){this.#Z();const N=this.#X;if(!N.length||!Number.isInteger(v)||v<0)return y;let G=0,q=N.length-1,Z=-1;for(;G<=q;){const ee=G+q>>1;N[ee].at<=v?(Z=ee,G=ee+1):q=ee-1}if(Z<0)return y;const J=[];for(let ee=N[Z].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(v){this.#Z();const N=this.#ue;if(!N.length||!Number.isInteger(v)||v<0)return 0;let G=0,q=N.length-1,Z=-1;for(;G<=q;){const J=G+q>>1;N[J].at<=v?(Z=J,G=J+1):q=J-1}return Z+1}moveRow(v,N){if(this.#r)return B("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 G=this.#n;if(!Number.isInteger(v)||!Number.isInteger(N)||v<0||v>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,N));if(q===v)return!1;const[Z]=G.splice(v,1);return G.splice(q,0,Z),this.#u++,this.#c++,this.#p=null,this.#f.clear(),this.#L.clear(),this.#xe(),this.#s.invalidate(),this.#I=null,this.invalidate("filter"),this.#Ve("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(v){this.#ge(),this.#u++,this.#c++,this.#p=null,this.#L.clear(),this.#f.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter"),this.#Ve("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#f.clear(),this.#L.clear(),this.#p=null,this.#D=[],this.#_=null,this.#I=null,this.#xe();for(const v of b)this.#l.set(v,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:v}of this.#b.values())try{v.abort()}catch{}this.#b.clear()}setRows(v){this.#n=v||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#L.clear(),this.#f.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(v){this.#o=v||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#f.clear(),this.#L.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const v=this.#e.store;if(!v||!_(v.source))return this.#n;const N=v.physical||0,G=new Array(N);for(let q=0;q<N;q++)G[q]=v.live&&!v.live(q)?void 0:v.source(q);return G}#Te(){const v=this.#G("detail",null);return!v||!_(v.isOpen)||v.inline===!1?null:v}#Se(){const v=(this.#e.config||{}).tree;return this.#B!==v&&(this.#B=v,this.#H=s(v,{dataAt:N=>this.#Ne(N),keyOf:N=>this.#i.keyOf(this.#Ne(N),N)})),this.#H}#re(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#re())return null;this.#Z();const v=this.#m.grand;return v?this.#i.grandTotal(v,this.#tt(this.#m.grandLeaves)):null}pivot(){return this.#Z(),this.#se}pivotMatrix(){this.#Z();const v=this.#m.groupLeaves,N=(this.#e.compute||{}).pivotMatrix;if(!_(N))return null;const G=this.#G("groupBy",[]),q=this.#G("pivotBy",[]);if(!G.length&&!q.length)return B("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 Z=this.#ut().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:S(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return N({rowHandles:G.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:Z,leaves:v||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(v){const N=[];if(!v)return N;for(let G=0;G<v.length;G++){const q=this.#Ee(v[G]);q&&q.key!=null&&N.push(String(q.key))}return N}leavesOf(v){this.#Z();const N=this.#l.get("group"),G=N&&N.result;if(!G||!G.nodes)return[];const q=G.nodes.get(v);if(!q)return[];const Z=[],J=ee=>{const ne=ee.row&&ee.row.children;if(ne&&ne.length){for(const ie of ne){const se=G.nodes.get(ie.key);se&&J(se)}return}if(ee.leaves)for(let ie=0;ie<ee.leaves.length;ie++)Z.push(this.#Ee(ee.leaves[ie]))};return J(q),Z}#me(v){return typeof v=="string"?v:this.#te(v)}#te(v){try{return this.#i.keyOf(v,-1)}catch{return"(unkeyed)"}}#Y(v){if(typeof v=="string")return this.#V(v);if(this.#i.keyed){const G=this.#i.keyOf(v,-1),q=this.#V(G);if(q!==void 0)return q}if(this.#r)return;const N=this.#n.indexOf(v);return N>=0?N:void 0}#V(v){return this.#p||this.#J(),this.#p.get(v)}#J(){this.#p=new Map;const v=this.#at(),N=this.#e.store,G=N&&_(N.live)?q=>N.live(q):null;for(let q=0;q<v;q++){if(G&&!G(q))continue;const Z=this.#Ne(q);Z!==void 0&&this.#p.set(this.#i.keyOf(Z,q),q)}}#q(v,N){const G=[];for(const q of this.#ie())this.#ze(q)&&this.#Ae(q,v,N,new Set)&&G.push(q);return G}#Ae(v,N,G,q){if(q.has(v))return!1;q.add(v);const Z=this.#ze(v);if(!Z)return!1;const J=Z.value&&Z.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#Ae(String(ee),N,G,q)):_(Z.getValue)?!Object.is(Z.getValue(N),Z.getValue(G)):!1}#ie(){const v=new Set;for(const G of this.#G("sort",[]))v.add(G.col);for(const G of this.#G("groupBy",[]))v.add(G);const N=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(N);return}G.col&&v.add(G.col)}};return N(this.#G("filters",null)),[...v]}#ne(v){if(!v.size)return!1;if(this.#G("quick",""))return!0;for(const N of this.#ie())if(v.has(N))return!0;return!1}#Z(){if(!this.#a){this.#a=!0;try{this.#Me()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Me(){const v=this.#ce("filter",()=>this.#K(),()=>this.#ye()),N=this.#pe(v),G=this.#ce("group",()=>this.#Be(),()=>this.#We(N)),q=this.#ce("total",()=>this.#Ge(),()=>this.#Fe(G));this.#ce("pivot",()=>this.#Ke(),()=>this.#He(G)),this.#ce("flatten",()=>this.#je(),()=>this.#st(G)),this.#de(G,q)}#pe(v){const N=this.#l.get("sort"),G=this.#fe();if(N.computed&&N.key===G&&!this.#b.has("sort"))return N.result;const q=this.#b.get("sort");return q&&q.key===G?N.result:N.result&&this.#we(v)?(this.#le(v,G),N.result):this.#ce("sort",()=>G,()=>this.#Pe(v))}#he(){if(this.#w===null){const v=this.#e.pipelineWorker,N=_(v)?v():null;this.#w=N||!1}return this.#w||null}#oe(){const v=this.#G("sort",[]);if(!Array.isArray(v)||!v.length)return null;const N=(this.#e.config||{}).locale,G=[],q=[];for(const Z of v){const J=this.#ze(Z.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const ee=this.#s.handle(Z.col);if(!ee)return null;G.push({col:Z.col,descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:N}),q.push(ee)}return G.length?{entries:G,handles:q,locale:N}:null}#we(v){if(this.#v())return!1;const N=this.#he();if(!N)return!1;const G=Number(N.threshold);return Number.isFinite(G)&&v.length<G?!1:!!this.#oe()}#le(v,N){const G=this.#he(),q=G&&this.#oe();if(!q){this.#ce("sort",()=>N,()=>this.#Pe(v));return}const Z=new AbortController;this.#b.set("sort",{key:N,controller:Z});const J=q.entries.length===1?G.sortColumn(q.handles[0],v,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:Z.signal,key:"sort"}):G.sortMulti(q.handles,q.entries.map((ee,ne)=>({...ee,handle:q.handles[ne]})),v,{signal:Z.signal,key:"sort"});if(!E(J)){this.#b.delete("sort"),this.#ce("sort",()=>N,()=>J);return}J.then(ee=>this.#U(N,ee),ee=>this.#F("sort",N,ee))}#U(v,N){const G=this.#b.get("sort");if(!(!G||G.key!==v)){if(this.#fe()!==v){this.#b.delete("sort");return}this.#b.delete("sort"),this.#ce("sort",()=>v,()=>N),this.#I=null,this.#Z(),this.#Ve("model:changed",{reason:A[0]})}}#F(v,N,G){const q=this.#b.get(v);if(!(!q||q.key!==N)&&(this.#b.delete(v),!(G&&G.name==="AbortError")&&v==="sort"&&this.#fe()===N)){const Z=this.#ce("filter",()=>this.#K(),()=>this.#ye());this.#ce("sort",()=>N,()=>this.#Pe(Z)),this.#I=null,this.#Z(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",G),this.#Ve("model:changed",{reason:A[1]})}}#de(v,N){const G=v&&v.leaves?v.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=N&&N.grand||null,this.#m.grandLeaves=v&&v.leaves?v.leaves.length:0,this.#m.groupLeaves=v&&v.leaves?v.leaves:null}#ce(v,N,G){const q=this.#l.get(v),Z=N();return q.computed&&q.key===Z||(q.result=G(),q.key=Z,q.computed=!0,q.id++,v==="flatten"&&(this.#I=null)),q.result}#R(v){return this.#l.get(v).id}#K(){const v=(this.#e.config||{}).hostFilter,N=v&&_(v.active)&&v.active()?1:0,G=this.#G("where",null),q=G?G.version:0,Z=this.#bt("filter.sig",`${this.#ct()}`,()=>l({filters:this.#G("filters",null),quick:this.#G("quick",""),quickMode:this.#G("quickMode","contains")}));return`${this.#c}|${Z}|${N}|${q}`}#fe(){const v=this.#v();return`${this.#R("filter")}|${JSON.stringify(this.#G("sort",[]))}`+(v?`|manual:${v.version}`:"")}#v(){const v=this.#G("rowOrder",null);return v&&Array.isArray(v.keys)?v:null}#ve(v,N){this.#p||this.#J();const G=this.#p,q=this.#at(),Z=N.keys.length,J=new Float64Array(q);for(let ee=0;ee<q;ee++)J[ee]=Z+ee;for(let ee=0;ee<Z;ee++){const ne=G.get(N.keys[ee]);ne!==void 0&&(J[ne]=ee)}return Uint32Array.from(v).sort((ee,ne)=>J[ee]-J[ne])}orderedKeys(){this.#p||this.#J();const v=this.#p,N=new Map;for(const[ee,ne]of v)N.set(ne,ee);const G=Uint32Array.from([...N.keys()]).sort(),q=this.#v(),Z=q?this.#ve(G,q):this.#Pe(G),J=new Array(Z.length);for(let ee=0;ee<Z.length;ee++)J[ee]=N.get(Z[ee]);return J}#Be(){const v=this.#G("pivotBy",[]).length>0?"p":"u";return`${this.#R("sort")}|${JSON.stringify(this.#G("groupBy",[]))}|${v}`}#Ge(){const v=this.#Ue()?"f":"a",N=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#R("group")}|${JSON.stringify(this.#G("totals",[]))}|${v}${N}|${this.#u}`}#Ke(){return`${this.#R("group")}|${JSON.stringify(this.#G("pivotBy",[]))}`}#je(){const N=this.#Qe()||!this.#re()?this.#R("total"):"x",G=`${this.#ct()}`,q=this.#bt("flatten.keys",G,()=>{const J=this.#G("expanded",null);return J?[...J].sort().join(""):"*"}),Z=this.#bt("flatten.detail",G,()=>{const J=this.#G("detail",null);return J&&_(J.signature)?J.signature():""});return`${N}|${this.#R("pivot")}|${q}|${Z}`}#Qe(){const v=this.#G("groupBy",[]);return Array.isArray(v)&&v.length>0}stageState(){const v=[];for(const[N,G]of this.#l){const q=G.result;v.push({stage:N,materialised:!!G.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:G.id})}return v}facetIndices(v){return this.#ye(v||null)}facetRows(v){const N=this.facetIndices(v),G=[];for(let q=0;q<N.length;q++){const Z=this.#Ee(N[q]);Z&&G.push(Z)}return G}invalidateRows(){this.#f.clear(),this.#L.clear(),this.#I=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ie()}filteredIndices(){const v=this.#l.get("filter");if(v&&v.computed&&v.key===this.#K())return v.result||this.#Ie();this.#Z();const N=this.#l.get("filter");return(N&&N.computed?N.result:null)||this.#Ie()}unfilteredRows(){const v=this.#Ie(),N=[];for(let G=0;G<v.length;G++){const q=this.#Ee(v[G]);q&&N.push(q)}return N}#ye(v=null){const N=this.#Ie(),G=this.#G("filters",null),q=v?this.#De("pruneColumn")(G,v):G,Z=this.#Ft(q),J=String(this.#G("quick","")||"").trim().toLowerCase(),ee=J?D(J,String(this.#G("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,ie=!!(ne&&_(ne.active)&&ne.active()),se=this.#G("where",null),he=!!(se&&se.active);if(!Z&&!J&&!ie&&!he)return N;let ce=null;Z&&(ce=this.#De("evaluateFilters")(Z,{handle:de=>this.#s.handle(de),count:this.#at(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:de=>F(this.#ze(de))}));const te=new Uint32Array(N.length);let oe=0;for(let fe=0;fe<N.length;fe++){const de=N[fe];if(!(ce&&!ce[de])&&!(ee&&!this.#nt(de,ee))){if(ie||he){const we=this.#Ee(de);if(ie&&!ne.passes(we)||he&&!se.passes(we.data,we.key))continue}te[oe++]=de}}if(ce){const fe=(this.#e.compute||{}).releaseMask;_(fe)&&fe({pool:this.#e.pool},ce)}return te.subarray(0,oe)}handleFor(v){return this.#s.handle(v)}#Pe(v){const N=this.#v();if(N)return this.#ve(v,N);const G=this.#G("sort",[]).filter(J=>{const ee=this.#ze(J.col);return!ee||!ee.running?!0:(B(`source.sort.running.${J.col}`,`sort ignores "${J.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(!G.length)return v;const q=(this.#e.config||{}).locale;if(G.length===1){const J=G[0],ee=this.#s.handle(J.col);if(!ee)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),v;const ne=this.#ze(J.col);return this.#De("sortColumn")(ee,v,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(ne)})}const Z=[];for(const J of G){const ee=this.#s.handle(J.col);if(!ee){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}Z.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(this.#ze(J.col))})}return Z.length?this.#De("sortMulti")(Z.map(J=>J.handle),Z,v):v}#We(v){const N=this.#G("groupBy",[]),G=this.#Se();if(G&&!N.length){const fe=f(v,G);return this.#$=p(fe.roots,G.declaresChildren),{roots:null,leaves:v,nodes:new Map,tree:fe}}if(this.#$=null,G&&N.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!N.length)return{roots:null,leaves:v,nodes:new Map};const q=(this.#e.config||{}).timeZone,Z=[],J=[];let ee=!1;for(const fe of N){const de=this.#s.handle(fe);if(!de){B(`source.group.${fe}`,`grouping ignores unknown column "${fe}".`);continue}Z.push(de);const we=this.#ze(fe),Te=we&&we.dataType;if(Te&&_(Te.groupProjector)){const Ae=we.typeOptions&&we.typeOptions.timeZone||q||void 0,Ce=Te.groupProjector(we,Ae);J.push(Ce||null),Ce&&(ee=!0)}else J.push(null)}if(!Z.length)return{roots:null,leaves:v,nodes:new Map};const{keys:ne,buckets:ie}=this.#De("groupByColumns")(Z,v,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),se=this.#G("pivotBy",[]).length>0,he=[],ce=new Map;for(let fe=0;fe<ie.length;fe++){const de=ne[fe];let we=null;const Te=[];for(let Ae=0;Ae<de.length;Ae++){Te.push(w(de[Ae]));const Ce=z(Te),pe=Ae===de.length-1;let be=ce.get(Ce);if(!be){const ge=this.#i.group({path:[...Te],column:N[Ae],value:de[Ae],level:Ae,parent:we,expanded:se&&pe?!1:this.#gt(Ce,{key:Ce,column:N[Ae],value:de[Ae],level:Ae,path:[...Te]}),hasChildren:!(se&&pe)});be={row:ge,leaves:null},ce.set(Ce,be),we?we.children.push(ge):he.push(ge)}be.row.leafCount+=ie[fe].length,Ae===de.length-1&&(be.leaves=ie[fe]),we=be.row}}const te=this.#G("sort",[])||[],oe=(fe,de)=>{if(!fe||fe.length<2){if(fe)for(const Ce of fe)oe(Ce.children,de+1);return}const we=N[de],Te=te.find(Ce=>Ce.col===we),Ae=Te&&Te.dir==="desc"?-1:1;fe.sort((Ce,pe)=>Ae*X(Ce.groupValue,pe.groupValue));for(const Ce of fe)oe(Ce.children,de+1)};return oe(he,0),{roots:he,leaves:v,nodes:ce,keys:ne,buckets:ie}}#_e(v,N){const G=new Map,q=new Map,Z=J=>{const ee=J.physical>=0?[J.physical]:[];for(const ne of J.children)ee.push(...Z(ne));if(J.children.length){const ne=this.#Ze(N,Uint32Array.from(ee),null);J.physical>=0?G.set(J.physical,ne):q.set(J.key,ne)}return ee};for(const J of v.roots)Z(J);return{byPhysical:G,byKey:q}}#Fe(v){const N=this.#ut();if(!N.length)return this.#T=null,this.#P=null,{grand:null};const G={id:this.#R("group"),columns:N.map(te=>te.id).join("")},q=this.#T&&this.#T.id===G.id&&this.#T.columns===G.columns,Z=this.#ot()&&q?this.#E:null,J=Z?N.filter(te=>Z.has(te.id)):N,ee=q?this.#P:null,ne=this.#Ue()?null:this.#j(),ie=this.#be(N),se=te=>{const oe=v.nodes.get(te.key);let fe=oe&&oe.leaves?oe.leaves:null;if(te.children&&te.children.length){const Te=te.children.map(se);let Ae=0;for(const be of Te)Ae+=be.length;const Ce=new Uint32Array(Ae);let pe=0;for(const be of Te)Ce.set(be,pe),pe+=be.length;fe=Ce}fe=fe||new Uint32Array(0);const de=ne?ne.get(te.key)||T:fe,we=this.#ht(te,Z?J:N,de,ie);return te.totals=Z?{...te.totals,...we}:we,fe};if(v.roots&&J.length)for(const te of v.roots)se(te);if(this.#z=v.tree?this.#_e(v.tree,N):null,this.#T=G,this.#E=this.#ot()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#A.length=0,this.#P=null,{grand:null};const ce=ne?this.#mt():v.leaves;return this.#P=this.#Je(N,ce,Z,ee),{grand:this.#P}}#Je(v,N,G,q){const Z={},J=this.#R("group");J!==this.#y&&(this.#$e(),this.#y=J);const ee=this.#A;this.#A=[];for(const ne of v){if(!R(ne))continue;const ie=this.#s.handle(ne.id);if(!ie)continue;const se=S(ne,"grand");if(!t(se,ie)){if(G&&!G.has(ne.id)&&q&&ne.id in q){Z[ne.id]=q[ne.id];continue}Z[ne.id]=this.#Ze([ne],N,null,"grand")[ne.id];continue}let he=this.#O.get(ne.id);if((!he||he.fn!==se)&&(he=new r(se),this.#O.set(ne.id,he)),he.valid){let ce=!0;for(const te of ee)if(te.colId===ne.id&&!he.update(te.before,te.after)){ce=!1;break}if(ce){Z[ne.id]=he.value();continue}he.invalidate()}he.seedColumn(ie.values,o(ie),N),Z[ne.id]=he.valid?he.value():this.#Ze([ne],N,null,"grand")[ne.id]}return Z}#be(v){const N=this.#R("group");N!==this.#C&&(this.#k.clear(),this.#C=N);const G=new Map;for(const Z of v){if(!R(Z))continue;const J=this.#s.handle(Z.id),ee=S(Z,"group");t(ee,J)&&G.set(Z.id,{fn:ee})}if(!G.size)return this.#S.length=0,G;const q=this.#S;this.#S=[];for(const Z of q){const{beforeKeys:J,afterKeys:ee,colDeltas:ne}=Z,ie=J.length?new Set(J):null,se=ee.length?new Set(ee):null;for(const{colId:he,before:ce,after:te}of ne)if(G.has(he)){for(const oe of J)se&&se.has(oe)||this.#W(oe,he,ce,null);for(const oe of ee)ie&&ie.has(oe)||this.#W(oe,he,null,te);for(const oe of J)se&&!se.has(oe)||this.#W(oe,he,ce,te)}}return G}#W(v,N,G,q){const Z=this.#k.get(v),J=Z&&Z.get(N);!J||!J.valid||J.update(G,q)||J.invalidate()}#ht(v,N,G,q){if(!q||!q.size)return this.#Ze(N,G,v);const Z={};let J=null,ee=this.#k.get(v.key);for(const ne of N){const ie=q.get(ne.id);if(!ie){(J||(J=[])).push(ne);continue}const se=this.#s.handle(ne.id);if(!se)continue;ee||(ee=new Map,this.#k.set(v.key,ee));let he=ee.get(ne.id);if((!he||he.fn!==ie.fn)&&(he=new r(ie.fn),ee.set(ne.id,he)),he.valid||he.seedColumn(se.values,o(se),G),he.valid){Z[ne.id]=he.value();continue}(J||(J=[])).push(ne)}return J&&Object.assign(Z,this.#Ze(J,G,v)),Z}#Ct(v,N,G,q){const Z=!this.#Ue()||this.#it(N);for(const J of v){const ee=J.getValue;if(!_(ee))continue;const ne=ee(G),ie=ee(q);Object.is(ne,ie)||(this.#E&&this.#E.add(J.id),Z&&this.#O.has(J.id)&&this.#A.push({colId:J.id,before:ne,after:ie}))}}#ft(){const v=this.#G("groupBy",[]),N=[];for(const G of v){const q=this.#ze(G);q&&N.push(q)}return N}#pt(v,N){const G=new Array(v.length);for(let q=0;q<v.length;q++){const Z=v[q].getValue;G[q]=w(_(Z)?Z(N):void 0)}return G}#et(v,N,G,q,Z){if(this.#Ue()&&!this.#it(G))return;const J=j(this.#pt(v,q)),ee=j(this.#pt(v,Z)),ne=J.length!==ee.length||J.some((se,he)=>se!==ee[he]),ie=[];for(const se of N){const he=se.getValue;if(!_(he))continue;const ce=he(q),te=he(Z);!ne&&Object.is(ce,te)||ie.push({colId:se.id,before:ce,after:te})}!ie.length&&!ne||this.#S.push({beforeKeys:J,afterKeys:ee,colDeltas:ie})}#it(v){const N=this.#l.get("filter"),G=N&&N.computed?N.result:null;if(!G)return!0;let q=0,Z=G.length-1;for(;q<=Z;){const J=q+Z>>1,ee=G[J];if(ee===v)return!0;ee<v?q=J+1:Z=J-1}return!1}#Ue(){return(this.#e.config||{}).totalFilteredOnly!==!1}#tt(v){return this.#Ue()?v:this.#mt().length}#mt(){return(!this.#M||this.#M.version!==this.#c)&&(this.#M={version:this.#c,indices:this.#Ie()}),this.#M.indices}#j(){const v=this.#G("groupBy",[]),N=`${this.#c}|${JSON.stringify(v)}`;if(this.#N&&this.#N.key===N)return this.#N.map;const G=new Map,q=[];for(const Z of v){const J=this.#s.handle(Z);J&&q.push(J)}if(q.length){const Z=this.#mt(),{keys:J,buckets:ee}=this.#De("groupByColumns")(q,Z,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let ie=0;ie<ee.length;ie++){const se=J[ie],he=[];for(let ce=0;ce<se.length;ce++){he.push(w(se[ce]));const te=z(he);let oe=ne.get(te);oe||(oe=[],ne.set(te,oe));for(let fe=0;fe<ee[ie].length;fe++)oe.push(ee[ie][fe])}}for(const[ie,se]of ne)G.set(ie,Uint32Array.from(se))}return this.#N={key:N,map:G},G}#ot(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#xe(){this.#$e(),this.#Ce(),this.#E=null,this.#T=null,this.#P=null}#$e(){this.#O.clear(),this.#A.length=0,this.#y=-1}#Ce(){this.#k.clear(),this.#S.length=0,this.#C=-1}#He(v){const N=this.#G("pivotBy",[]);if(!N.length)return this.#se=null,null;const G=(this.#e.compute||{}).pivot;if(!_(G))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#se=null,null;const q=N.map(J=>this.#s.handle(J)).filter(Boolean),Z=this.#ut();return this.#se=G(q,v.leaves,{groups:v.keys&&v.buckets?{keys:v.keys,buckets:v.buckets}:null,totals:Z.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>S(Z.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#se}#st(v){const N=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Te();if(v.tree)return this.#lt(v,N,q);if(!v.roots&&!q){if(N&&N.grand&&!this.#re()){const se=this.#i.grandTotal(N.grand,this.#tt(v.leaves.length));if(this.#_===v.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=se;else{const he=Array.from(v.leaves);he.push(se),this.#D=he,this.#_=v.leaves}this.#ue=[{at:this.#D.length-1}]}else this.#_=null,this.#D=v.leaves,this.#ue=y;return this.#X=y,this.#D}const Z=[],J=[],ee=[],ne=se=>{if(Z.push(se),!q)return;const he=this.#Ee(se);!he||!q.isOpen(he.key)||(he.master=!0,he.expanded=!0,ee.push({at:Z.length}),Z.push(this.#i.detail(he,q.heightOf(he))))};if(!v.roots){for(let se=0;se<v.leaves.length;se++)ne(v.leaves[se]);return N&&N.grand&&!this.#re()&&(ee.push({at:Z.length}),Z.push(this.#i.grandTotal(N.grand,this.#tt(v.leaves.length)))),this.#_=null,this.#X=y,this.#ue=ee.length?ee:y,this.#D=Z,Z}const ie=(se,he,ce)=>{if(se.expanded=se.hasChildren===!1?!1:this.#gt(se.key,{key:se.key,column:se.groupColumn,value:se.groupValue,level:se.level,path:se.groupPath}),se.posinset=he+1,se.setsize=ce,J.push({at:Z.length,row:se}),ee.push({at:Z.length}),Z.push(se),!!se.expanded){if(se.children&&se.children.length)for(let te=0;te<se.children.length;te++)ie(se.children[te],te,se.children.length);else{const te=v.nodes.get(se.key),oe=te&&te.leaves?te.leaves:null;if(oe)for(let fe=0;fe<oe.length;fe++)ne(oe[fe])}G&&se.totals&&(ee.push({at:Z.length}),Z.push(this.#i.footer(se)))}};for(let se=0;se<v.roots.length;se++)ie(v.roots[se],se,v.roots.length);return N&&N.grand&&!this.#re()&&(ee.push({at:Z.length}),Z.push(this.#i.grandTotal(N.grand,this.#tt(v.leaves.length)))),this.#X=J,this.#ue=ee,this.#D=Z,Z}#Ie(){const v=this.#e.store;if(v&&_(v.liveIndices))return v.liveIndices();const N=new Uint32Array(this.#n.length);let G=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(N[G++]=q);return N.subarray(0,G)}#at(){const v=this.#e.store;return v&&typeof v.physical=="number"?v.physical:this.#n.length}#Ne(v){const N=this.#e.store;return N&&_(N.source)?N.source(v):this.#n[v]}#qe(v,N=v){const G=this.#D[v];if(typeof G!="number")return G.index=N,G;const q=this.#Ee(G);return q.index=N,q}#Ee(v){let N=this.#f.get(v);N||(N=this.#i.leaf(this.#Ne(v),v),this.#f.set(v,N));const G=this.#$?this.#$.get(v):null;if(G){N.level=G.level,N.posinset=G.posinset,N.setsize=G.setsize,N.hasChildren=G.hasChildren,N.expanded=G.hasChildren&&!G.lazy&&this.#gt(N.key);const q=this.#z?this.#z.byPhysical.get(v):void 0;q?N.totals=q:N.totals&&(N.totals=null)}else N.hasChildren&&(N.level=0,N.hasChildren=!1,N.expanded=!1,N.posinset=void 0,N.setsize=void 0);return N}#lt(v,N,G){const q=[],Z=[],J=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let ie=ne.physical>=0?1:0;for(const se of ne.children)ie+=J(se);return ne.leafCount=ie,ie},ee=ne=>{const ie=this.#gt(ne.key);if(ne.physical>=0){if(q.push(ne.physical),G&&G.isOpen(this.#Ee(ne.physical).key)){const se=this.#Ee(ne.physical);Z.push({at:q.length}),q.push(this.#i.detail(se,G.heightOf(se)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:ie,hasChildren:ne.children.length>0,leafCount:J(ne),totals:this.#z?this.#z.byKey.get(ne.key):void 0}));if(ie)for(const se of ne.children)ee(se)};for(const ne of v.tree.roots)ee(ne);return N&&N.grand&&!this.#re()&&(Z.push({at:q.length}),q.push(this.#i.grandTotal(N.grand,this.#tt(v.leaves.length)))),this.#_=null,this.#X=y,this.#ue=Z.length?Z:y,this.#D=q,q}#Lt(){return g(()=>this.count(),v=>this.at(v))}#nt(v,N){let G=this.#L.get(v);if(G===void 0){const q=this.#Ne(v),Z=this.#rt(),J=[],ee=this.#e.columnHidden;for(const ne of Z){if(ne.quickFilter===!1||_(ee)&&ee(ne.id))continue;const ie=ne.value&&_(ne.value.quickFilterText)?ne.value.quickFilterText({value:void 0,data:q,row:null,column:ne,colId:ne.id,grid:null,context:this.#G("context",null)}):null,se=ie??(_(ne.formatValue)?ne.formatValue(_(ne.getValue)?ne.getValue(q):void 0):"");se!=null&&se!==""&&J.push(String(se))}G=J.join(" ").toLowerCase(),this.#L.set(v,G)}return N(G)}#ut(){const v=this.#G("totals",[]),N=v&&v.length?new Set(v):null;return this.#rt().filter(G=>N?N.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#Ze(v,N,G,q="group"){const Z={},J=(this.#e.compute||{}).total;for(const ee of v){if(!R(ee))continue;const ne=this.#s.handle(ee.id);if(!ne)continue;const ie=S(ee,q);if(ie)if(_(ie)){const se=new Array(N.length);for(let he=0;he<N.length;he++)se[he]=ne.get(N[he]);Z[ee.id]=ie(se,{row:G,column:ee,grid:this.#e.grid||null,context:this.#G("context",null),valueAt:(he,ce)=>{const te=this.#s.handle(he);return te&&ce>=0&&ce<N.length?te.get(N[ce]):null}})}else _(J)&&(Z[ee.id]=J(ne,N,ie))}return Z}#Ft(v){if(!v)return v;const N=this.#e.config||{},G={tz:N.timeZone,weekStartsOn:N.weekStartsOn};return i(v,q=>{const Z=m(q,G),J=this.#ze(Z&&Z.col),ee=J&&J.type==="datetime";if(Z&&Z.type)return Z.type==="datetime"&&!Z.timeZone&&J?{...Z,timeZone:N.timeZone||void 0}:Z;if(ee)return{...Z,type:"datetime",timeZone:N.timeZone||void 0};const ne=J&&(J.dataType?.base||J.type);return ne?{...Z,type:ne}:Z})}#gt(v,N){const G=this.#G("expanded",null);return G?_(G.has)?G.has(v,N):Array.prototype.includes.call(G,v):!0}#G(v,N){if(v==="context"||!_(this.#e.stateVersion))return this.#Et(v,N);const G=this.#yt(v),q=this.#d.get(v);if(q&&q.version===G)return q.value;const Z=this.#Et(v,N);return this.#d.set(v,{version:G,value:Z}),Z}#Et(v,N){const G=this.#e.state;if(G&&_(G[v])){const q=G[v]();return q??N}return N}#ct(){const v=this.#e.stateVersion;return _(v)?v():0}#St(){const v=this.#e.columnsVersion,N=this.#e.permissionsVersion;return`${_(v)?v():0}|${_(N)?N():0}`}#yt(v){return v==="totals"?this.#St():`${this.#ct()}`}#bt(v,N,G){if(!_(this.#e.stateVersion))return G();const q=this.#h.get(v);if(q&&q.version===N)return q.key;const Z=G();return this.#h.set(v,{version:N,key:Z}),Z}#De(v){const N=(this.#e.compute||{})[v];return _(N)||I(`ctx.compute.${v} is required by the memory source pipeline`),N}#rt(){const v=this.#e.columns;return v&&_(v.all)?v.all():[]}#ze(v){const N=this.#e.columns;return N&&_(N.get)?N.get(v):void 0}#Ve(v,N){const G=this.#e.emit;_(G)&&G(v,N)}}}),Le("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class Q extends Error{constructor(W,V="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${V}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class x{#e;constructor(W,V,H,z){this.#e=W,this.key=V,this.controller=H,this.signal=H.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(W){this.signal.aborted||this.controller.abort(new Q(this.key,W)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(W="",V="superseded"){const H=this.#e.get(W);H&&!H.signal.aborted&&H.controller.abort(new Q(W,V));const z=new x(this,W,new AbortController,++this.#t);return this.#e.set(W,z),z}tokenFor(W){return this.#e.get(W)}pending(W=""){const V=this.#e.get(W);return!!V&&!V.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",V="superseded"){const H=this.#e.get(W);H&&H.abort(V)}abortAll(W="superseded"){for(const V of[...this.#e.values()])V.abort(W);this.#e.clear()}}function I(){return new B}function _(X){if(!X||typeof X!="object")return!1;const W=X;return W.superseded===!0||W.name==="AbortError"||W.name==="SupersededError"}}),Le("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return I}});const Q=100,x=32;class B{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class I{#e=new Map;#t;#n;#r=0;#o=-1;constructor(X={}){this.#t=Math.max(1,Math.floor(Number(X.pageSize)||Q)),this.#n=Math.max(1,Math.floor(Number(X.maxCachedPages)||x))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(X){return Math.floor(X/this.#t)}rangeOf(X){return{start:X*this.#t,end:(X+1)*this.#t}}has(X){return this.#e.has(X)}pending(X){const W=this.#e.get(X);return!!W&&W.state==="pending"}loaded(X){const W=this.#e.get(X);return!!W&&W.state==="loaded"}begin(X,W){let V=this.#e.get(X);return V||(V=new B(X)),V.state="pending",V.token=W,V.error=null,this.#i(X,V),V}fill(X,W){const V=this.#e.get(X)||new B(X);V.rows=W,V.state="loaded",V.token=null,this.#i(X,V)}failed(X,W){const V=this.#e.get(X)||new B(X);V.state="error",V.error=W,V.token=null,this.#i(X,V)}delete(X){return this.#e.delete(X)}rowAt(X){const W=this.blockOf(X),V=this.#e.get(W);if(!(!V||V.state!=="loaded"||!V.rows))return this.#i(W,V),V.rows[X-W*this.#t]}rowLoaded(X){const W=this.blockOf(X),V=this.#e.get(W);return!!V&&V.state==="loaded"&&!!V.rows&&X-W*this.#t<V.rows.length}erroredAt(X){const W=this.#e.get(this.blockOf(X));return!!W&&W.state==="error"}loadedExtent(){let X=0;for(const W of this.#e.values()){if(W.state!=="loaded"||!W.rows)continue;const V=W.id*this.#t+W.rows.length;V>X&&(X=V)}return X}fillOf(X){const W=this.#e.get(X);return W&&W.state==="loaded"&&W.rows?W.rows.length:null}protect(X,W){this.#r=this.blockOf(Math.max(0,X)),this.#o=this.blockOf(Math.max(0,W))}evict(){const X=[];if(this.#e.size<=this.#n)return X;for(const[W,V]of this.#e){if(this.#e.size-X.length<=this.#n)break;W>=this.#r&&W<=this.#o||V.state!=="pending"&&X.push(W)}for(const W of X)this.#e.delete(W);return X}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(X,W){this.#e.delete(X),this.#e.set(X,W)}}}),Le("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q(x,B,I,_){const X=Math.floor(Number(x)||0);if(X<=0)return null;const W=Math.max(0,Math.floor(Number(B)||0)),V=Math.max(0,Math.floor(Number(I)||0));if(_){const H=Math.max(1,Math.ceil(V/X)),z=Math.min(W,H-1),w=z*X;return{page:z,pageSize:X,offset:w,length:Math.max(0,Math.min(X,V-w)),pageCount:H,total:V}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(V/X)),total:null}}}),Le("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,V=X.isAbortError,H=K("packages/core/src/source/blockcache.js"),z=H.BlockCache,w=H.DEFAULT_PAGE_SIZE,j=H.DEFAULT_MAX_CACHED_PAGES,u=K("packages/core/src/source/rows.js").createRowFactory,h=K("packages/core/src/source/filterwire.js"),a=h.wireFilters,r=h.querySignature,t=h.warnHostFilterNotApplied,o=K("packages/core/src/source/pagewindow.js").pageWindow,d=120;function l(m,c){return new i(m,c)}class i{mode="paged";#e;#t;#n;#r=W();#o;#i;#s=new Map;#l=null;#a=null;#u=!1;#c=0;#d="";#h={start:0,end:0};#f;#p=!1;#m=0;#g="";constructor(c,f){this.#e=c||{mode:"paged"},this.#t=f||{},this.#n=new z({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||j}),this.#o=u(this.#t),this.#i=new x(this.#n.pageSize*4),this.#f=_((s,p)=>this.#y(s,p),d),this.#d=this.#E(),B(this.#e.fetch)||I("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const c=this.#w();return c?c.length:this.#b()}#b(){if(this.#C(),this.#l!==null)return this.#l;const c=Math.max(this.#c,this.#n.loadedExtent());return this.#u?c:c+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const c=this.#w();if(!c){const f=this.#b();return{page:0,pageSize:0,total:this.exact()?f:null,pageCount:1,counting:!1}}return{page:c.page,pageSize:c.pageSize,total:c.total,pageCount:c.pageCount,counting:c.total===null&&this.#r.size>0&&this.#c===0&&this.#n.loadedExtent()===0}}#w(){const c=this.#b(),f=o(this.#P("pageSize",0),this.#P("page",0),c,this.exact());if(!f)return this.#g="",null;const s=`${this.#m}:${f.offset}:${f.length}`;if(s!==this.#g&&!this.#p&&(this.#g=s,f.length>0)){const p=f.offset+f.length-1;this.#h={start:f.offset,end:p},this.#y(f.offset,p)}return f}at(c){const f=this.#w();if(f){if(c<0||c>=f.length)return;const s=this.#O(f.offset+c);return s&&(s.index=c),s}return this.#O(c)}#O(c){if(c<0||c>=this.#b())return;const f=this.#i.get(c);if(f&&(f.data!==null||!this.#n.rowLoaded(c)))return f;const s=this.#n.rowAt(c);if(s===void 0){const b=this.#o.skeleton(c,0,this.#n.erroredAt(c));return this.#i.set(c,b),b}const p=this.#o.leaf(s,c);return p.index=c,this.#i.set(c,p),this.#s.set(p.key,c),p}byKey(c){const f=this.#s.get(c);return f===void 0?void 0:this.#O(f)}loaded(c){const f=this.#w();return f?c>=0&&c<f.length&&this.#n.rowLoaded(f.offset+c):this.#n.rowLoaded(c)}loadedCount(){this.#C();let c=0;for(const f of this.#n.ids()){if(!this.#n.loaded(f))continue;const s=this.#n.fillOf(f);typeof s=="number"&&(c+=s)}return c}residentRows(){this.#C();const c=this.#w(),f=c?c.offset:0,s=c?c.offset+c.length:1/0,p=[],b=this.#n.ids().sort((A,k)=>A-k);for(const A of b){if(!this.#n.loaded(A))continue;const{start:k}=this.#n.rangeOf(A),y=this.#n.fillOf(A)||0;for(let S=k;S<k+y;S++){if(S<f||S>=s)continue;const R=this.#i.peek(S);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const O=this.#n.rowAt(S);if(O===void 0)continue;const F=this.#o.leaf(O,S);F.index=S,this.#i.set(S,F),this.#s.set(F.key,S),p.push(F)}}return p}hint(c,f){if(this.#p)return;const s=this.#C();let p=Math.max(0,Math.floor(c)),b=Math.max(p,Math.floor(f));const A=this.#w();if(A){if(A.length===0)return;p=A.offset,b=A.offset+A.length-1}this.#h={start:p,end:b},this.#n.protect(p,b);for(const k of this.#n.evict())this.#k(k);this.#f(p,b),s&&this.#f.flush()}#y(c,f){if(this.#p)return;this.#n.protect(c,f);const s=this.#n.blockOf(c),p=this.#n.blockOf(f);for(let b=s;b<=p&&!(this.#l!==null&&b*this.#n.pageSize>=this.#l);b++)this.#n.has(b)||this.#A(b)}apply(c){const f={added:[],updated:[],removed:[]};if(!c)return f;if(c.update)for(const s of c.update){const p=this.#o.keyOf(s,-1),b=this.#s.get(p);if(b===void 0)continue;const A=this.#o.leaf(s,b);A.index=b,this.#i.set(b,A),f.updated.push(A)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),f}reload(c){this.#S("reload"),this.#f.cancel(),this.hint(this.#h.start,this.#h.end)}destroy(){this.#p=!0,this.#f.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#u}pending(){return this.#r.size}async#A(c){if(!B(this.#e.fetch))return;const f=this.#r.begin(`block:${c}`);this.#n.begin(c,f);const{start:s,end:p}=this.#n.rangeOf(c),b=this.#d;try{const A=await this.#e.fetch({range:{start:s,end:p},sort:this.#P("sort",[]),filters:a(this.#P("filters",null),this.#T()),quick:this.#P("quick","")||void 0,context:this.#P("context",null),signal:f.signal});if(!f.current||b!==this.#d||this.#p)return;f.settle();const k=A&&A.rows||[];this.#n.fill(c,k);for(let S=0;S<k.length;S++)this.#i.delete(s+S);const y=A&&typeof A.total=="number"?A.total:A&&typeof A.count=="number"?A.count:null;y!==null?(this.#l=y,this.#u=!0):k.length<this.#n.pageSize?(this.#u=!0,this.#l=s+k.length):this.#c=Math.max(this.#c,s+k.length),this.#M("model:changed",{reason:"page",block:c,from:s,to:s+k.length}),this.#M("rows:changed",{companion:!0,reason:"page",block:c,from:s,to:s+k.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#M("source:total",{total:this.#l,groupPath:[]}))}catch(A){if(f.settle(),V(A))return;this.#n.failed(c,A);for(let k=s;k<p;k++)this.#i.delete(k);this.#M("model:changed",{reason:"page-error",block:c,range:{start:s,end:p}}),this.#M("source:error",{error:A,block:c,range:{start:s,end:p}})}}#k(c){const{start:f,end:s}=this.#n.rangeOf(c);for(let p=f;p<s;p++){const b=this.#i.peek(p);b&&this.#s.delete(b.key),this.#i.delete(p)}}#C(){const c=this.#E();return c===this.#d?!1:(this.#d=c,this.#S("query"),!0)}#S(c){this.#r.abortAll(c),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=null,this.#u=!1,this.#c=0,this.#m++,this.#M("model:changed",{reason:c})}#E(){return r({filters:this.#P("filters",null),sort:this.#P("sort",[]),quick:this.#P("quick",""),context:this.#P("context",null)})}#T(){const c=this.#t.config||{};return{tz:c.timeZone,weekStartsOn:c.weekStartsOn}}#P(c,f){const s=this.#t.state;if(s&&B(s[c])){const p=s[c]();return p??f}return f}#M(c,f){const s=this.#t.emit;B(s)&&s(c,f)}}}),Le("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return H}});const Q=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)"},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 x(){const z=new Set;for(const[w,j]of Object.entries(Q))j.pushable&&z.add(w);return z}function B(z,w,j){let g=z.split("%c").join(w);return j!==void 0&&(g=g.split("%w").join(j)),g}function I(z){const w=z||{},j=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[u,h]of Object.entries(w.overrides))(h==="engine"||h==="client")&&(g[u]=h);return{default:j,overrides:g}}function _(z,w){const j=Q[z];if(!j||!j.pushable)return"client";const g=w.overrides[z];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?j.class==="identical"?"engine":"client":"engine"}function X(z,w){const j=I(w),g=[],u=[];for(const h of z||[]){const a=Q[h.fn],r=_(h.fn,j),t={id:h.id,col:h.col,fn:h.fn,class:a?a.class:"fallback"};h.weight!==void 0&&(t.weight=h.weight),h.params!==void 0&&(t.params=h.params),r==="engine"?g.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:g,client:u,config:j}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function V(z,w=[]){return(z||[]).every(g=>{if(typeof g=="string")return W.test(g);if(!g||typeof g!="object")return!1;const u=g;return Array.isArray(w)&&w.includes(u.bucket)&&typeof u.col=="string"&&W.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function H(){return Object.entries(Q).map(([z,w])=>({stat:z,class:w.class,sql:w.sql?B(w.sql,"col",w.twoColumn?"weight":void 0):"",note:w.note||(w.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Le("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),x=Q.defaultCompare,B=Q.isFunction,I=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,V=X.warnWherePageRelative,H=X.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),w=z.resolveAggregatePlan,j=z.groupKeysPushable,g=z.STAT_PUSHDOWN,h=K("packages/core/src/source/abort.js").SupersededError,a=1e3;function r(N){const G=N&&N.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new h("","superseded before it was sent")}const t=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function n(N){if(!N||typeof N!="object")return!1;const G=N.returning==="row"||N.returning==="key"?N.returning:"none";return{append:N.append===!0,update:N.update===!0,delete:N.delete===!0,returning:G}}function o(N,G){if(!N||typeof G!="string")return;if(!G.includes("."))return N[G];let q=N;for(const Z of G.split(".")){if(q===null||typeof q!="object")return;q=q[Z]}return q}function d(N){if(N===!0)return!0;if(!N||typeof N!="object")return!1;const G=N;return G.enabled===!1?!1:G.enabled===!0||B(G.commit)}function l(N){const G={...t,...N||{}};return G.operators=new Set(G.operators||[]),G.mutate=n(G.mutate),G}function i(N,G){return!N||!N.op||!G.operators.size?!1:G.operators.has(N.op)}function m(N,G){if(!N)return{pushed:null,residual:null};if(!G.filter)return{pushed:null,residual:N};if(G.filter==="term"){if(W(N)){const ee=N.conditions||[];if(String(N.op)!=="and")return{pushed:null,residual:N};const ne=ee.findIndex(se=>!W(se)&&i(se,G));if(ne<0)return{pushed:null,residual:N};const ie=ee.filter((se,he)=>he!==ne);return{pushed:ee[ne],residual:ie.length?{op:"and",conditions:ie}:null}}return i(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N}}if(!W(N))return i(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N};if(String(N.op)!=="and")return(N.conditions||[]).every(ne=>W(ne)?m(ne,G).residual===null:i(ne,G))?{pushed:N,residual:null}:{pushed:null,residual:N};const q=[],Z=[];for(const ee of N.conditions||[]){if(W(ee)){if(G.filter==="flat"){Z.push(ee);continue}const ne=m(ee,G);ne.pushed&&q.push(ne.pushed),ne.residual&&Z.push(ne.residual);continue}(i(ee,G)?q:Z).push(ee)}const J=ee=>ee.length===0?null:ee.length===1?ee[0]:{op:"and",conditions:ee};return{pushed:J(q),residual:J(Z)}}const c="__lattice_leaves";function f(N){return N.aggregates?N.aggregates instanceof Set?N.aggregates:new Set(I(N.aggregates)):new Set}function s(N){const G=f(N);return G.size?G.has("count")?N.filter!=="tree"||!N.operators||!N.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 p(N,G,q,Z,J,ee,ne){const ie=Array.isArray(N.groupBy)?N.groupBy:[],se=Array.isArray(N.groupPath)?N.groupPath:[],he=Array.isArray(N.groupValues)?N.groupValues:null;if(!G.group){const ce=s(G);if(ce)return ce}return j(ie)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Z?J?ee?"a host `where` predicate can only run in the browser, over rows the engine grouped":ne?"fullDataset holds the whole matching set, so the grid groups it itself":!he||he.length!==se.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 b="pushdown:pivot-unsupported",A="pushdown:group-unsupported",k=Symbol("lattice.remote.ungroupedLevel");function y(N,G,q,Z,J,ee){const ne=Array.isArray(N.pivotBy)?N.pivotBy:[],ie=Array.isArray(N.groupBy)?N.groupBy:[],se=Array.isArray(N.groupPath)?N.groupPath:[],he=Array.isArray(N.groupValues)?N.groupValues:null;return G.pivot?j(ne)?ie.length&&!j(ie)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Z?J?ee?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!he||he.length!==se.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 S(N,G,q=!1){const Z=m(N.filters||null,G),J=[];Z.residual&&J.push("filter");const ee=N.sort||[],ne=ee.length===0||G.sort==="multi"&&ee.length>=1||G.sort==="single"&&ee.length===1;!ne&&ee.length&&J.push("sort");const ie=N.quick?String(N.quick):"",se=!ie||!!G.quick;se||J.push("quick");const he=N.where&&N.where.active?N.where:null;he&&J.push("where");const ce={filters:Z.residual,sort:ne?null:ee,quick:se?"":ie,where:he},te=!!q,oe=Array.isArray(N.groupBy)&&N.groupBy.length>0,fe=oe?p(N,G,Z,ne,se,he,te):"",de=N.pivotMode!==!1&&Array.isArray(N.pivotBy)&&N.pivotBy.length>0,we=de?y(N,G,Z,ne,se,he):"",Te=de&&we==="";de&&!Te&&J.push("pivot");const Ae=de?Te&&oe:oe&&fe==="";oe&&!de&&!Ae&&J.push("group");const Ce=(Ae||Te)&&Array.isArray(N.groupValues)?N.groupValues.length:0,pe=Ae||de?!1:te||!!(ce.filters||ce.sort||ce.quick||ce.where)||!G.range;return{pushed:{...N,filters:Z.pushed,sort:ne?ee:[],quick:se?ie:"",range:pe?null:N.range},residual:ce,needsAll:pe,unpushed:J,full:te,grouped:Ae,groupLevel:Ce,groupReason:de?"":fe,pivoted:Te,pivotReason:we}}function R(N){const G=Array.isArray(N.totals)?N.totals:[],q=N.totalFns&&typeof N.totalFns=="object"?N.totalFns:{},Z=[],J=[];for(const ee of G){const ne=String(ee),ie=typeof q[ne]=="string"?q[ne]:null,se=ie?g[ie]:null;ie?!se||!se.pushable||!se.sql?J.push({id:ne,fn:ie,class:se?se.class:"fallback",reason:se&&se.note?se.note:`the pushdown map cannot express "${ie}"`}):se.twoColumn?J.push({id:ne,fn:ie,class:se.class,reason:`"${ie}" reduces two columns, and a grouped request carries no weight column`}):Z.push({id:ne,col:ne,fn:ie,class:se.class}):J.push({id:ne,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Z,client:J}}const O=Object.freeze({items:N=>N==null?[]:Array.isArray(N)?N:[N]});function F(N,G,q){if(!G)return N;let Z=N;if(G.filters&&B(q.evaluateFilters)){const J=Z,ee={count:Z.length,handle:se=>({id:se,get:he=>o(J[he],se)}),itemwise:se=>J.some(he=>Array.isArray(o(he,se)))?O:null},ne=q.evaluateFilters(G.filters,ee),ie=[];for(let se=0;se<Z.length;se++)ne[se]&&ie.push(Z[se]);Z=ie}if(G.where&&G.where.active&&(G.whole||V(G.where.names,"pushdown"),Z=Z.filter(J=>G.where.passes(J))),G.quick){const J=G.quick.toLowerCase();Z=Z.filter(ee=>{if(!ee||typeof ee!="object")return!1;for(const ne of Object.values(ee))if(ne!=null&&String(ne).toLowerCase().includes(J))return!0;return!1})}if(G.sort&&G.sort.length&&B(q.sortMulti)){const J=[...new Set(G.sort.map(se=>se.col))],ee=Z,ne=J.map(se=>({id:se,get:he=>o(ee[he],se)})),ie=q.sortMulti(ne,G.sort.map(se=>({col:se.col,dir:se.dir})),Uint32Array.from({length:Z.length},(se,he)=>he),{});Z=Array.from(ie,se=>ee[se])}return Z}function E(N){return JSON.stringify({filters:N.filters||null,sort:N.sort||[],quick:N.quick||"",groupBy:N.groupBy||[],groupPath:N.groupPath||[],context:N.context??null})}function T(N){if(!N||typeof N!="object")return 16;let G="";try{G=JSON.stringify(N)}catch{return 200}return G.length*2+64}function L(N){const G=N||{};return{enabled:!!G.enabled,maxRows:Number.isFinite(G.maxRows)?G.maxRows:1e6,maxBytesEstimate:Number.isFinite(G.maxBytesEstimate)?G.maxBytesEstimate:512*1024*1024}}const C=5e4;function D(N){return Number.isFinite(N)&&N>=0?N:C}function $(N){return!!N&&B(N.then)}async function P(N){if(!N||N.total!==void 0||!$(N.pendingTotal))return N;const G=await N.pendingTotal,{pendingTotal:q,...Z}=N;return typeof G=="number"?{...Z,total:G}:Z}function v(N={}){const G=N.adapter;if(!G||!B(G.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...N,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=l(G.capabilities),Z=G.capabilities&&Object.getOwnPropertyDescriptor(G.capabilities,"operators");Z&&B(Z.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(G.capabilities.operators||[]),set:()=>{}});const J=G.name||"adapter";let ee=null;const ne=()=>B(G.ready)?(ee||(ee=Promise.resolve(G.ready()).then(()=>{Object.assign(q,l(G.capabilities))},Ie=>{throw ee=null,Ie})),ee):null,ie=L(N.fullDataset),se=!!N.allowPartialResults,he=D(N.whereRowLimit);let ce=null;const te=N.aggregates;let oe=null,fe=null,de=null,we=null,Te=null,Ae,Ce=null,pe=0,be=null;const ge=()=>!ie.enabled||!oe?null:(be!==oe.key&&(pe++,be=oe.key),{rows:oe.rows,version:pe}),Ne=async Ie=>{const qe=Ie.where&&Ie.where.active?Ie.where:null;if(!qe)return{request:Ie,probe:null};const{where:ye,...ke}=Ie,me=S(ke,q,ie.enabled);if(me.needsAll)return{request:Ie,probe:null};const je=E(me.pushed);let Me=null;return(!ce||ce.key!==je)&&(q.total?(r(Ie),Me=await P(await G.execute(me.pushed,Ie)),ce={key:je,size:Me&&typeof Me.total=="number"?Me.total:null}):ce={key:je,size:null}),ce.size!==null&&ce.size<he?{request:Ie,probe:null}:(H(qe.names,J,ce.size,he),{request:ke,probe:Me})},$e=async(Ie,qe)=>{Ce=null;const ye=R(Ie.pushed);de={engine:ye.engine,client:ye.client,groupBy:Ie.pushed.groupBy},ye.client.length&&_(`source.pushdown.group.totals.${J}.${ye.client.map(je=>je.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${ye.client.map(je=>`"${je.id}" (${je.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 ke=await G.executeGroupLevel(Ie.pushed,ye.engine,qe)||{};let me=ke.rows||[];return!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),Ge(ke),ke.total===void 0?{rows:me}:{rows:me,total:ke.total}},He=new Map,Ye=64,Oe=async(Ie,qe)=>{Ce=null;const ye=Ie.pushed,ke=ye.groupBy,me=Array.isArray(ye.groupValues)?ye.groupValues:[],je=me.length,Me=[...ye.filters?[ye.filters]:[],...ke.slice(0,je).map((ot,St)=>({col:ot,op:"eq",value:me[St]===void 0?null:me[St],caseSensitive:!0}))],ze=Me.length===0?null:Me.length===1?Me[0]:{op:"and",conditions:Me},_e=qe.range?qe.range.start:0;if(je>=ke.length){const ot={...ye,filters:ze,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},St=await P(await G.execute(ot,qe))||{};let At=St.rows||[];return!q.range&&qe.range&&(At=At.slice(qe.range.start,qe.range.end)),typeof St.total=="number"?{rows:At,total:St.total}:{rows:At}}const De=ke[je],Se=R(ye),xe=f(q),Be=Se.engine.filter(ot=>xe.has(ot.fn)),Je=[...Se.engine.filter(ot=>!xe.has(ot.fn)).map(ot=>({id:ot.id,fn:ot.fn,class:ot.class,reason:`the ${J} adapter does not compute "${ot.fn}"`})),...Se.client];de={engine:Be,client:Je,groupBy:ke},Je.length&&_(`source.pushdown.group.totals.${J}.${Je.map(ot=>ot.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${Je.map(ot=>`"${ot.id}" (${ot.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 Qe=[...Be.map(ot=>({id:ot.id,col:ot.col,fn:ot.fn})),{id:c,col:De,fn:"count"}],at={...ye,filters:ze,range:null},it=JSON.stringify([E(at),me,De,Qe]);let gt=_e>0?He.get(it):void 0;if(!gt){for(gt=Promise.resolve(G.executeGroupedAggregates(at,[De],Qe)),He.delete(it),He.set(it,gt);He.size>Ye;)He.delete(He.keys().next().value);gt.catch(()=>{He.get(it)===gt&&He.delete(it)})}const wt=await gt||[];r(qe);const dt=ot=>{const St={};for(const At of Be)St[At.id]=ot?ot[At.id]:void 0;return St},jt=(ye.sort||[]).find(ot=>ot&&ot.col===De),Ve=jt&&jt.dir==="desc"?-1:1,pt=wt.filter(ot=>ot&&ot.level===1).map(ot=>({[De]:ot.keys[0]===void 0?null:ot.keys[0],leafCount:Number(ot.values&&ot.values[c])||0,totals:dt(ot.values)})).sort((ot,St)=>Ve*x(ot[De],St[De]));if(je===0){const ot=wt.find(At=>At&&At.level===0),St=ot?Number(ot.values&&ot.values[c]):NaN;Ge({matchCount:Number.isFinite(St)?St:pt.reduce((At,ft)=>At+ft.leafCount,0),...ot?{grand:dt(ot.values)}:{}})}const ct=qe.range?qe.range.end:pt.length;return{rows:pt.slice(_e,ct),total:pt.length}},Ge=Ie=>{typeof Ie.matchCount=="number"&&(we=Ie.matchCount,Te=Ie.grand?{totals:Ie.grand,leafCount:Ie.matchCount}:null,Ae===void 0&&B(G.unfilteredCount)&&(Ae=null,Promise.resolve(G.unfilteredCount()).then(qe=>{Ae=typeof qe=="number"?qe:null}).catch(qe=>{_(`source.pushdown.group.unfiltered.${J}`,`the ${J} adapter could not count the unfiltered set (${qe&&qe.message?qe.message:qe}), so "N of M" falls back to the display count for its denominator.`)})))},Ze=async(Ie,qe)=>{Ce=null;const ye=R(Ie.pushed);de={engine:ye.engine,client:ye.client,groupBy:Ie.pushed.groupBy,pivotBy:Ie.pushed.pivotBy},ye.client.length&&_(`source.pushdown.pivot.totals.${J}.${ye.client.map(ze=>ze.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${ye.client.map(ze=>`"${ze.id}" (${ze.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 ke=await G.executePivotLevel(Ie.pushed,ye.engine,qe)||{};let me=ke.rows||[];!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),Ge(ke);const je=ke.pivot&&typeof ke.pivot=="object"?ke.pivot:{},Me={cells:Array.isArray(je.cells)?je.cells:[],...Array.isArray(je.axis)?{axis:je.axis}:{}};return ke.total===void 0?{rows:me,pivot:Me}:{rows:me,total:ke.total,pivot:Me}},rt=Ie=>{_(`source.pushdown.pivot.${J}.${Ie}`,`pushdown:pivot-unsupported: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const qe=new Error(`[lattice] ${b}: the ${J} adapter cannot pivot this query because ${Ie}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw qe.code=b,qe.reason=Ie,qe},st=(Ie,qe)=>{const ye={key:qe,state:"pending",value:null};return Ce=ye,Ie.then(ke=>(Ce===ye&&(Ce={key:qe,state:"settled",value:typeof ke=="number"?ke:null}),ke),ke=>{throw Ce===ye&&(Ce={key:qe,state:"failed",value:null}),ke})};let ht=0,yt=[];const Ot=()=>ht===0?null:new Promise(Ie=>{const qe=setTimeout(Ie,a);yt.push(()=>{clearTimeout(qe),Ie()})});let Ct;const Tt=async Ie=>{const qe=ne();qe&&await qe;const ke=Ie&&Ie.pivotMode!==!1&&Array.isArray(Ie.pivotBy)&&Ie.pivotBy.length>0?{request:Ie,probe:null}:await Ne(Ie);r(Ie);let me=S(ke.request,q,ie.enabled);if(q.group&&me.grouped&&!me.pivoted&&!B(G.executeGroupLevel)&&(_(`source.pushdown.group.method.${J}`,`the ${J} 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.`),me=S(ke.request,{...q,group:!1,aggregates:null},ie.enabled)),me.pivoted&&!B(G.executePivotLevel)&&(me=S(ke.request,{...q,pivot:!1},ie.enabled),me.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),me.grouped&&!me.pivoted&&!q.group&&!B(G.executeGroupedAggregates)&&(_(`source.pushdown.group.aggregates.method.${J}`,`the ${J} 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\`.`),me=S(ke.request,{...q,aggregates:null},ie.enabled)),fe=me,me.pivoted)return Ze(me,Ie);if(me.pivotReason&&rt(me.pivotReason),me.grouped)return q.group?$e(me,Ie):Oe(me,Ie);const Me=!!me.groupReason&&!me.full;Me?_(`source.pushdown.group-unsupported.${J}.${me.groupReason}`,`pushdown:group-unsupported: the ${J} adapter was not asked to group this query because ${me.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.`):me.groupReason&&_(`source.pushdown.group.${J}.${me.groupReason}`,`the ${J} adapter was not asked to group this query because ${me.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 ze=Qe=>Me?{...Qe,[k]:!0}:Qe;if(!me.needsAll){const Qe=ke.probe||await G.execute(me.pushed,Ie),at=Qe.rows||[];return $(Qe.pendingTotal)&&Qe.total===void 0?ze({rows:at,pendingTotal:st(Qe.pendingTotal,E(me.pushed))}):(Ce=null,!q.total&&Qe.total===void 0?ze({rows:at}):ze({rows:at,total:Qe.total??at.length}))}me.unpushed.length&&_(`source.pushdown.residual.${J}.${me.unpushed.join(".")}`,`the ${J} adapter cannot push ${me.unpushed.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 _e=E(me.pushed);if(!oe||oe.key!==_e){const Qe=await P(await G.execute(me.pushed,Ie));Ce=null;const at=Qe.rows||[];if(me.full){const it=typeof Qe.total=="number"?Math.max(Qe.total,at.length):at.length;if(it>ie.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${it.toLocaleString()} rows, past the configured maxRows of ${ie.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 gt=at.length*T(at[0]);if(gt>ie.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is an estimated ${Math.round(gt/(1024*1024)).toLocaleString()} MB across ${at.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ie.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 Qe.total=="number"&&at.length<Qe.total){const it=!!(me.residual.filters||me.residual.quick||me.residual.sort&&me.residual.sort.length);if(it&&!se)throw new Error(`[lattice] the ${J} adapter returned ${at.length} of ${Qe.total} matching rows when asked for the whole result, and the query has residual ${me.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.`);it?_(`source.pushdown.partial.residual.${J}`,`the ${J} adapter returned ${at.length} of ${Qe.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.`):_(`source.pushdown.partial.${J}`,`the ${J} adapter returned ${at.length} of ${Qe.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}oe={key:_e,rows:at,total:typeof Qe.total=="number"?Qe.total:null}}let De=me;if(me.residual.where){const Qe=oe.total??oe.rows.length;if(Qe>=he){H(me.residual.where.names,J,Qe,he);const{where:at,...it}=ke.request;De=S(it,q,ie.enabled),fe=De}}const Se=oe.total!==null&&oe.rows.length>=oe.total,xe=F(oe.rows,{...De.residual,whole:Se},N.compute||{}),Be=Ie.range?Ie.range.start:0,Je=Ie.range?Ie.range.end:xe.length;return ze({rows:xe.slice(Be,Je),total:xe.length})},Et=async(Ie,qe,ye)=>{const me=ye&&ye.waitForPage&&Ct&&B(Ct.pageForegroundIdle)?Ct.pageForegroundIdle():Ot();me&&await me;const je=ne();je&&await je;const Me=S(Ie,q,ie.enabled);fe=Me;const ze=w(qe,te),_e=Array.isArray(Ie.groupBy)?Ie.groupBy:[],De=_e.length>0,Se=!Me.residual.filters&&!Me.residual.quick,xe=!De||j(_e,q.buckets);let Be=ze.engine,Je=ze.client;if(q.aggregates&&Be.length){const gt=q.aggregates instanceof Set?q.aggregates:new Set(I(q.aggregates)),wt=Be.filter(dt=>!gt.has(dt.fn));wt.length&&(Be=Be.filter(dt=>gt.has(dt.fn)),Je=[...wt.map(dt=>({...dt,reason:`the ${J} adapter does not compute "${dt.fn}"`})),...Je])}const Qe=gt=>{Je=[...Be.map(wt=>({...wt,reason:gt})),...Je],Be=[]};Be.length&&!Se?Qe(Me.residual.quick&&!Me.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Be.length&&!xe&&Qe("a grouping key the engine cannot form forces all-client (no mixed provenance)");let at={},it;return Be.length&&(B(De?G.executeGroupedAggregates:G.executeAggregates)?De?it=await G.executeGroupedAggregates(Me.pushed,_e,Be)||[]:at=await G.executeAggregates(Me.pushed,Be)||{}:(_(`source.pushdown.aggregates.${J}${De?".grouped":""}`,`the ${J} adapter cannot compute ${De?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Qe(`adapter cannot compute ${De?"grouped ":""}aggregates`))),de={engine:Be,client:Je,...De?{groupBy:_e}:{}},{values:at,engine:Be,client:Je,...it!==void 0?{groups:it}:{}}},zt=async Ie=>{ht++;try{return await Tt(Ie)}finally{if(ht--,ht===0&&yt.length){const qe=yt;yt=[];for(const ye of qe)ye()}}},It=d(N.edit),ut=N.edit&&typeof N.edit=="object"&&B(N.edit.commit);let nt=N.edit;if(It&&!ut)if(q.mutate&&q.mutate.update){const Ie=qe=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${J} 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 ye={kind:"update",key:String(qe.key),patch:{[qe.colId]:qe.value}};return G.mutate(ye,qe.request||{})};nt={...N.edit===!0?{}:N.edit,commit:Ie}}else _(`source.pushdown.readonly.${J}`,`edit is enabled but the ${J} adapter declares mutate: ${q.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 le=It&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Ie,qe)=>G.mutate(Ie,qe||{})}:null,ve=async Ie=>{const qe=ne();qe&&await qe;const{range:ye,signal:ke,export:me,...je}=Ie||{},Me={...je,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:S(Me,q,ie.enabled),signal:ke}};async function*Re(Ie,qe={}){const{plan:ye,signal:ke}=await ve(Ie),me=Math.max(1,Math.floor(Number(qe.pageSize))||5e3),je={signal:ke,stream:!0};if(!ye.needsAll)for(let _e=0;;_e+=me){r(je);const De=await G.execute({...ye.pushed,range:{start:_e,end:_e+me}},je);De&&$(De.pendingTotal)&&De.pendingTotal.then(null,()=>{});const Se=De&&De.rows||[];if(Se.length&&(yield Se),Se.length<me)return}r(je);const Me=await P(await G.execute({...ye.pushed,range:void 0},je)),ze=F(Me&&Me.rows||[],{...ye.residual,whole:!0},N.compute||{});for(let _e=0;_e<ze.length;_e+=me)yield ze.slice(_e,_e+me)}return Ct={...N,edit:nt,rowMutate:le,mode:"remote",fetch:zt,foregroundIdle:Ot,aggregate:Et,countMatching:async Ie=>{const{plan:qe,signal:ye}=await ve(Ie);if(!qe.needsAll&&q.total){r({signal:ye});const me=await P(await G.execute({...qe.pushed,range:{start:0,end:0}},{signal:ye}));if(me&&typeof me.total=="number")return me.total}let ke=0;for await(const me of Re(Ie))ke+=me.length;return ke},streamMatching:Re,lastPlan:()=>fe?{...fe,...de?{aggregates:de}:{},...Ce?{total:{deferred:!0,state:Ce.state,value:Ce.value}}:{}}:null,fullFrame:ge,counts:()=>({match:we,total:Ae??null,pending:!!Ce&&Ce.state==="pending"}),grandTotals:()=>Te},Ct}}),Le("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,V=X.isAbortError,H=K("packages/core/src/source/blockcache.js"),z=H.BlockCache,w=H.DEFAULT_PAGE_SIZE,j=H.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),u=g.createRowFactory,h=g.groupKey,a=K("packages/core/src/source/filterwire.js"),r=a.wireFilters,t=a.querySignature,n=a.warnHostFilterNotApplied,d=K("packages/core/src/source/pagewindow.js").pageWindow,i=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,f=K("packages/core/src/compute/pivot.js"),s=f.pivotKey,p=f.joinPath,b=f.DEFAULT_PATH_SEPARATOR,k=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,S=120,R=1e3;function O(L,C,D){for(let $=0;$<Math.max(L.length,C.length);$++){const P=L[$],v=C[$],N=P==null,G=v==null;if(N||G){if(N&&G)continue;return N?1:-1}const q=D(P,v);if(q!==0)return q}return 0}function F(L,C){return new T(L,C)}class E{constructor(C,D,$,P){this.path=C,this.keyPath=P||C,this.values=[],this.level=D,this.key=h(this.keyPath),this.cache=new z($),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 T{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=W();#l;#a;#u=new Map;#c=[];#d=null;#h="";#f;#p=!1;#m=!1;#g=[];#b=!1;#w=0;#O="";#y=null;#A=-1;constructor(C,D){this.#e=C||{mode:"remote"},this.#t=D||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#z(),this.unfilteredIndices=()=>this.#H(),this.handleFor=G=>this.#B(G),this.display=()=>this.#L(),this.grandTotalRow=()=>this.#D(),this.unfilteredRows=()=>this.#ue(),this.facetIndices=G=>this.#I(G));const $=this.#e.counts;B($)&&(this.matchCount=()=>this.#_("match"),this.totalCount=()=>this.#_("total"));const P=this.#e.grandTotals;B(P)&&(this.grandTotalRow=()=>this.#X());const v=this.#e.foregroundIdle;B(v)&&(this.foregroundIdle=()=>this.#me(v),this.#e.pageForegroundIdle=()=>this.#b?this.#me(v):null);const N=this.#e;B(N.countMatching)&&B(N.streamMatching)&&(this.selectionQuery=()=>this.#se(),this.countMatching=G=>N.countMatching(G),this.streamMatching=(G,q)=>N.streamMatching(G,q),this.loadedRows=()=>this.#ae(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||j},this.#l=u(this.#t),this.#a=new x(this.#n.pageSize*4),this.#f=_((G,q)=>this.#P(G,q),S),this.#r=new E([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#h=this.#oe(),B(this.#e.fetch)||I("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const C=this.#S();return C?C.length:this.#k()}#k(){const C=this.#N();return C?C.count():(this.#pe(),this.#q(this.#r))}#C(){if(this.#N())return!0;const C=D=>{if(D.count===null&&!D.complete)return!1;for(const $ of D.children.values())if(this.#we($.key)&&!C($))return!1;return!0};return C(this.#r)}pageInfo(){const C=this.#S(),D=this.totalPending();if(!C){const $=this.#k();return{page:0,pageSize:0,total:this.#C()?$:null,pageCount:1,counting:D}}return{page:C.page,pageSize:C.pageSize,total:C.total,pageCount:C.pageCount,counting:D||C.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const C=this.#k(),D=d(this.#R("pageSize",0),this.#R("page",0),C,this.#C());if(!D)return this.#O="",null;const $=`${this.#w}:${D.offset}:${D.length}`;return $!==this.#O&&!this.#p&&(this.#O=$,D.length>0&&!this.#N()&&this.#P(D.offset,D.offset+D.length-1)),D}at(C){const D=this.#S();if(D){if(C<0||C>=D.length)return;const $=this.#E(D.offset+C);return $&&($.index=C),$}return this.#E(C)}#E(C){const D=this.#N();if(D)return D.at(C);if(this.#pe(),C<0||C>=this.#k())return;const $=this.#ie(this.#r,C);if(!$)return;const P=this.#ne($.node,$.local);return P&&(P.index=C),P||this.#l.skeleton(C,$.node.level,$.node.cache.erroredAt($.local))}byKey(C){const D=this.#N();if(D)return D.byKey(C);const $=this.#u.get(C);if(!$)return;const P=$.lastIndexOf(":"),v=this.#o.get($.slice(0,P));return v&&this.#ne(v,Number($.slice(P+1)))||void 0}loaded(C){const D=this.#S();if(D){if(C<0||C>=D.length)return!1;C+=D.offset}const $=this.#N();if($)return $.loaded(C);if(C<0||C>=this.#k())return!1;const P=this.#ie(this.#r,C);return!!P&&P.node.cache.rowLoaded(P.local)}hint(C,D){if(this.#p)return;this.#b=!0;const $=this.#pe();let P=Math.max(0,Math.floor(C)),v=Math.max(P,Math.floor(D));const N=this.#S();if(N){if(N.length===0)return;P=N.offset,v=N.offset+N.length-1}for(const[G,q]of this.#T(P,v)){G.cache.protect(q.min,q.max);for(const Z of G.cache.evict())this.#Me(G,Z)}this.#f(P,v),$&&this.#f.flush()}#T(C,D){const $=this.#k(),P=new Map;for(let v=C;v<=D&&v<$;v++){const N=this.#ie(this.#r,v);if(!N)continue;const G=P.get(N.node);G?(G.min=Math.min(G.min,N.local),G.max=Math.max(G.max,N.local)):P.set(N.node,{min:N.local,max:N.local})}return P.size||P.set(this.#r,{min:C,max:C}),P}#P(C,D){if(!this.#p)for(const[$,P]of this.#T(C,D)){$.cache.protect(P.min,P.max);const v=$.cache.blockOf(P.min),N=$.cache.blockOf(P.max);for(let G=v;G<=N&&!($.count!==null&&G*$.cache.pageSize>=$.count);G++)$.cache.has(G)||this.#Te($,G)}}apply(C){const D={added:[],updated:[],removed:[]};if(!C)return D;if(C.update)for(const $ of C.update){const P=this.#u.get(this.#l.keyOf($,-1));if(!P)continue;this.#a.delete(P);const v=P.lastIndexOf(":"),N=this.#o.get(P.slice(0,v));if(!N)continue;const G=Number(P.slice(v+1)),q=N.cache.blockOf(G);if(!N.cache.loaded(q))continue;const{start:Z}=N.cache.rangeOf(q),J=[];for(let ne=Z;ne<Z+N.cache.pageSize;ne++){const ie=N.cache.rowAt(ne);if(ie===void 0)break;J.push(ne===G?$:ie)}N.cache.fill(q,J);const ee=this.#ne(N,G);ee&&D.updated.push(ee)}return(C.add&&C.add.length||C.remove&&C.remove.length)&&this.reload({keepExpanded:!0}),D}reload(C){this.#s.abortAll("reload"),this.#f.cancel(),C&&C.keepExpanded===!1&&this.#i.clear(),this.#he(),this.#K("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#f.cancel(),this.#s.abortAll("destroyed"),this.#he(),this.#o.clear(),this.#i.clear(),this.#y&&B(this.#y.destroy)&&this.#y.destroy(),this.#y=null}expand(C){this.#i.has(C)||(this.#i.add(C),this.#K("group:toggled",{key:C,expanded:!0}),this.#K("model:changed",{reason:"expand",key:C}))}collapse(C){this.#i.delete(C)&&(this.#K("group:toggled",{key:C,expanded:!1}),this.#K("model:changed",{reason:"collapse",key:C}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#pe();const C=this.#d;if(!C||!C.keys.size||!this.#R("pivotBy",[]).length)return null;if(!C.result){const D=c((this.#t.config||{}).locale),$=[...C.keys.entries()].sort((v,N)=>O(v[1],N[1],D)),P=$.map(([v])=>v);C.result={keys:$.map(([,v])=>v),paths:P,fields:this.#V(P),groupPaths:[],columns:P.length*Math.max(1,this.#le().length),values:C.cells,cells:C.cells,error:null}}return C.result}invalidateHandles(){this.#y&&(B(this.#y.invalidateHandles)&&this.#y.invalidateHandles(),B(this.#y.invalidate)&&this.#y.invalidate("filter"))}#M(){const C=this.#e.fullFrame;return B(C)?C():null}#N(){const C=this.#M();return C?(this.#y||(this.#y=new i({mode:"memory"},this.#$())),C.version!==this.#A&&(this.#y.setRows(C.rows),this.#A=C.version),this.#y):null}#$(){const C=this.#t,D=C.state||{};return{...C,state:{...D,page:()=>0,pageSize:()=>0}}}#z(){const C=this.#N();return C?C.filteredIndices():new Uint32Array(0)}#H(){const C=this.#N();return C?C.unfilteredIndices():new Uint32Array(0)}#B(C){const D=this.#N();return D?D.handleFor(C):void 0}#L(){const C=this.#N();return C?C.display():[]}#I(C){const D=this.#N();return D&&B(D.facetIndices)?D.facetIndices(C):new Uint32Array(0)}#D(){const C=this.#N();return C&&B(C.grandTotalRow)?C.grandTotalRow():null}#_(C){const D=this.#N();if(D){const N=C==="match"?D.matchCount:D.totalCount;if(B(N))return N.call(D)}const $=this.#e.counts,P=B($)?$():null,v=P?P[C]:null;return typeof v=="number"?v:this.#k()}#X(){const C=this.#N();if(C&&B(C.grandTotalRow))return C.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const $=this.#e.grandTotals,P=B($)?$():null;return!P||!P.totals?null:this.#l.grandTotal(P.totals,P.leafCount||0)}#ue(){const C=this.#N();if(C&&B(C.unfilteredRows))return C.unfilteredRows();const D=[],$=this.count();for(let P=0;P<$;P++){const v=this.at(P);v&&D.push(v)}return D}#se(){const C=this.#R("quick",""),D={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:r(this.#R("filters",null),this.#ce()),sort:this.#R("sort",[]),context:this.#R("context",null)};C&&(D.quick=C);const $=this.#R("where",null);return $&&$.active&&(D.where=$),D}#ae(){const C=this.#R("groupBy",[]).length,D=[];for(const $ of this.#o.values())if(!($.level!==C&&!$.flat))for(const P of $.cache.ids()){if(!$.cache.loaded(P))continue;const{start:v,end:N}=$.cache.rangeOf(P);for(let G=v;G<N&&$.cache.rowLoaded(G);G++){const q=this.#ne($,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const C=this.#N();if(C){const P=C.matchCount();return typeof P=="number"?P:C.count()}this.#pe();const D=this.#R("groupBy",[]).length;let $=0;for(const P of this.#o.values())if(!(P.level!==D&&!P.flat))for(const v of P.cache.ids()){if(!P.cache.loaded(v))continue;const N=P.cache.fillOf(v);typeof N=="number"&&($+=N)}return $}residentRows(){const C=this.#N();return C?C.display():this.#R("groupBy",[]).length>0?null:(this.#pe(),this.#ae())}#ge(C,D,$){const{start:P,end:v}=C.cache.rangeOf(D),N=this.#R("groupBy",[]),G=this.#R("pivotBy",[]),q=this.#R("quick",""),Z=this.#le(),J={protocol:y,range:{start:P,end:v},groupPath:C.path,groupValues:C.values,groupBy:N,totals:Z,totalFns:this.#U(Z),pivotBy:G,pivotMode:G.length>0,filters:r(this.#R("filters",null),this.#ce()),sort:this.#R("sort",[]),context:this.#R("context",null),signal:$};q&&(J.quick=q);const ee=this.#R("where",null);return ee&&ee.active&&(J.where=ee),J}async#Te(C,D){if(!B(this.#e.fetch))return;if(!this.#m){this.#m=!0;const N=this.#g;this.#g=[],queueMicrotask(()=>{for(const G of N)G()})}const $=this.#s.begin(`${C.key}:${D}`);C.cache.begin(D,$);const P=this.#h,{start:v}=C.cache.rangeOf(D);try{const N=await this.#e.fetch(this.#ge(C,D,$.signal));if(!$.current||P!==this.#h||this.#p)return;$.settle();const G=N&&N.rows||[];if(!!(N&&N[k])&&!C.flat){C.flat=!0,C.children.clear();for(const[ee,ne]of[...this.#u])ne.startsWith(`${C.key}:`)&&(this.#a.delete(ne),this.#u.delete(ee))}C.cache.fill(D,G),C.failed=!1;for(let ee=0;ee<G.length;ee++)this.#a.delete(`${C.key}:${v+ee}`);const Z=N&&typeof N.count=="number"?N.count:N&&typeof N.total=="number"?N.total:null,J=N&&B(N.pendingTotal?.then)?N.pendingTotal:null;Z!==null?(C.count=Z,C.complete=!0):G.length<C.cache.pageSize?(C.count=v+G.length,C.complete=!0):J&&(C.counting=!0,C.announced=null),N&&Array.isArray(N.pivotFields)&&this.#te(N.pivotFields),N&&N.pivot&&typeof N.pivot=="object"&&this.#J(N.pivot),this.#K("model:changed",{reason:"page",groupPath:C.path,block:D}),this.#K("rows:changed",{companion:!0,reason:"page",groupPath:C.path,block:D}),this.#re(C),J&&this.#Se(C,J,P)}catch(N){if($.settle(),V(N))return;C.cache.failed(D,N),C.failed=!0;const{end:G}=C.cache.rangeOf(D);for(let q=v;q<G;q++)this.#a.delete(`${C.key}:${q}`);this.#K("model:changed",{reason:"page-error",groupPath:C.path,block:D}),this.#K("source:error",{error:N,groupPath:C.path,block:D})}}async#Se(C,D,$){let P;try{P=await D}catch(v){if($!==this.#h||this.#p)return;C.counting=!1,V(v)||(C.failed=!0),V(v)||this.#K("source:error",{error:v,groupPath:C.path});return}$!==this.#h||this.#p||(C.counting=!1,typeof P=="number"&&(C.count=P,C.complete=!0,this.#re(C),this.#K("model:changed",{reason:"total",count:P,groupPath:C.path})))}#re(C){typeof C.count!="number"||!C.complete||C.announced!==C.count&&(C.announced=C.count,this.#K("source:total",{total:C.count,groupPath:C.path}))}#me(C){if(this.#p)return null;this.#pe();const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),$=C();if(!D&&!$)return null;const P=(async()=>{D&&await D;for(let G=C();G;G=C())await G})();let v;const N=new Promise(G=>{v=setTimeout(G,R)});return Promise.race([P,N]).then(()=>clearTimeout(v))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#pe();const C=this.#r;return C.count===null&&!C.complete&&C.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#te(C){C.length===this.#c.length&&C.every((D,$)=>D===this.#c[$])||(this.#c=C,this.#K("column:pivoted",{pivotFields:C,remote:!0}))}#Y(){const C=this.#t.config||{};return C.pivot&&C.pivot.separator||b}#V(C){const D=this.#Y(),$=this.#le();if(!$.length)return C.slice();const P=[];for(const v of C)for(const N of $)P.push(`${v}${D}${N}`);return P}#J(C){const D=this.#Y();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const $=this.#d;let P=!1;const v=G=>{const q=Array.isArray(G)?G:[G],Z=p(q,D);return $.keys.has(Z)||($.keys.set(Z,q),P=!0),Z},N=this.#R("groupBy",[]).length>0;for(const G of Array.isArray(C.axis)?C.axis:[])v(G);for(const G of Array.isArray(C.cells)?C.cells:[]){if(!G||typeof G!="object")continue;const q=v(G.pivot);if(N&&!(Array.isArray(G.group)&&G.group.length))continue;const Z=p(Array.isArray(G.group)?G.group:[],D);for(const[J,ee]of Object.entries(G.values||{}))$.cells.set(s(Z,q,J),ee)}$.result=null,P&&this.#te((this.pivot()||{fields:[]}).fields)}#q(C){let D=this.#Ae(C);for(const $ of C.children.values())this.#we($.key)&&(D+=this.#q($));return D}#Ae(C){if(C.count!==null)return C.count;const D=C.cache.loadedExtent();return C.complete?D:C.row&&C.row.leafCount>0?C.level>=this.#R("groupBy",[]).length?Math.max(D,C.row.leafCount):D===0?1:Math.min(D+C.cache.pageSize,Math.max(D,C.row.leafCount)):D+C.cache.pageSize}#ie(C,D){let $=D,P=0;const v=[...C.children.entries()].filter(([,G])=>this.#we(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of v){const Z=G-P+1;if($<Z)return{node:C,local:P+$};$-=Z,P=G+1;const J=this.#q(q);if($<J)return this.#ie(q,$);$-=J}const N=this.#Ae(C);return P+$<N?{node:C,local:P+$}:null}#ne(C,D){const $=`${C.key}:${D}`,P=this.#a.get($);if(P)return P;const v=C.cache.rowAt(D);if(v===void 0)return null;const N=this.#R("groupBy",[]);let G;if(C.level<N.length&&!C.flat){const q=N[C.level],Z=this.#d!==null&&C.level===N.length-1&&this.#R("pivotBy",[]).length>0,J=this.#F(v,q),ee=J==null,ne=[...C.path,ee?"":String(J)],ie=[...C.keyPath,ee?null:String(J)];if(G=this.#l.group({path:ne,keyPath:ie,column:q,value:J,level:C.level,parent:C.row,leafCount:Number(v.leafCount)||0,expanded:Z?!1:this.#we(h(ie)),...Z?{hasChildren:!1}:{}}),G.totals=this.#Z(v),G.data=v,!Z){let se=this.#o.get(G.key);se?se.row=G:(se=new E(ne,C.level+1,this.#n,ie),se.row=G,this.#o.set(se.key,se)),se.values=[...C.values,J],C.children.set(D,se)}}else G=this.#l.leaf(v,D,C.level,C.row);return this.#a.set($,G),this.#u.set(G.key,$),G}#Z(C){const D=C||{};if(D.totals&&typeof D.totals=="object")return D.totals;const $={};for(const P of this.#le())Object.hasOwn(D,P)&&($[P]=D[P]);return $}#Me(C,D){const{start:$,end:P}=C.cache.rangeOf(D);for(let v=$;v<P;v++){const N=`${C.key}:${v}`,G=this.#a.peek(N);G&&this.#u.delete(G.key),this.#a.delete(N)}}#pe(){const C=this.#oe();return C===this.#h?!1:(this.#h=C,this.#s.abortAll("query"),this.#he(),this.#m=!1,this.#K("model:changed",{reason:"query"}),!0)}#he(){for(const C of this.#o.values())C.cache.clear(),C.count=null,C.complete=!1,C.announced=null,C.counting=!1,C.failed=!1,C.children.clear(),C.flat=!1;this.#a.clear(),this.#u.clear(),this.#w++,this.#d=null}#oe(){const C=this.#R("where",null);return`${t({filters:this.#R("filters",null),sort:this.#R("sort",[]),quick:this.#R("quick",""),groupBy:this.#R("groupBy",[]),pivotBy:this.#R("pivotBy",[]),context:this.#R("context",null)})}|${C?C.version:0}`}#we(C){const D=this.#R("expanded",null);return D?B(D.has)?D.has(C):Array.prototype.includes.call(D,C):this.#i.has(C)}#le(){const C=this.#R("totals",[]);if(C&&C.length)return[...C];const D=this.#t.columns;return!D||!B(D.all)?[]:D.all().filter($=>!!$.total).map($=>$.id)}#U(C){const D=this.#t.columns,$={};if(!D||!B(D.get))return $;for(const P of C){const v=D.get(P);if(!v)continue;const N=v.groupTotal!=null?v.groupTotal:v.total;typeof N=="string"&&($[P]=N)}return $}#F(C,D){const $=this.#t.columns,P=$&&B($.get)?$.get(D):void 0;return P&&B(P.getValue)?P.getValue(C):C?.[D]}#de(){n(this.#t)}#ce(){const C=this.#t.config||{};return{tz:C.timeZone,weekStartsOn:C.weekStartsOn}}#R(C,D){const $=this.#t.state;if($&&B($[C])){const P=$[C]();return P??D}return D}#K(C,D){const $=this.#t.emit;B($)&&$(C,D)}}}),Le("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return x}});const Q=64;class x{#e;#t=0;#n=0;constructor(I=Q){this.#e=new Uint32Array(Math.max(1,I)),this.#n=this.#e.length}static from(I,_=Q){const X=new x(I.length+Math.max(1,_));return X.#e.set(I,0),X.#t=I.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(I){return I<0||I>=this.length?0:I<this.#t?this.#e[I]:this.#e[I+(this.#n-this.#t)]}insert(I,_){const X=I<0?0:I>this.length?this.length:I;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push(I){this.insert(this.length,I)}removeAt(I){return!Number.isInteger(I)||I<0||I>=this.length?!1:(this.#r(I),this.#n++,!0)}toArray(){const I=new Uint32Array(this.length);return I.set(this.#e.subarray(0,this.#t),0),I.set(this.#e.subarray(this.#n),this.#t),I}clear(){this.#t=0,this.#n=this.#e.length}#r(I){if(I!==this.#t)if(I<this.#t){const _=this.#t-I;this.#e.copyWithin(this.#n-_,I,this.#t),this.#t=I,this.#n-=_}else{const _=I-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=I,this.#n+=_}}#o(){const I=this.#e.length-this.#n,_=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Q));_.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),_.length-I),this.#e=_,this.#n=_.length-I}}}),Le("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return r}});const Q=K("packages/core/src/internal/util.js"),x=Q.now,B=Q.nextFrame,I=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,H=K("packages/core/src/store/columnstore.js").ColumnStore,z=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function w(t,n={}){if(n.multi)return"multi";if(t.length===0)return"object";let o=0,d=0,l=0,i=0,m=0;for(let f=0;f<t.length;f++){const s=t[f];typeof s=="number"?o++:typeof s=="boolean"?d++:typeof s=="string"?l++:s instanceof Date?i++:Array.isArray(s)&&m++}const c=t.length;return o===c?"float64":d===c?"bitset":i===c?"float64":l===c?"text":m===c?"multi":"object"}function j(t,n,o){return n<=0||t<o*n?"dictionary":"object"}function g(t,n,o){const d=new Map,l=new Map;for(const y of t){if(y.computed)continue;const S=X(y.read)?y.read:W(y.field||y.id);l.set(y.id,S),d.set(y.id,S)}const i=n?.order??[],m=n?.fns??{},c=n?.deps??{},f=n?.wrapDeps??null,s=i.filter(y=>X(m[y])),p=s.some(y=>c[y]==="*");let b=new WeakMap;const A=y=>{const S={};if(p)for(const[R,O]of l)S[R]=O(y);for(const R of s){const O=c[R];let F;if(O==="*")F=S;else{F={};const E=O||[];for(let T=0;T<E.length;T++){const L=E[T];F[L]=L in S?S[L]:l.get(L)?.(y)}}S[R]=m[R](f?f(F,R):F,{data:y,row:null,column:null,grid:null,context:o})}return S},k=y=>{if(y===null||typeof y!="object"&&typeof y!="function")return A(y);let S=b.get(y);return S===void 0&&(S=A(y),b.set(y,S)),S};for(const y of s)d.set(y,S=>k(S)[y]);return{readers:d,reset(){b=new WeakMap}}}class u{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(n,o){this.spec=n,this.read=o,this.kind="object",this.inferred=!1,this.nullable=n.nullable!==!1}}class h{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(n,o={},d={}){this.#e=Array.isArray(n)?n:Array.from(n||[]),this.#i={...z,...d};const l=o.columns??[];this.#r=g(l,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(l,o.computed??null),this.#n=new H(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const n=x(),{chunkMs:o,chunkRows:d}=this.#i,l=this.#e.length;do{const i=Math.min(this.#o+d,l);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#f(!1)}while(this.#o<l&&x()-n<o);return this.#a+=x()-n,this.#i.onProgress?.({loaded:this.#o,total:l}),this.#o>=l?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,read:n.read,dictionary:n.spec.dictionary})),decisions:this.#t.map(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,inferred:n.inferred,distinct:n.candidate||n.change?this.#h(n):null,change:n.change,reason:n.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(n,o){const d=this.#e,l=Math.min(this.#i.sampleSize,d.length),i=this.#i.dictionaryRatio,m=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const c of n){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||o&&!m.has(c.id))){_(`ingest.impure.${c.id}`,`column "${c.id}" is an impure computed column and is not materialised into the store`);continue}const f=this.#r.readers.get(c.id)??(X(c.read)?c.read:W(c.field||c.id)),s=new u(c,f);if(c.kind)s.kind=c.kind,s.reason="declared by the caller";else if(c.dictionary)s.kind=c.multi?"multi":"dictionary",s.reason="value table supplied (lookup column)";else{const p=[];for(let A=0;A<l&&p.length<this.#i.sampleSize;A++){const k=f(d[A]);k!=null&&p.push(k)}s.inferred=!0;const b=w(p,{multi:c.multi});if(b==="text"){const A=new Set(p).size;s.kind=j(A,p.length,i),s.candidate=this.#u,s.reason=`sampled ${A} distinct in ${p.length}`}else s.kind=b,s.reason=`inferred from ${p.length} sampled values`,b==="object"&&p.length&&I(`ingest.mixed.${c.id}`,`column "${c.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);s.kind==="object"&&s.candidate&&(s.distinct=new Set(p))}this.#t.push(s)}}#d(n,o){const d=this.#e;for(const l of this.#t){if(!l.candidate||!l.distinct)continue;const i=l.distinct;for(let m=n;m<o;m++){const c=l.read(d[m]);c!=null&&i.add(c)}}}#h(n){if(n.distinct)return n.distinct.size;const o=this.#n.column(n.spec.id);return o?.dict?o.dict.size:0}#f(n){const o=this.#i.dictionaryRatio,d=this.#e.length;for(const l of this.#t){if(!l.candidate)continue;const i=this.#h(l);if(l.kind==="dictionary"&&i>=o*d){const m=this.#n.column(l.spec.id);l.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(l.spec.id,"object"),l.kind="object",l.change="demoted",l.reason=`${i} distinct values is at or above ${o*100}% of ${d} rows`;continue}if(l.kind==="object"&&i>=o*d){l.candidate=!1,l.distinct=null,l.reason=`${i} distinct values is at or above ${o*100}% of ${d} rows`;continue}n&&l.kind==="object"&&i<o*d&&(this.#n.convert(l.spec.id,"dictionary"),l.kind="dictionary",l.change=l.change==="demoted"?null:"promoted",l.reason=`${i} distinct values is below ${o*100}% of ${d} rows`,l.distinct=null),n&&(l.candidate=!1)}}}async function a(t,n={},o={}){const d=new h(t,n,o),l=o.scheduler?.frame??B;for(;d.slice();)await new Promise(i=>{l(i)});return d.result()}function r(t,n={},o={}){const d=new h(t,n,{...o,chunkMs:1/0});for(;d.slice(););return d.result()}}),Le("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),I=B.inferKind,_=B.decideText,X=B.INGEST_DEFAULTS,V=K("packages/core/src/store/columnstore.js").toFloat,H=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(a){if(!Array.isArray(a)||a.length===0)return!1;for(const r of a)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!H.has(r.kind))return!1;return!0}function w(a){const r=V(a);return Number.isFinite(r)?r|0:0}function j(a){return a==null?[]:Array.isArray(a)?a:[a]}function g(a,r,t,n){if(a.kind)return a.kind;const o=[];for(let i=0;i<r.length&&o.length<X.sampleSize;i++){const m=r[i];m!=null&&o.push(m)}const d=I(o,{multi:a.multi});if(d!=="text")return d;const l=new Set(o).size;return _(l,o.length,n)}function u(a,r,t={}){const n=r.length|0,o=t.dictionaryRatio??X.dictionaryRatio,d=[];for(const l of a){const i=x(l.field||l.id),m=l.nullable!==!1,c=new Array(n);for(let A=0;A<n;A++){const k=i(r[A]);c[A]=k===void 0?null:k}const f=g(l,c,n,o),s=m?new Uint8Array(n+7>>3):null,p=A=>{s&&(s[A>>3]|=1<<(A&7))};let b;switch(f){case"float64":{const A=new Float64Array(n);for(let k=0;k<n;k++){const y=c[k],S=y===null;S||p(k),A[k]=S?NaN:V(y)}b={id:l.id,kind:f,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"int32":{const A=new Int32Array(n);for(let k=0;k<n;k++){const y=c[k],S=y===null;S||p(k),A[k]=S?0:w(y)}b={id:l.id,kind:f,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"bitset":{const A=new Uint8Array(n+7>>3);for(let k=0;k<n;k++){const y=c[k],S=y===null;S||p(k),!S&&y&&(A[k>>3]|=1<<(k&7))}b={id:l.id,kind:f,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"dictionary":{const A=new Uint32Array(n),k=[],y=new Map;for(let S=0;S<n;S++){const R=c[S];if(R===null){A[S]=0;continue}p(S);let O=y.get(R);O===void 0&&(O=k.length,k.push(R),y.set(R,O)),A[S]=O}b={id:l.id,kind:f,nullable:m,values:A,presence:s,offsets:null,table:k};break}case"multi":{const A=[],k=new Map,y=new Uint32Array(n+1),S=[];for(let R=0;R<n;R++){const O=c[R];y[R]=S.length,O===null||p(R);const E=j(O);for(let T=0;T<E.length;T++){const L=E[T];let C=k.get(L);C===void 0&&(C=A.length,A.push(L),k.set(L,C)),S.push(C)}}y[n]=S.length,b={id:l.id,kind:f,nullable:m,values:Int32Array.from(S),presence:s,offsets:y,table:A};break}default:{const A=new Array(n);for(let k=0;k<n;k++){const y=c[k];y!==null&&p(k),A[k]=y}b={id:l.id,kind:"object",nullable:m,values:A,presence:s,offsets:null,table:null};break}}d.push(b)}return{count:n,columns:d}}function h(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const t=n=>{ArrayBuffer.isView(n)&&n.buffer&&!r.includes(n.buffer)&&r.push(n.buffer)};for(const n of a.columns)t(n.values),t(n.presence),t(n.offsets);return r}}),Le("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,B=Q.isFunction,I=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,V=Q.defaultCompare,H=Q.warnOnce,z=Q.infoOnce,w=Q.getPath,j=K("packages/core/src/source/abort.js"),g=j.createAbortScope,u=j.isAbortError,h=K("packages/core/src/source/rows.js"),a=h.createRowFactory,r=h.lazyRowView,n=K("packages/core/src/source/gapbuffer.js").GapBuffer,d=K("packages/core/src/source/memory.js").createMemorySource,i=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,f=25e4,s=Symbol("lattice.stream.storeBacked"),p=8,b=.1,A=1e3,k=50;function y(F){return Math.min(A,Math.max(k,Math.floor(F/4)))}function S(F){if(F instanceof Date)return F.getTime();if(typeof F=="number")return Number.isFinite(F)?F:NaN;if(typeof F=="string"){const E=F.trim();if(!E)return NaN;const T=Date.parse(E);return Number.isNaN(T)?Number(E):T}return NaN}function R(F,E){return new O(F,E)}class O{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=g();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#p=0;#m=0;#g=null;#b=null;#w=null;#O=!1;#y=!1;#A=!1;#k=!1;#C="";#S=0;#E=0;#T=0;#P=null;#M=1/0;#N=!1;#$=null;#z=null;#H=null;#B=null;#L=!1;#I=0;#D=0;#_=!1;constructor(E,T){this.#e=E||{mode:"stream"},this.#t=T||{},this.#s=a(this.#t),this.#l=new x(4096),this.#C=this.#Je();const L=(this.#t.config||{}).ingest;this.#L=!!L&&L.retainSource===!1,B(this.#e.open)||H("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const C=Number(this.#e.poll);Number.isFinite(C)&&C>0&&(this.#B=setInterval(()=>{this.#k||this.reload()},C),this.#B&&B(this.#B.unref)&&this.#B.unref()),this.#ue()}#X(){const E=Number(this.#e.maxAge);return Number.isFinite(E)&&E>0?E:0}#ue(){const E=this.#X();if(!E)return;const T=this.#e.ageBy;B(T)?this.#z=T:typeof T=="string"&&T?this.#z=L=>w(L,T):this.#z=null,this.#P=[],this.#$=setInterval(()=>{this.#k||this.#se()&&(this.#pe(),this.#v())},y(E)),this.#$&&B(this.#$.unref)&&this.#$.unref()}#se(){const E=this.#X();return!E||!this.#P?!1:this.#N?!0:this.#M<Date.now()-E*(1+b)}#ae(E,T){if(!this.#P)return;const L=this.#z?S(this.#z(T)):Date.now();this.#P[E]=L,Number.isNaN(L)||(L<this.#M&&(this.#M=L),L<Date.now()-this.#X()&&(this.#N=!0))}#ge(){return this.#be("groupBy",[]).length>0?!0:!!this.#be("pivotMode",!1)&&this.#be("pivotBy",[]).length>0}#Te(){if(this.#g||this.#k)return;const E=this.#ge();if(E&&!this.#b){this.#b=d({mode:"memory",rows:this.#n},this.#Se()),this.#O=!1;return}!E&&this.#b&&(this.#b.destroy(),this.#b=null)}#Se(){if(this.#w)return this.#w;const E=this,T={liveIndices:()=>E.#re(),live:L=>E.#n[L]!==void 0,source:L=>E.#je(L),get physical(){return E.#n.length}};return this.#L&&(T.column=L=>{const C=E.#t.store;return C&&B(C.column)?C.column(L):void 0}),this.#w=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#w}#re(){const E=new Uint32Array(this.#n.length);let T=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(E[T++]=L);return E.subarray(0,T)}#me(){return this.#g?this.#g:this.#b?(this.#O&&(this.#O=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(E="filter"){if(this.#g){this.#g.invalidate(E);return}this.#Te(),this.#b&&this.#b.invalidate(E),(E==="filter"||E==="sort")&&this.#le()}count(){const E=this.#me();return E?E.count():this.#r?this.#r.length:this.#S}matchCount(){const E=this.#me();return E&&B(E.matchCount)?E.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const E=this.#me();return E&&B(E.totalCount)?E.totalCount():this.#S}unfilteredRows(){const E=this.#me();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const T=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const C=this.#ye(L);C&&T.push(C)}return T}at(E){const T=this.#me();if(T)return T.at(E);if(E<0||E>=this.count())return;const L=this.#r?this.#r.at(E):E,C=this.#ye(L);return C.index=E,C}byKey(E){const T=this.#me();if(T)return T.byKey(E);const L=this.#a.get(E);return L===void 0?void 0:this.#ye(L)}leavesOf(E){const T=this.#me();return T&&B(T.leavesOf)?T.leavesOf(E):[]}loaded(E){return E>=0&&E<this.count()}hint(E,T){if(this.#g){this.#g.hint(E,T);return}this.#te(),this.#p=Math.max(0,Math.floor(E))}#te(){this.#k||this.#Je()===this.#C||this.reload()}display(){const E=this.#me();return E?E.display():r(()=>this.count(),T=>this.at(T))}apply(E){if(this.#g)return this.#g.apply(E);const T={added:[],updated:[],removed:[]};if(!E)return T;if(E.update){let L=!1;for(const C of E.update){const D=this.#a.get(this.#s.keyOf(C,-1));if(D===void 0)continue;const $=this.#de(D);this.#L?this.#Qe(D,C):this.#n[D]=C,this.#l.delete(D),this.#ce(D,$),this.#P&&(this.#ae(D,C),L=!0),this.#O=!0,T.updated.push(this.#ye(D))}L&&this.#pe()}if(E.add&&E.add.length){const L=this.#Z(E.add);for(const C of L)T.added.push(this.#ye(C))}return E.remove&&E.remove.length&&H("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#v(),T}reload(E){this.#u.abortAll("reload"),this.#Fe(),this.#b&&(this.#b.destroy(),this.#b=null),this.#O=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#E=0,this.#T=0,this.#P&&(this.#P=[]),this.#M=1/0,this.#N=!1,this.#y=!1,this.#A=!1,this.#c={loaded:0,estimated:void 0},this.#C=this.#Je(),this.#W("model:changed",{reason:"reload"}),this.start()}destroy(){this.#k=!0,this.#B!==null&&(clearInterval(this.#B),this.#B=null),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#P=null,this.#u.abortAll("destroyed"),this.#Fe(),this.#d!==null&&(this.#Ke(this.#d),this.#d=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#A||this.#k||!B(this.#e.open))return;this.#A=!0;const E=this.#u.begin("stream");this.#le(),this.#Te();let T;try{T=this.#e.open({sort:this.#be("sort",[]),filters:this.#be("filters",null),quick:this.#be("quick","")||void 0,context:this.#be("context",null),signal:E.signal})}catch(C){this.#W("source:error",{error:C});return}const L=B(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#H=L;try{for(;;){const C=await L.next();if(!E.current||this.#k)return;if(C.done){this.#fe();return}if(await this.#Y(C.value,E),!E.current||this.#k)return;if(C.value&&C.value.done){this.#fe();return}if(await this.#ve(),!E.current||this.#k)return}}catch(C){if(u(C))return;this.#W("source:error",{error:C})}finally{E.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#S,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const E=this.#me();E&&(B(E.invalidateHandles)&&E.invalidateHandles(),B(E.invalidate)&&E.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#I,inline:this.#D,storeBacked:this.#L}}#Y(E,T){if(!E)return;const L=E.rows;if(L&&L.length&&this.#J(L))return this.#Ae(E,T);const C=I();L&&L.length&&(this.#Z(L),this.#D++),this.#V(E),this.#f+=I()-C,this.#v()}#V(E){this.#c.loaded=E.progress&&typeof E.progress.loaded=="number"?E.progress.loaded:this.#n.length,E.progress&&typeof E.progress.estimated=="number"&&(this.#c.estimated=E.progress.estimated)}#J(E){if(this.#_||this.#g)return!1;const T=this.#ie();if(!T)return!1;const L=this.#t.store;if(!L||!B(L.appendPacked))return!1;const C=this.#ne();return!C||!c(C)?(this.#_=!0,z("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):E.length<T.threshold?!1:!this.#q(E)}#q(E){if(!this.#s.keyed)return!1;const T=new Set;for(let L=0;L<E.length;L++){const C=this.#s.keyOf(E[L],this.#n.length+L);if(C!=null){if(T.has(C)||this.#a.has(C))return!0;T.add(C)}}return!1}async#Ae(E,T){const L=E.rows,C=this.#ie(),D=this.#ne();let $;try{$=await C.columnize(D,L,{key:"ingest:stream",signal:T&&T.signal})}catch(q){if(u(q)||(H("source.stream.columnize","worker columnization failed; columnizing on the main thread",q),this.#_=!0,T&&(!T.current||this.#k)))return;this.#Z(L),this.#D++,this.#V(E),this.#v();return}if(T&&(!T.current||this.#k))return;const P=this.#t.store,v=this.#L?void 0:L,{from:N}=P.appendPacked($,v),G=$.count|0;for(let q=0;q<G;q++){const Z=N+q,J=L[q],ee=this.#s.keyed?this.#s.keyOf(J,Z):null;if(this.#n[Z]=this.#L?s:J,this.#S++,this.#ae(Z,J),ee!==null&&this.#a.set(ee,Z),!this.#r||!this.#U(Z))continue;const ne=this.#R(Z);this.#r.insert(ne,Z),ne<=this.#p&&this.#m++}this.#O=!0,this.#pe(),this.#I++,this.#V(E),this.#v()}#ie(){const E=this.#t.ingestWorker;return B(E)?E():null}#ne(){const E=this.#t.storeSchema;return B(E)?E():null}#Z(E){const T=[],L=this.#t.store,C=new Array(E.length),D=[],$=new Set;for(let v=0;v<E.length;v++){const N=this.#s.keyed?this.#s.keyOf(E[v],this.#n.length+D.length):null;C[v]=N,!(N!==null&&(this.#a.has(N)||$.has(N)))&&(N!==null&&$.add(N),D.push(E[v]))}let P=D.length&&L&&B(L.append)?L.append(D).from:this.#n.length;for(let v=0;v<E.length;v++){const N=E[v],G=C[v];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),ee=this.#de(J);this.#L||(this.#n[J]=N,L&&B(L.setSource)&&L.setSource(J,N)),this.#Qe(J,N),this.#l.delete(J),this.#ae(J,N),this.#ce(J,ee);continue}const q=P++;if(this.#n[q]=this.#L?s:N,this.#S++,this.#ae(q,N),G!==null&&this.#a.set(G,q),T.push(q),!this.#r||!this.#U(q))continue;const Z=this.#R(q);this.#r.insert(Z,q),Z<=this.#p&&this.#m++}return this.#O=!0,this.#pe(),T}#Me(E){const T=this.#n[E];let L=!1;if(this.#r){const P=this.#we(E);P>=0&&P<=this.#p&&(L=!0)}else E<=this.#p&&(L=!0);const C=T===s?this.#je(E):T,D=this.#s.keyed?this.#s.keyOf(C,E):null;D!==null&&this.#a.get(D)===E&&this.#a.delete(D),this.#n[E]=void 0,this.#P&&(this.#P[E]=NaN),this.#l.delete(E);const $=this.#t.store;return $&&B($.remove)&&$.remove(E),this.#S--,L}#pe(){let E=0,T=0;const L=this.#oe();E+=L.dropped,T+=L.aboveAnchor;const C=this.#he();E+=C.dropped,T+=C.aboveAnchor,E&&(this.#O=!0,this.#E+=E,this.#le(),this.#m-=T,this.#W("stream:evicted",{evicted:E,total:this.#E,live:this.#S}))}#he(){const E=this.#e.maxRows;if(!Number.isFinite(E)||E<=0||this.#S<=E)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(E*(1-b)));let L=0,C=0;for(;this.#S>T&&this.#T<this.#n.length;){const D=this.#T++;this.#n[D]!==void 0&&(this.#Me(D)&&C++,L++)}return{dropped:L,aboveAnchor:C}}#oe(){const E=this.#X();if(!E||!this.#P||!this.#se())return{dropped:0,aboveAnchor:0};const T=Date.now()-E;let L=0,C=0,D=1/0;for(let $=this.#T;$<this.#n.length;$++){if(this.#n[$]===void 0)continue;const P=this.#P[$];if(!(Number.isNaN(P)||P===void 0)){if(P>=T){P<D&&(D=P);continue}this.#Me($)&&C++,L++}}for(this.#M=D,this.#N=!1;this.#T<this.#n.length&&this.#n[this.#T]===void 0;)this.#T++;return{dropped:L,aboveAnchor:C}}#we(E){if(!this.#r)return E;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===E)return T;return-1}#le(){this.#o=this.#be("sort",[]),this.#i=this.#be("filters",null);const E=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#X()>0,T=this.#be("where",null),L=(this.#t.config||{}).hostFilter,C=!!(T&&T.active)||!!(L&&B(L.active)&&L.active());if(!(E||this.#o.length>0||!!this.#i||!!this.#be("quick","")||C)){this.#r=null;return}this.#r=new n(Math.max(64,this.#n.length+64));for(let $=0;$<this.#n.length;$++)this.#n[$]!==void 0&&this.#U($)&&this.#r.insert(this.#R($),$)}#U(E){const T=this.#je(E);if(this.#i&&!this.#F(this.#i,T))return!1;const L=String(this.#be("quick","")||"").toLowerCase();if(L&&!this.#We(T).includes(L))return!1;const C=(this.#t.config||{}).hostFilter;if(C&&B(C.active)&&C.active()&&!C.passes(this.#ye(E)))return!1;const D=this.#be("where",null);if(D&&D.active){const $=this.#ye(E);if(!D.passes($.data,$.key))return!1}return!0}#F(E,T){if(!E)return!0;const L=E;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some($=>this.#F($,T)):L.op==="not"?!L.conditions.some($=>this.#F($,T)):L.conditions.every($=>this.#F($,T));const C=E,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#Pe(T,C.col),C,(this.#t.config||{}).locale):(H("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#de(E){if(!this.#r)return-1;if(!this.#o.length)return this.#we(E);let T=0,L=this.#r.length;for(;T<L;){const C=T+L>>>1;this.#K(this.#r.at(C),E)<0?T=C+1:L=C}for(let C=T;C<this.#r.length;C++){const D=this.#r.at(C);if(D===E)return C;if(this.#K(D,E)>0)break}return this.#we(E)}#ce(E,T){if(!this.#r||!this.#o.length)return;const L=this.#U(E);if(T>=0&&this.#r.at(T)===E)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!L)return;const C=this.#R(E);this.#r.insert(C,E),C<=this.#p&&this.#m++}#R(E){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let T=0,L=this.#r.length;for(;T<L;){const C=T+L>>>1;this.#K(E,this.#r.at(C))<0?L=C:T=C+1}return T}#K(E,T){const L=this.#je(E),C=this.#je(T);for(const D of this.#o){const $=this.#_e(D.col),P=this.#Pe(L,D.col),v=this.#Pe(C,D.col),G=($&&$.value&&B($.value.compare)?$.value.compare:V)(P,v);if(G!==0)return D.dir==="desc"?-G:G}return 0}#fe(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const E=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:f;!this.#L&&this.#n.length<E&&(this.#g=d({mode:"memory",rows:this.#n},this.#t),this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#v(),this.#W("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:E})}#v(){this.#d!==null||this.#k||(this.#d=this.#Ge(()=>{this.#d=null,this.#h++;const E=this.#m;this.#m=0,this.#f=0,this.#W("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#W("model:changed",{reason:"stream",shiftAboveViewport:E,anchor:this.#p}),this.#W("rows:changed",{companion:!0,reason:"stream"})}))}#ve(){return this.#h===0||this.#f<this.#Be()?Promise.resolve():(this.#f=0,new Promise(E=>{const T=(this.#t.scheduler||{}).idle;B(T)?T(()=>E()):W(()=>E())}))}#Be(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#Ge(E){const T=this.#t.scheduler||{};return B(T.frame)?T.frame(E):_(E)}#Ke(E){const T=this.#t.scheduler||{};B(T.cancel)?T.cancel(E):X(E)}#je(E){const T=this.#n[E];if(T!==void 0&&T!==s)return T;if(T===void 0)return;const L=this.#t.store;return L&&B(L.source)?L.source(E):void 0}#Qe(E,T){const L=this.#t.store;if(!L||!B(L.set))return;const C=this.#ne();if(Array.isArray(C))for(const D of C){if(!D||!D.id)continue;const $=B(D.read)?D.read:P=>w(P,D.field||D.id);L.set(D.id,E,$(T))}}#ye(E){let T=this.#l.get(E);return T||(T=this.#s.leaf(this.#je(E),E),this.#l.set(E,T)),T}#Pe(E,T){const L=this.#_e(T);return L&&B(L.getValue)?L.getValue(E):E?.[T]}#We(E){const T=this.#t.columns,L=T&&B(T.all)?T.all():[],C=[];for(const D of L){const $=B(D.getValue)?D.getValue(E):void 0;$!=null&&$!==""&&C.push(String($))}return C.join(" ").toLowerCase()}#_e(E){const T=this.#t.columns;return T&&B(T.get)?T.get(E):void 0}#Fe(){const E=this.#H;if(this.#H=null,E&&B(E.return))try{E.return()}catch{}}#Je(){return i({context:this.#be("context",null)})}#be(E,T){const L=this.#t.state;if(L&&B(L[E])){const C=L[E]();return C??T}return T}#W(E,T){const L=this.#t.emit;B(L)&&L(E,T)}}}),Le("packages/core/src/source/url.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isObject,I=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,V=500,H=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),z=Symbol("lattice.url.skip");function w(c,f={}){const s=B(f)?f:{},p=I(s.fetch)?s.fetch:typeof globalThis<"u"&&I(globalThis.fetch)?globalThis.fetch:null,b=s.format==="json"||s.format==="ndjson"?s.format:void 0,A=typeof s.rowsPath=="string"&&s.rowsPath?s.rowsPath:void 0,k=I(s.map)?s.map:void 0,y=B(s.headers)?s.headers:void 0,S=Number.isFinite(s.batchSize)&&s.batchSize>0?Math.floor(s.batchSize):V,R=s.lenient===!0,O=Number.isFinite(s.poll)&&s.poll>0?Math.floor(s.poll):void 0,F=typeof c=="string"&&c.length>0;F||x("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(L={}){if(!F)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const C=L&&L.signal;let D;try{D=await p(c,y?{signal:C,headers:y}:{signal:C})}catch(v){throw W(v)?v:new Error(`[lattice] createUrlSource: request to ${c} failed — ${v&&v.message||v}`)}if(!D||!D.ok){const v=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${v} for ${c}`)}const $=j(c,b,D),P=D.body&&I(D.body.getReader)?D.body.getReader():null;try{if(!P){const G=await D.text();($||h(G,c))==="ndjson"?yield*d(null,null,G,0,D,c,S,R):yield*o(G,c,A,k);return}const v=new TextDecoder("utf-8");if($==="json"){yield*o(await n(P,v,""),c,A,k);return}if($==="ndjson"){yield*d(P,v,"",0,D,c,S,R);return}const N=await a(P,v,c);N.format==="json"?yield*o(await n(P,v,N.seed),c,A,k):yield*d(P,v,N.seed,N.bytes,D,c,S,R)}finally{if(P&&I(P.cancel))try{await P.cancel()}catch{}}}const T={mode:"stream",open:E,autoStart:s.autoStart!==!1};return O!==void 0&&(T.poll=O),Number.isFinite(s.maxRows)&&(T.maxRows=s.maxRows),Number.isFinite(s.maxAge)&&(T.maxAge=s.maxAge),(typeof s.ageBy=="string"||I(s.ageBy))&&(T.ageBy=s.ageBy),Number.isFinite(s.coalesceMs)&&(T.coalesceMs=s.coalesceMs),Number.isFinite(s.promoteToMemoryBelow)&&(T.promoteToMemoryBelow=s.promoteToMemoryBelow),T}function j(c,f,s){if(f)return f;const p=g(c);if(p)return p;const b=s&&s.headers&&I(s.headers.get)?s.headers.get("content-type"):null;return u(b)}function g(c){const f=String(c).split(/[?#]/)[0].toLowerCase();if(f.endsWith(".ndjson")||f.endsWith(".jsonl"))return"ndjson";if(f.endsWith(".json"))return"json"}function u(c){if(!c)return;const f=c.split(";")[0].trim().toLowerCase();if(H.has(f))return"ndjson";if(f==="application/json"||f==="text/json"||f.endsWith("+json"))return"json"}function h(c,f){const s=c.replace(/^\s+/,""),p=r(s);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${f} — pass opts.format: 'json' | 'ndjson'.`);return p}async function a(c,f,s){let p="",b=0;for(;;){const{value:k,done:y}=await c.read();if(k&&(b+=k.byteLength,p+=f.decode(k,{stream:!0})),y){p+=f.decode();break}const S=p.replace(/^\s+/,"");if(S){if(S[0]==="[")return{format:"json",seed:p,bytes:b};if(S[0]!=="{"||p.indexOf(`
|
|
8
8
|
`)!==-1)break}}const A=r(p.replace(/^\s+/,""));if(A==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${s} — pass opts.format: 'json' | 'ndjson'.`);return{format:A,seed:p,bytes:b}}function r(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const f=c.indexOf(`
|
|
9
9
|
`);if(f===-1)return"json";let s=c.slice(0,f);return s.endsWith("\r")&&(s=s.slice(0,-1)),t(s)?"ndjson":"json"}function t(c){try{return JSON.parse(c),!0}catch{return!1}}async function n(c,f,s){let p=s;for(;;){const{value:b,done:A}=await c.read();if(b&&(p+=f.decode(b,{stream:!0})),A)break}return p+=f.decode(),p}function*o(c,f,s,p){let b;try{b=JSON.parse(c)}catch(k){throw new Error(`[lattice] createUrlSource: ${f} is not valid JSON — ${k.message}`)}let A=s!==void 0?_(b,s):b;if(p&&(A=p(A)),!Array.isArray(A)){const k=s!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${f} did not resolve to an array${k}.`)}yield{rows:A,progress:{loaded:A.length,estimated:A.length}}}async function*d(c,f,s,p,b,A,k,y){const S=m(b);let R=s||"",O=p||0,F=0,E=0,T=[];function*L(){let D;for(;(D=R.indexOf(`
|
|
@@ -54,6 +54,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
54
54
|
`,b),R=s.slice(y,S),O=R.split(`
|
|
55
55
|
`);let F=0;const E=O.map(T=>{if(!c)return F+=A.length,A+T;if(T.startsWith(A))return F-=A.length,T.slice(A.length);const L=T.replace(/^[ \t]/,"");return F-=T.length-L.length,L}).join(`
|
|
56
56
|
`);return E===R?!1:(f.value=s.slice(0,y)+E+s.slice(S),this.#r(Math.max(y,p+(c?-A.length:A.length)),Math.max(y,b+F)),this.revalidate(),!0)}#r(c,f){const s=this.input;s&&(s.selectionStart=c,s.selectionEnd=f===void 0?c:f,W(s.setSelectionRange)&&s.setSelectionRange(s.selectionStart,s.selectionEnd))}format(c){const f=this.input;if(!f||this.language!=="json")return!1;const s=a(f.value);if(!s.ok)return this.revalidate(),!1;if(s.value===null&&f.value.trim()==="")return!1;try{const p=JSON.stringify(s.value,null,c===void 0?this.indent:c);return p===void 0?!1:(f.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",f=o(c,this.language);this.lastResult=f;const s=this.errorNode;return s&&(s.textContent=f.ok?"":d(f),s.classList.toggle(w.errorOn,!f.ok)),this.input&&(f.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),f.ok||!s?this.input.removeAttribute("aria-errormessage"):(s.id||(s.id=V("lat-err")),this.input.setAttribute("aria-errormessage",s.id))),f}text(){return this.input?this.input.value:""}readValue(){const c=this.text();if(c.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return c;const s=a(c);return s.ok?s.value:c}checkValue(c){if(this.props.allowInvalid===!0)return!0;const f=this.revalidate();return f.ok?!0:d(f)}toClipboard(){return this.text()}fromClipboard(c){const f=c==null?"":String(c);return this.input&&(this.input.value=f),this.revalidate(),f.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:f}:{ok:!0,value:z(f)}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=l}),Le("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/unit.js"),H=V.parseUnit,z=V.formatUnit,w=V.findUnit;function j(h,a){return z(h,a)}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.props,r=this.params.column&&this.params.column.dataType||null,t=r&&r.unitConfig||{};return{system:a.system||t.system||"data",unit:a.unit??t.unit,binary:a.binary===!0||a.binary===void 0&&t.binary===!0,display:a.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const a=this.props;this.opts=this.buildOptions();const r=this.symbol(),t=`${this.id}-unit`,n=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":r?t:null}});n.value=j(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const o=typeof a.step=="number"?a.step:0;return o>0&&this.#e.push(_(n,"keydown",d=>{d.key==="ArrowUp"?(W(d.preventDefault)&&d.preventDefault(),this.nudge(o)):d.key==="ArrowDown"&&(W(d.preventDefault)&&d.preventDefault(),this.nudge(-o))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:r,attrs:{id:t,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[n,this.hint]})}symbol(){const a=w(this.opts.system,this.opts.unit);return a?a.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=H(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:o}=this.props;typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=j(t,this.opts))}readValue(){const a=this.input?this.input.value:"";if(String(a).trim()==="")return null;const r=H(a,this.opts);if(r===null)return NaN;if(this.mode()!=="clamp")return r;const{min:t,max:n}=this.props;let o=r;return typeof t=="number"&&o<t&&(o=t),typeof n=="number"&&o>n&&(o=n),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a)){const r=this.symbol();return r?`Enter a value such as 10 ${r}`:"Enter a value"}if(this.mode()==="reject"){const{min:r,max:t}=this.props;if(typeof r=="number"&&a<r)return`Must be ${this.describe(r)} or more`;if(typeof t=="number"&&a>t)return`Must be ${this.describe(t)} or less`}return!0}describe(a){return z(a,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return z(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(a){const r=a==null?"":String(a);if(r.trim()==="")return{ok:!0,value:null};const t=H(r,this.opts),n=t===null?NaN:t,o=this.checkValue(n);return o!==!0?{ok:!1,message:o}:{ok:!0,value:n}}destroy(){for(const a of this.#e)a();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const u=g}),Le("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,V=X.uid,H=K("packages/core/src/columns/types/radix.js"),z=H.compileRadixFormat,w=H.compileRadixParse,j=H.normaliseRadixOptions,g=H.radixRange,u=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),h=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),a=new Map;function r(d){const l=d||"";let i=a.get(l);if(i)return i;try{i=new Intl.NumberFormat(d||void 0,{maximumFractionDigits:0})}catch{i={format:m=>String(m)}}return a.set(l,i),i}function t(d,l){const i=l||{},m={};if(d){for(const f of h)d[f]!==void 0&&(m[f]=d[f]);const c=g(d.bitWidth??null,d.signed!==!1);typeof d.min=="number"&&d.min>c.min&&(m.min=d.min),typeof d.max=="number"&&d.max<c.max&&(m.max=d.max)}for(const c of h)i[c]!==void 0&&(m[c]=i[c]);return typeof i.min=="number"&&(m.min=i.min),typeof i.max=="number"&&(m.max=i.max),j(m)}class n extends x{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const l=this.params.column&&this.params.column.dataType;this.options=t(l&&l.radix||null,this.props),this.format=z(this.options),this.parse=w(this.options);const i=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const m=I(this.doc,"span",{class:u.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(i,"input",()=>this.refresh())),this.#e.push(_(i,"keydown",f=>this.#n(f)));const c=I(this.doc,"div",{class:u.root,children:[i,m]});return this.refresh(),c}focusTarget(){return this.input}attached(){super.attached();const l=this.input;l&&!this.params.key&&this.props.selectOnFocus!==!1&&W(l.select)&&l.select()}#t(l){return l.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(l)}#n(l){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;l.key==="ArrowUp"?(W(l.preventDefault)&&l.preventDefault(),this.nudge(i)):l.key==="ArrowDown"&&(W(l.preventDefault)&&l.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(l){const{min:i,max:m}=this.options;return l<i?i:l>m?m:l}evaluate(){const l=this.input?String(this.input.value):"";if(l.trim()==="")return{value:null,message:null};const i=this.parse(l);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(l){const i=this.options;return l==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:l==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:l,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=V("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(u.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(u.hintInvalid),this.hint.textContent=l===null?"":`= ${r(this.params.locale).format(l)}`}}nudge(l){if(!this.input)return;const i=this.parse(this.input.value);let m;typeof i.value=="number"?m=i.value:typeof this.params.value=="number"?m=this.params.value:m=0,this.input.value=this.format(this.clamp(m+l)),this.refresh()}readValue(){return this.evaluate().value}checkValue(l){return l===null?!0:typeof l!="number"||Number.isNaN(l)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&l<0?this.messageFor("negative"):this.mode()==="reject"&&(l<this.options.min||l>this.options.max)?this.messageFor("range"):!0}toClipboard(){const l=this.readValue();return l===null||Number.isNaN(l)?this.input?String(this.input.value):"":this.format(l)}fromClipboard(l){const i=l==null?"":String(l);if(i.trim()==="")return{ok:!0,value:null};const m=this.parse(i);let c;if(m.ok)c=m.value;else if(this.mode()==="clamp"&&typeof m.value=="number"&&(m.reason==="range"||m.reason==="negative"))c=this.clamp(m.value);else return{ok:!1,message:this.messageFor(m.reason)};const f=this.checkValue(c);return f!==!0?{ok:!1,message:f}:{ok:!0,value:c}}destroy(){for(const l of this.#e)l();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=n}),Le("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,V=Q.documentFor,H=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,h=K("packages/dom/src/cell/icons.js").createIcon,a=6;class r extends x{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(d){const l=d||{},i=t(l),m=H(l,i,{colId:l.column&&(l.column.id||l.column.field)}),c=Number(i.max??a),f=m.options().length;if(Number.isFinite(c)&&f>c){const s=new w;s.init(l),this.#e=s,this.params=l,this.doc=V(l),this.props=i,this.lookup=m,this.popup=s.popup;return}super.init(l),(!this.lookup||!this.lookup.options().length)&&(this.lookup=m)}usesFallback(){return this.#e!==null}build(){const d=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const l=I(d,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&l.appendChild(this.buildClear()),this.#t.push(_(l,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),l}buildSegment(d,l){const i=this.doc,m=I(i,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":l,"data-variant":d.variant??null,"aria-disabled":d.disabled===!0?"true":null}});return d.icon&&m.appendChild(h(i,d.icon,{className:B.icon})),m.appendChild(I(i,"span",{class:`${B.editor}__segment-label`,text:d.label})),this.#t.push(_(m,"mousedown",c=>{c&&g(c.preventDefault)&&c.preventDefault(),d.disabled!==!0&&(this.focused=l,this.select(l,{commit:!0}))})),this.segments.push(m),m}buildClear(){const d=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(d,"mousedown",l=>{l&&g(l.preventDefault)&&l.preventDefault(),this.clearSelection()})),d}indexOf(d){if(d==null)return-1;const l=X(d);for(let i=0;i<this.options.length;i++)if(X(this.options[i].id)===l)return i;return-1}paint(){for(let d=0;d<this.segments.length;d++){const l=d===this.indexOf(this.selected),i=this.segments[d];i.setAttribute("aria-checked",l?"true":"false"),i.setAttribute("tabindex",d===this.focused?"0":"-1"),i.classList.toggle(`${B.editor}__segment--active`,l),i.classList.toggle(`${B.editor}__segment--disabled`,this.options[d].disabled===!0)}}select(d,l){const i=this.options[d];!i||i.disabled===!0||(this.selected=i.id,this.paint(),l&&l.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(d){const l=this.segments.length;if(!l)return;let i=this.focused;for(let m=0;m<l;m++)if(i=(i+d+l)%l,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(d){if(d<0||d>=this.segments.length)return;this.focused=d,this.paint();const l=this.segments[d];l&&g(l.focus)&&l.focus()}edgeIndex(d){const l=this.options.length;for(let i=0;i<l;i++){const m=d===1?i:l-1-i;if(this.options[m].disabled!==!0)return m}return-1}onKeyDown(d){const l=()=>{g(d.preventDefault)&&d.preventDefault()};switch(d.key){case"ArrowRight":case"ArrowDown":l(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":l(),this.moveFocus(-1);break;case"Home":l(),this.focusAt(this.edgeIndex(1));break;case"End":l(),this.focusAt(this.edgeIndex(-1));break;case"Enter":l(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":l(),this.select(this.focused);break;case"Escape":l(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(d){return d==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(d)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(d)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const d=this.indexOf(this.selected);return this.segments[d>=0?d:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const d=this.lookup.ready();!d||!g(d.then)||d.then(()=>{if(!super.element()||this.options.length)return;const l=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(d){return this.#e?this.#e.validate(d):super.validate(d)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(d){return this.#e?this.#e.fromClipboard(d):super.fromClipboard(d)}destroy(){for(const d of this.#t)d();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const n=r}),Le("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/dom/src/cell/icons.js").createIcon,V=K("packages/dom/src/cell/renderers/rating.js"),H=V.ratingFills,z=V.fillState,w=V.ratingText,j=V.clampRating,g=V.DEFAULT_RATING_ICON,u=V.DEFAULT_RATING_MAX,a=K("packages/core/src/internal/util.js").isFunction;class r extends x{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const d=Math.floor(Number(this.props.max??u));return Number.isFinite(d)&&d>0?d:u}step(){return this.props.allowHalf===!0?.5:1}build(){const d=this.doc,l=this.max();this.rating=t(this.params.value,l,this.props.allowHalf===!0);const i=I(d,"div",{class:`${B.editor}__rating`}),m=I(d,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(l),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let f=0;f<l;f++)m.appendChild(this.buildItem(f));i.appendChild(m),this.slider=m;const c=I(d,"span",{class:`${B.editor}__rating-value`});return i.appendChild(c),this.readout=c,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(_(m,"keydown",f=>this.onKeyDown(f))),this.props.hoverPreview!==!1&&this.#e.push(_(m,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),l)),this.paint(),i}buildItem(d){const l=this.doc,i=String(this.props.icon??g),m=I(l,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(l,i,{className:B.icon})]}),c=I(l,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":d,"data-icon":i,"aria-hidden":"true"},children:[W(l,i,{className:B.icon}),m]});return this.fills.push(m),this.#e.push(_(c,"mousedown",f=>{f&&a(f.preventDefault)&&f.preventDefault(),this.setRating(this.ratingAt(d,f),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",f=>{const s=this.ratingAt(d,f);s!==this.preview&&(this.preview=s,this.paint())})),this.items.push(c),c}buildClear(){const d=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(d,"mousedown",l=>{l&&a(l.preventDefault)&&l.preventDefault(),this.setRating(null)})),d}ratingAt(d,l){if(this.props.allowHalf!==!0)return d+1;const i=this.items[d],m=i&&Number(i.offsetWidth),c=l&&Number(l.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(c)?d+1:c*2<m?d+.5:d+1}focusTarget(){return this.slider}setRating(d,l){this.rating=d===null?null:j(d,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),l&&l.commit&&this.commit()}nudge(d){const l=this.rating===null?0:this.rating;this.setRating(l+d)}paint(){const d=this.max(),l=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,m=H(i===null?0:i,d,{allowHalf:l});for(let s=0;s<this.items.length;s++){const p=z(m[s]);this.items[s].setAttribute("data-fill",p),this.items[s].classList.toggle(`${B.editor}__rating-item--filled`,p!=="empty"),this.fills[s]&&this.fills[s].style.setProperty("--lat-rating-fill",`${(m[s]*100).toFixed(2)}%`)}const c=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(i),max:d}),f=this.slider;f&&(f.setAttribute("aria-valuenow",i===null?"0":String(i)),f.setAttribute("aria-valuetext",c),f.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(d){const l=()=>{a(d.preventDefault)&&d.preventDefault()},i=this.step();if(/^[0-9]$/.test(d.key)){l(),this.setRating(Math.min(Number(d.key),this.max()));return}switch(d.key){case"ArrowRight":case"ArrowUp":l(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":l(),this.nudge(-i);break;case"Home":l(),this.setRating(0);break;case"End":l(),this.setRating(this.max());break;case"Enter":l(),this.commit();break;case"Escape":l(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(d){if(d==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof d!="number"||!Number.isFinite(d))return"Enter a rating";const l=this.max();return d<0?"Must be 0 or more":d>l?`Must be ${l} or less`:this.props.allowHalf!==!0&&!Number.isInteger(d)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":w(this.rating)}fromClipboard(d){const l=String(d??"").trim();if(l==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(l);if(!Number.isFinite(i))return{ok:!1,message:`"${l}" is not a rating`};const m=this.checkValue(i);return m!==!0?{ok:!1,message:m}:{ok:!0,value:i}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(o,d,l){if(o==null||o==="")return null;const i=Number(o);return Number.isFinite(i)?j(i,d,l,!1):null}const n=r}),Le("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/editors/number.js"),W=X.parseNumberText,V=X.presentNumber,z=K("packages/core/src/internal/util.js").isFunction,w=0,j=100;class g extends x{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const n=Number(this.props.min??w);return Number.isFinite(n)?n:w}max(){const n=Number(this.props.max??j);return Number.isFinite(n)?n:j}step(){const n=Number(this.props.step??1);return Number.isFinite(n)&&n>0?n:1}build(){const n=this.doc,o=this.min(),d=this.max(),l=this.step(),i=a(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=I(n,"div",{class:`${B.editor}__slider`});this.root=m;const c=I(n,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(d),step:String(l),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=c,m.appendChild(c),i.length){const s=I(n,"datalist",{attrs:{id:`${this.id}-marks`}}),p=I(n,"div",{class:`${B.editor}__slider-marks`});for(const b of i){s.appendChild(I(n,"option",{attrs:{value:String(b.value),label:b.label}}));const A=I(n,"span",{class:`${B.editor}__slider-mark`,text:b.label,attrs:{"data-value":String(b.value)}});A.style&&z(A.style.setProperty)&&A.style.setProperty("--lat-slider-mark",`${(u(b.value,o,d)*100).toFixed(2)}%`),p.appendChild(A)}m.appendChild(s),m.appendChild(p)}const f=I(n,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=f,m.appendChild(f),this.props.showValue!==!1){const s=I(n,"span",{class:`${B.editor}__slider-value`});m.appendChild(s),this.readout=s}return this.#e.push(_(c,"input",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"change",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"keydown",s=>this.onKeyDown(s))),this.#e.push(_(f,"input",()=>this.onFieldInput())),this.#e.push(_(f,"change",()=>this.paint())),this.#e.push(_(f,"keydown",s=>this.onKeyDown(s))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(f.value=this.params.key,this.onFieldInput()),this.paint(),m}focusTarget(){return this.field}attached(){super.attached();const n=this.field;n&&!this.params.key&&this.props.selectOnFocus!==!1&&z(n.select)&&n.select()}snap(n){if(!Number.isFinite(n))return this.min();const o=this.min(),d=this.max(),l=this.step(),i=Math.min(Math.max(n,o),d),m=o+Math.round((i-o)/l)*l,c=h(l),f=c>0?Number(m.toFixed(c)):Math.round(m);return Math.min(Math.max(f,o),d)}setAmount(n,o){this.amount=n===null?null:this.snap(n),this.paint(o)}onFieldInput(){const n=this.field?String(this.field.value):"";if(n.trim()===""){this.amount=null,this.paint("field");return}const o=W(n,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(n){const o=this.min(),d=this.max(),l=this.amount,i=l===null?o:l;this.range&&n!=="range"&&(this.range.value=String(i)),this.field&&n!=="field"&&(this.field.value=l===null?"":V(l,this.props));const m=this.root;m&&m.style&&z(m.style.setProperty)&&m.style.setProperty("--lat-slider-pos",`${(u(i,o,d)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",l===null?"true":"false");const c=this.labelFor(l);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(n){if(n===null)return String(this.props.emptyLabel??"");const o=this.marks.find(l=>l.value===n),d=V(n,this.props);return o&&o.label!==d?`${d} (${o.label})`:d}onKeyDown(n){if(n.key==="Escape"){z(n.preventDefault)&&n.preventDefault(),this.cancel();return}if(n.key==="Enter"){z(n.preventDefault)&&n.preventDefault(),this.commit();return}n.key==="Tab"&&this.commit()}readValue(){const n=this.field?String(this.field.value):"";if(n.trim()==="")return null;const o=W(n,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof n!="number"||Number.isNaN(n)?"Enter a number":n<this.min()?`Must be ${this.min()} or more`:n>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(n){const o=String(n??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const d=W(o,this.params.locale);if(d===null||Number.isNaN(d))return{ok:!1,message:"Enter a number"};const l=this.snap(d),i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function u(t,n,o){const d=o-n;return!Number.isFinite(d)||d===0?0:Math.min(1,Math.max(0,(Number(t)-n)/d))}function h(t){if(!Number.isFinite(t))return 0;const n=String(t),o=n.indexOf("e");if(o>=0){const l=n.slice(0,o),i=l.indexOf("."),m=i<0?0:l.length-i-1;return Math.min(15,Math.max(0,m-Number(n.slice(o+1))))}const d=n.indexOf(".");return d<0?0:Math.min(15,n.length-d-1)}function a(t){if(!t)return[];const n=[];if(Array.isArray(t)){for(const o of t){if(o&&typeof o=="object"){const l=Number(o.value);Number.isFinite(l)&&n.push({value:l,label:String(o.label??l)});continue}const d=Number(o);Number.isFinite(d)&&n.push({value:d,label:String(d)})}return n}if(typeof t=="object")for(const[o,d]of Object.entries(t)){const l=Number(o);Number.isFinite(l)&&n.push({value:l,label:String(d)})}return n}const r=g}),Le("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,X=K("packages/dom/src/cell/renderers/colour.js"),W=X.normaliseColour,V=X.parseColour,z=K("packages/core/src/internal/util.js").isFunction,w=Object.freeze(["neutral","info","success","warning","danger","accent"]),j=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(n){if(n==null)return null;if(typeof n=="object"){const l=n,i=g(l.token??l.value??l.colour??l.color);return i?{...i,label:l.label==null?i.label:String(l.label)}:null}const o=String(n).trim();if(o==="")return null;const d=W(o);return d?{token:null,hex:d,label:d}:Object.hasOwn(j,o)?{token:o,hex:j[o],label:o}:null}function u(n,o){const d=n&&n.ownerDocument,l=d&&d.defaultView;if(!l||!z(l.getComputedStyle))return null;try{const i=l.getComputedStyle(n);return!i||!z(i.getPropertyValue)?null:W(String(i.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class h extends x{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const o=this.doc;this.swatches=a(this.props.swatches);const d=I(o,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=I(o,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),d.appendChild(this.preview),this.swatches.length){const i=I(o,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)i.appendChild(this.buildSwatch(this.swatches[m],m));d.appendChild(i)}this.native=I(o,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),d.appendChild(this.native),this.hex=I(o,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),d.appendChild(this.hex),this.props.allowClear===!0&&d.appendChild(this.buildClear()),this.#e.push(_(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.hex,"input",()=>this.paint())),this.#e.push(_(this.hex,"change",()=>this.paint())),this.#e.push(_(this.hex,"keydown",i=>this.onKeyDown(i))),this.#e.push(_(d,"keydown",i=>this.onKeyDown(i)));const l=W(this.params.value,{alpha:this.alpha()});return this.hex.value=l===null?this.params.value==null?"":String(this.params.value):l,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),d}buildSwatch(o,d){const l=I(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":d,"data-variant":o.token}});return o.token||r(l,o.hex),this.#e.push(_(l,"mousedown",i=>{i&&z(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[d].hex)})),this.buttons.push(l),l}buildClear(){const o=I(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(o,"mousedown",d=>{d&&z(d.preventDefault)&&d.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const d=this.swatches[o];if(!d.token)continue;const l=u(this.buttons[o]||this.element(),d.token);l&&(d.hex=l)}this.paint()}setColour(o){const d=o===null?null:W(o,{alpha:this.alpha()});this.hex&&(this.hex.value=d===null?"":d),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:W(o,{alpha:this.alpha()})}paint(){const o=this.current(),d=o===null?null:o.slice(0,7);r(this.preview,d),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=d===null?"#000000":d);for(let l=0;l<this.buttons.length;l++){const i=o!==null&&this.swatches[l].hex.toLowerCase()===o.toLowerCase();this.buttons[l].setAttribute("aria-checked",i?"true":"false"),this.buttons[l].classList.toggle(`${B.editor}__colour-swatch--selected`,i),this.swatches[l].token||r(this.buttons[l],this.swatches[l].hex)}}onKeyDown(o){if(o.key==="Escape"){z(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){z(o.preventDefault)&&o.preventDefault(),this.commit();return}o.key==="Tab"&&this.commit()}readValue(){const o=this.hex?String(this.hex.value).trim():"";if(o==="")return null;const d=W(o,{alpha:this.alpha()});return d===null?o:d}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const d=V(o);return d?!this.alpha()&&d.a<1?"This column does not accept transparency":!0:`"${String(o)}" is not a colour`}toClipboard(){const o=this.current();return o===null?"":o}fromClipboard(o){const d=String(o??"").trim();if(d==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const l=W(d,{alpha:this.alpha()});if(l===null)return{ok:!1,message:`"${d}" is not a colour`};const i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function a(n){const o=Array.isArray(n)&&n.length?n:n===!1?[]:w,d=[];for(const l of o){const i=g(l);i&&d.push(i)}return d}function r(n,o){const d=n&&n.style;if(d){if(o===null){z(d.removeProperty)&&d.removeProperty("--lat-swatch");return}z(d.setProperty)&&d.setProperty("--lat-swatch",o)}}const t=h}),Le("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const x=K("packages/dom/src/editors/select.js").SelectEditorBase,I=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),X=_.CLS,W=_.el,V=_.on,H=_.clear,z=_.keyOf,w=_.rawOptions,j=_.lookupKey,g=K("packages/core/src/internal/util.js"),u=g.isFunction,h=g.isObject,a="\0";class r extends x{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const o=super.build();return o.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),o}initSelection(){this.rebuild(),this.selected=this.params.value??null;const o=this.nodeById(this.selected);if(o)for(let d=o.parent;d;d=d.parent)this.expanded.add(d.key)}rebuild(){const o=w(this.params,this.props),d=this.props.keys||{},l=d.value||j(this.params,"valueKey")||"id",i=d.label||j(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of o){if(!h(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,l,i):this.addByChildren(m,null,l,i)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(o,d,l,i){const m=o?`${o.key}${a}${d}`:d;let c=this.nodes.get(m);return c?c.id===void 0&&l!==void 0&&(c.id=l):(c={id:l,label:d,key:m,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(m,c),(o?o.children:this.roots).push(c)),i&&(i.disabled===!0&&(c.disabled=!0),i.icon!==void 0&&(c.icon=i.icon),i.variant!==void 0&&(c.variant=i.variant)),c}addByPath(o,d,l){const i=o.path;let m=null;for(let c=0;c<i.length;c++){const f=c===i.length-1,s=String(i[c]),p=f&&o[l]!=null?String(o[l]):s,b=this.addNode(m,s,f?o[d]:void 0,f?o:null);f&&(b.label=p),m=b}}addByChildren(o,d,l,i){const m=o[l],c=o[i]!=null?String(o[i]):String(m??""),f=this.addNode(d,c,m,o),s=Array.isArray(o.children)?o.children:[];for(const p of s)h(p)?this.addByChildren(p,f,l,i):this.addNode(f,String(p??""),p,null)}nodeById(o){if(o==null)return;const d=z(o);for(const l of this.nodes.values())if(l.id!==void 0&&z(l.id)===d)return l}filterOptions(o){const d=String(o||"").trim().toLowerCase(),l=d!=="";this.matched=l?this.computeMatches(d):new Set;const i=[],m=c=>{for(const f of c)l&&!this.matched.has(f.key)||(i.push(f),f.children.length&&(l||this.expanded.has(f.key))&&m(f.children))};return m(this.roots),i}computeMatches(o){const d=new Set,l=i=>{let m=i.label.toLowerCase().includes(o);for(const c of i.children)l(c)&&(m=!0);return m&&d.add(i.key),m};for(const i of this.roots)l(i);return d}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const d=this.visible.findIndex(l=>l.key===o);d>=0&&this.list.setActive(d)}isBranch(o){return!!o&&o.children.length>0}isSelectable(o){return!o||o.disabled||o.id===void 0||o.id===null?!1:!(this.leavesOnly&&this.isBranch(o))}setExpanded(o,d){this.isBranch(o)&&(d?this.expanded.add(o.key):this.expanded.delete(o.key),this.repaint(o.key))}choose(o){if(o){if(!this.isSelectable(o)){this.isBranch(o)&&this.setExpanded(o,!this.expanded.has(o.key));return}this.selected=o.id,this.input&&(this.input.value=""),this.query="",this.repaint(o.key),this.paintDisplay(),this.commit()}}isSelected(o){return this.selected!=null&&o&&o.id!==void 0&&z(o.id)===z(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const d=this.nodeById(o);return d&&this.isSelectable(d)?!0:d?`"${d.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(o)}" is not a valid option`}renderOption(o,d,l){H(d),d.setAttribute("role","treeitem"),d.setAttribute("aria-level",String(o.depth+1)),d.setAttribute("data-depth",String(o.depth));const i=W(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<o.depth;b++)i.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));d.appendChild(i);const m=this.isBranch(o),c=m&&(this.expanded.has(o.key)||this.query.trim()!==""),f=m?c?"chevronDown":"chevronRight":"blank",s=W(this.doc,"span",{class:m?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[I(this.doc,f,{className:X.icon})],attrs:{"data-icon":m?f:null,"aria-hidden":"true"}});m&&V(s,"mousedown",b=>{u(b.preventDefault)&&b.preventDefault(),u(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),d.appendChild(s),o.icon&&d.appendChild(I(this.doc,o.icon,{className:X.icon})),d.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:o.label})),o.variant?d.setAttribute("data-variant",o.variant):d.removeAttribute("data-variant"),m?d.setAttribute("aria-expanded",c?"true":"false"):d.removeAttribute("aria-expanded");const p=this.isSelected(o);d.classList.toggle(X.optionSelected,p),d.classList.toggle(X.optionDisabled,!this.isSelectable(o)),d.classList.toggle("lat-tree__row--branch",m),d.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(o)?d.removeAttribute("aria-disabled"):d.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(H(o),this.selected==null){o.removeAttribute("data-variant");return}const d=this.nodeById(this.selected);if(!d){o.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}d.icon&&o.appendChild(I(this.doc,d.icon,{className:X.icon})),o.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(d)})),d.variant?o.setAttribute("data-variant",d.variant):o.removeAttribute("data-variant")}pathLabel(o){const d=[];for(let l=o;l;l=l.parent)d.unshift(l.label);return d.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const d=this.list,l=d&&d.active>=0?this.visible[d.active]:null;switch(o.key){case"ArrowRight":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&!this.expanded.has(l.key)?this.setExpanded(l,!0):this.isBranch(l)&&d&&d.setActive(Math.min(this.visible.length-1,d.active+1));return}case"ArrowLeft":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&this.expanded.has(l.key)?this.setExpanded(l,!1):l.parent&&this.focusNode(l.parent.key);return}case"Home":u(o.preventDefault)&&o.preventDefault(),d&&this.visible.length&&d.setActive(0);return;case"End":u(o.preventDefault)&&o.preventDefault(),d&&this.visible.length&&d.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const d=this.visible.findIndex(l=>l.key===o);d>=0&&this.list.setActive(d)}acceptHighlight(o){const d=this.list,l=d&&d.active>=0?this.visible[d.active]:null;if(!l){o&&o.commit&&this.commit();return}if(this.isSelectable(l)){this.choose(l);return}this.isBranch(l)?this.setExpanded(l,!this.expanded.has(l.key)):o&&o.commit&&this.commit()}moveHighlight(o){const d=this.list;if(!d)return;let l=d.active;for(let i=0;i<this.visible.length;i++){if(l+=o,l<0||l>=this.visible.length)return;if(!this.visible[l].disabled){d.setActive(l);return}}}}const t=r}),Le("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const x=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,V=B.keyOf,H=B.debounce,z=B.rawOptions,w=B.optionSource,j=B.lookupSearch,g=B.lookupKey,u=K("packages/core/src/internal/util.js"),h=u.isFunction,a=u.isObject,r=u.getPath,n=K("packages/dom/src/cell/icons.js").createIcon;class o extends x{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const f=super.build();if(f.classList.add("lat-objectpicker"),h(this.props.search)&&!(this.lookup&&this.lookup.search)){const s=Number(this.props.searchDebounce)||200;this.#n=H(p=>this.runRemoteSearch(String(p)),s)}return f}onQuery(f){super.onQuery(f),this.#n&&this.#n(f)}initSelection(){const f=z(this.params,this.props).map(s=>this.toOption(s));(f.length||!this.all.length)&&(this.all=f),this.selected=this.params.value??null}toOption(f){if(!a(f)){const y=f==null?"":String(f);return{id:f,label:y,secondary:"",avatar:"",initials:l(y),disabled:!1,raw:{}}}const s=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",b=d(f,this.props.template??p,""),A=d(f,this.props.secondary,""),k=d(f,this.props.avatar,"");return{id:f[s],label:b||String(f[s]??""),secondary:A,avatar:k,initials:l(b||String(f[s]??"")),disabled:f.disabled===!0,icon:f.icon,variant:f.variant,raw:f}}attached(){if(super.attached(),this.#t||this.all.length)return;const f=w(this.params,this.props);h(f)&&(this.#t=!0,Promise.resolve(f()).then(s=>{!this.element()||!Array.isArray(s)||(this.all=s.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(f){const s=String(f||"").trim().toLowerCase();if(s==="")return this.all;const p=i(this.props.searchFields);return this.all.filter(b=>{if(!p)return b.label.toLowerCase().includes(s)||b.secondary.toLowerCase().includes(s);for(const A of p){const k=h(A)?A(b.raw):r(b.raw,A);if(k!=null&&String(k).toLowerCase().includes(s))return!0}return!1})}async runRemoteSearch(f){const s=j(this.params,this.props);if(!s)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const b=await s(f,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(b)?b.map(A=>this.toOption(A)):[])}catch(b){if(!p.signal.aborted)throw b}finally{this.#e===p&&(this.#e=null)}}choose(f){!f||f.disabled||(this.selected=f.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(f){return this.selected!=null&&f!=null&&V(f.id)===V(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(f){if(f==null)return;const s=V(f);return this.all.find(p=>V(p.id)===s)}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(f)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(f)}" is not a valid option`}renderOption(f,s,p){W(s),s.appendChild(this.buildAvatar(f));const b=_(this.doc,"span",{class:"lat-object__text"});b.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:f.label})),f.secondary&&b.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:f.secondary})),s.appendChild(b),f.icon&&s.appendChild(n(this.doc,f.icon,{className:I.icon})),f.variant?s.setAttribute("data-variant",f.variant):s.removeAttribute("data-variant");const A=this.isSelected(f);s.classList.add("lat-object__row"),s.classList.toggle(I.optionSelected,A),s.classList.toggle(I.optionDisabled,f.disabled===!0),s.setAttribute("aria-selected",A?"true":"false"),f.disabled?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled")}buildAvatar(f){const s=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!f.avatar)return s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),s.setAttribute("data-fallback","initials"),s;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:f.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(p,"error",()=>{p.parentNode===s&&(s.removeChild(p),s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),s.setAttribute("data-fallback","initials"))}),s.appendChild(p),s}paintDisplay(){const f=this.display;if(!f)return;if(W(f),this.selected==null){f.removeAttribute("data-variant");return}const s=this.optionById(this.selected);if(!s){f.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}f.appendChild(this.buildAvatar(s)),f.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:s.label})),s.variant?f.setAttribute("data-variant",s.variant):f.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function d(c,f,s){if(f==null)return s;const p=h(f)?f(c):r(c,String(f));return p==null?s:String(p)}function l(c){const f=String(c||"").trim().split(/\s+/).filter(b=>b!=="");if(!f.length)return"";const s=[...f[0]][0]||"";if(f.length===1)return s.toUpperCase();const p=[...f[f.length-1]][0]||"";return(s+p).toUpperCase()}function i(c){if(c==null)return null;const s=(Array.isArray(c)?c:[c]).filter(p=>typeof p=="string"||h(p));return s.length?s:null}const m=o}),Le("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,V=K("packages/dom/src/cell/icons.js"),H=V.createIcon,z=V.iconNames,j=K("packages/core/src/internal/util.js").isFunction;class g extends x{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const r=this.props;this.columns=Math.max(1,Math.floor(Number(r.columns)||8)),this.names=u(r.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=_(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=_(this.doc,"div",{class:`${B.editor}__display`}),this.input=_(this.doc,"input",{class:B.input,attrs:{type:"text",autocomplete:"off",placeholder:r.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new I({document:this.doc,itemHeight:Number(r.rowHeight)||34,height:Number(r.listHeight)||204,renderItem:(n,o,d)=>this.renderRow(n,o,d)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),r.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(X(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(X(this.input,"keydown",n=>this.onKeyDown(n))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const r=_(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(X(r,"mousedown",t=>{j(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),r}focusTarget(){return this.input}onQuery(r){this.query=r,this.refreshIcons()}refreshIcons(){const r=this.query.trim().toLowerCase();this.matches=r===""?this.names.slice():this.names.filter(n=>n.toLowerCase().includes(r)),this.rows=[];for(let n=0;n<this.matches.length;n+=this.columns)this.rows.push(this.matches.slice(n,n+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(r){return r<0?-1:Math.floor(r/this.columns)}moveCursor(r){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+r));return this.setCursor(t)}setCursor(r){return this.cursor=r,this.list&&this.list.setActive(this.rowOf(r)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(r,t,n){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let o=t.__latIconCells;if(!o){o=[],W(t);for(let d=0;d<this.columns;d++){const l=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(l,"mousedown",i=>{j(i.preventDefault)&&i.preventDefault();const m=l.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(l),o.push(l)}t.__latIconCells=o}for(let d=0;d<o.length;d++){const l=o[d],i=r[d];if(i===void 0){l.setAttribute("aria-hidden","true"),l.removeAttribute("data-icon"),l.removeAttribute("title"),l.removeAttribute("aria-label"),l.classList.add("lat-iconpicker__cell--empty"),l.classList.remove("lat-iconpicker__cell--active"),l.classList.remove("lat-iconpicker__cell--selected"),l.__latIconName!==void 0&&(W(l),l.__latIconName=void 0);continue}const m=n*this.columns+d;l.removeAttribute("aria-hidden"),l.classList.remove("lat-iconpicker__cell--empty"),l.setAttribute("data-icon",i),l.setAttribute("title",i),l.setAttribute("aria-label",i),l.__latIconName!==i&&(W(l),l.appendChild(H(this.doc,i,{className:B.icon})),l.__latIconName=i);const c=this.selected===i;l.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),l.classList.toggle("lat-iconpicker__cell--selected",c),l.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const r=this.display;if(r){if(W(r),this.selected==null){r.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}r.appendChild(H(this.doc,this.selected,{className:B.icon})),r.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(r){this.selected=r;const t=this.matches.indexOf(r);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(r))?!0:`"${String(r)}" is not a known icon name`}onKeyDown(r){const t=()=>{j(r.preventDefault)&&r.preventDefault()};switch(r.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const n=this.cursorName();n&&this.choose(n);return}case"Escape":t(),this.cancel();return;case"Tab":{const n=this.cursorName();n&&(this.selected=n),this.commit();return}default:break}}destroy(){for(const r of this.off)r();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function u(a){const r=z();if(Array.isArray(a)&&a.length){const t=new Set(r);return a.map(n=>String(n)).filter(n=>t.has(n))}return r.filter(t=>t!=="blank")}const h=g}),Le("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/temperature.js"),H=V.formatTemperature,z=V.parseTemperature,w=V.findScale;function j(h,a){return H(h,{...a,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.params.column&&this.params.column.dataType||null,r=a&&a.temperatureConfig||{};return{scale:this.props.scale||r.scale||"C",locale:this.params.locale}}build(){const a=this.props;this.opts=this.buildOptions();const r=w(this.opts.scale),t=r?r.scale.symbol:"",n=`${this.id}-scale`,o=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});o.value=j(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const d=typeof a.step=="number"?a.step:0;return d>0&&this.#e.push(_(o,"keydown",l=>{l.key==="ArrowUp"?(W(l.preventDefault)&&l.preventDefault(),this.nudge(d)):l.key==="ArrowDown"&&(W(l.preventDefault)&&l.preventDefault(),this.nudge(-d))})),this.hint=I(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:n,"aria-hidden":"true"}}),I(this.doc,"div",{class:`${B.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=z(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:o}=this.props;typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=j(t,this.opts))}readValue(){const a=this.input?String(this.input.value).trim():"";if(a==="")return null;const r=z(a,this.opts);return r===null?Number.NaN:r}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a))return"Enter a temperature";const{min:r,max:t}=this.props;return typeof r=="number"&&a<r?`Must be ${r} or more`:typeof t=="number"&&a>t?`Must be ${t} or less`:!0}destroy(){for(const a of this.#e)a();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const u=g}),Le("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,B=Q.CLS,I=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/currency.js"),H=V.parseMoney,z=V.toMoney,w=V.normaliseCode,j=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(a){const r=z(a);return r?String(r.amount):""}class u extends x{input=null;picker=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.currencyConfig||{},n=z(this.params.value),o=w(this.props.code)||n&&n.code||w(t.code)||"USD";let d=this.props.codes||t.codes||j;return d=d.map(l=>w(l)).filter(Boolean),d.includes(o)||(d=[o,...d]),{code:o,codes:d,locale:this.params.locale}}build(){const r=this.props;this.opts=this.buildOptions();const t=I(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=g(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const n=I(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const d=I(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(d.selected=!0),n.appendChild(d)}return this.picker=n,I(this.doc,"div",{class:`${B.editor}__unit`,children:[t,n]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&W(r.select)&&r.select()}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=this.picker?this.picker.value:this.opts.code,n=H(r,{...this.opts,code:t});return n===null?Number.NaN:n}checkValue(r){if(r===null)return!0;if(!r||typeof r!="object"||!Number.isFinite(r.amount))return"Enter an amount";const t=r.amount,{min:n,max:o}=this.props;return typeof n=="number"&&t<n?`Must be ${n} or more`:typeof o=="number"&&t>o?`Must be ${o} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const h=u}),Le("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return fe}});const x=K("packages/dom/src/editors/text.js").TextEditor,I=K("packages/dom/src/editors/textarea.js").TextareaEditor,X=K("packages/dom/src/editors/number.js").NumberEditor,V=K("packages/dom/src/editors/date.js").DateEditor,z=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,j=K("packages/dom/src/editors/select.js").SelectEditor,u=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,a=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,o=K("packages/dom/src/editors/duration.js").DurationEditor,l=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,m=K("packages/dom/src/editors/password.js").PasswordEditor,f=K("packages/dom/src/editors/code.js").CodeEditor,p=K("packages/dom/src/editors/unit.js").UnitEditor,A=K("packages/dom/src/editors/radix.js").RadixEditor,y=K("packages/dom/src/editors/segmented.js").SegmentedEditor,R=K("packages/dom/src/editors/rating.js").RatingEditor,F=K("packages/dom/src/editors/slider.js").SliderEditor,T=K("packages/dom/src/editors/colour.js").ColourEditor,C=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,$=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,v=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,G=K("packages/dom/src/editors/temperature.js").TemperatureEditor,Z=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),ee=J.isCtor,ne=J.isFunction,ie=J.warnOnce,se=K("packages/dom/src/editors/common.js");for(const de of Object.keys(se))de!=="default"&&Object.defineProperty(e,de,{enumerable:!0,get:function(){return se[de]}});const he=Object.freeze({text:x,textarea:I,number:X,date:V,checkbox:z,select:j,multiSelect:u,temperature:G,currency:Z,time:a,datetime:t,duration:o,ipaddress:l,password:m,code:f,unit:p,radix:A,slider:F,rating:R,segmented:y,treeSelect:C,objectPicker:$,iconPicker:v,colour:T}),ce=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function te(de,we){const Te=de&&de.edit&&de.edit.editor,Ae=we&&we.editors||{},Ce=!!(de&&de.lookup&&de.lookup.multiple);if(ee(Te)||ne(Te))return Te;if(typeof Te=="string"){if(Ce&&Te==="select")return u;const ge=Ae[Te]||he[Te];if(ge)return ge;ie(`editor:missing:${Te}`,`unknown editor "${Te}"; falling back to the data type default`)}const pe=de&&de.type||"text";if(pe==="lookup"||de&&de.lookup)return Ce?u:j;const be=ce[pe];return be&&(Ae[be]||he[be])||null}function oe(de,we){const Te=te(de.column||{},we);if(!Te)return null;const Ae=new Te;return Ae.init(de),ne(Ae.cancelBeforeStart)&&Ae.cancelBeforeStart()===!0?(ne(Ae.destroy)&&Ae.destroy(),null):Ae}const fe=he}),Le("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction;function z(c){let f=0,s=0,p=0,b=null,A=null;for(const k of c||[]){if(k==null||k==="")continue;f++;const y=typeof k=="number"?k:Number(k);Number.isFinite(y)&&(s++,p+=y,(b===null||y<b)&&(b=y),(A===null||y>A)&&(A=y))}return{count:f,numericCount:s,sum:s?p:null,min:b,max:A,avg:s?p/s:null}}class w{root=null;valueNode=null;init(f){this.ctx=f,this.doc=f.document,this.root=I(this.doc,"div",{class:`${x.statusBar}__panel`,attrs:{"data-align":f.align||"end"}}),f.label&&this.root.appendChild(I(this.doc,"span",{class:`${x.statusBar}__label`,text:f.label})),this.valueNode=I(this.doc,"span",{class:`${x.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(f,s){const p=this.ctx&&this.ctx.messages;return(p&&H(p.t)?p:W).t(f,s)}element(){return this.root}refresh(){const f=this.read();this.valueNode&&this.valueNode.textContent!==f&&(this.valueNode.textContent=f)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class j extends w{read(){const f=this.ctx.host||{},s=H(f.totalRowCount)?f.totalRowCount():0,p=H(f.loadError)?f.loadError():null;if(p)return p;if(s==null)return this.t("status.counting");const b=H(f.rowCount)?f.rowCount():s;if(b==null)return p||this.t("status.counting");const A=this.ctx.noun,k=y=>A===void 0?this.t("count.rows",{count:y}):`${d(y,this.ctx.locale)}${A?` ${A}`:""}`;return b===s?this.t("status.total",{rows:k(s)}):this.t("status.shownOfTotal",{shown:d(b,this.ctx.locale),total:k(s)})}}class g extends w{read(){const f=this.ctx.host||{},s=H(f.selectedAcrossSource)?f.selectedAcrossSource():null;if(s)return typeof s.count=="number"?this.t("status.selectedAcrossSource",{count:s.count}):this.t("status.selectedAcrossSourceCounting");const p=H(f.selectedCount)?f.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class u extends w{read(){const f=this.ctx.host||{},s=H(f.rangeValues)?f.rangeValues():[],p=z(s);if(!p.count)return"";const b=this.ctx.stats||["count","sum","min","max","avg"],A=[];for(const k of b){if(k==="count"){A.push(this.t("status.count",{count:p.count}));continue}const y=p[k];y!==null&&A.push(`${this.t(`status.stat.${k}`)} ${i(y,this.ctx.locale)}`)}return A.join(" ")}}class h extends w{read(){const f=this.ctx.host||{},s=H(f.progress)?f.progress():null;if(!s)return"";const{loaded:p,estimated:b,done:A}=s;if(A)return"";if(!b)return this.t("status.loading",{count:p||0});const k=Math.min(100,Math.round((p||0)/b*100));return this.t("status.loadingOf",{loaded:p||0,total:b,percent:k})}}class a extends w{read(){const f=this.ctx.host||{},s=H(f.updateStats)?f.updateStats():null;return s?s.paused?s.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:s.pending})}):this.t("status.paused"):s.coalescedTotal?this.t("status.coalesced",{count:s.coalescedTotal}):"":""}}class r extends w{read(){const f=this.ctx.host||{},s=H(f.hiddenUnresolved)?f.hiddenUnresolved():0;return s?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:s})}):""}}const t=Object.freeze({rowCount:j,selectedCount:g,aggregation:u,progress:h,updates:a,comments:r});class n{panels=[];root=null;init(f){const s=f||{};this.doc=B(s),this.host=s.host||{},this.messages=s.messages||null,this.root=I(this.doc,"div",{class:x.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=s.registry||{},b=Array.isArray(s.panels)&&s.panels.length?s.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const A of b){const k=typeof A=="string"?A:A.name,y=typeof A=="function"?A:p[k]||t[k];if(!y)continue;const S=new y;S.init({document:this.doc,host:this.host,locale:s.locale,messages:this.messages,...typeof A=="object"?A.props||{}:{}}),this.panels.push({name:String(k||"panel"),panel:S}),this.root.appendChild(S.element())}this.refresh()}element(){return this.root}addPanel(f,s,p){const b=new s;return b.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:f,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(f){const s=this.panels.findIndex(A=>A.name===f);if(s<0)return!1;const[p]=this.panels.splice(s,1),b=p.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),H(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const f of this.panels)f.panel.refresh()}destroy(){for(const f of this.panels)H(f.panel.destroy)&&f.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const o=new Map;function d(c,f){const s=f||"";let p=o.get(s);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0}),o.set(s,p)),p.format(Number(c)||0)}const l=new Map;function i(c,f){const s=f||"";let p=l.get(s);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:3}),l.set(s,p)),p.format(Number(c)||0)}const m=n}),Le("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/renderer/direction.js").isRtlElement,j=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,n){const o=[];for(const d of t||[]){const l=V(d)?d(n):d;if(l==null||l===!1)continue;if(l==="separator"){o.push({separator:!0});continue}if(typeof l=="string"){o.push({name:l});continue}const i=l,m=i.subMenu||i.children;m?o.push({...i,subMenu:g(m,n)}):o.push(i)}return o.filter((d,l,i)=>d.separator?l===0||l===i.length-1?!1:!i[l-1].separator:!0)}class u{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(n){const o=n||{};this.doc=B(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(n){const o=this.host,d=V(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},l=V(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=i.innerWidth||0,c=i.innerHeight||0;let f=n.x||0,s=n.y||0;const p=z(o);if(n.anchor&&V(n.anchor.getBoundingClientRect)){const k=n.anchor.getBoundingClientRect();n.placement==="below"?(f=p?k.right-l.width:k.left,s=k.bottom):(f=p?k.left-l.width:k.right,s=k.top)}else p&&(f-=l.width);const b={left:Math.max(0,d.left||0),top:Math.max(0,d.top||0),right:Math.min(m||1/0,(d.left||0)+(d.width||1/0)),bottom:Math.min(c||1/0,(d.top||0)+(d.height||1/0))};f+l.width>b.right&&(f-=l.width),f<b.left&&(f=b.left),s+l.height>b.bottom&&(s-=l.height),s<b.top&&(s=b.top);const A=b.bottom-s;l.height>A&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(A))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(f-d.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(s-d.top+(o.scrollTop||0))}px`}show(n){return this.hide(),n.ctx&&(this.ctx={...this.ctx||{},...n.ctx}),this.items=g(n.items,this.ctx),this.returnFocus=n.returnFocus||null,this.anchor=n.anchor&&V(n.anchor.setAttribute)&&n.anchor.getAttribute&&n.anchor.getAttribute("aria-haspopup")?n.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=I(this.doc,"div",{class:x.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,d)=>{if(o.separator){this.root.appendChild(I(this.doc,"div",{class:x.menuSeparator,attrs:{role:"separator"}}));return}const l=I(this.doc,"div",{class:[x.menuItem,o.cssClass||""],attrs:{role:o.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":o.disabled?"true":null,"aria-checked":o.checked===void 0?null:String(o.checked===!0),"aria-haspopup":o.subMenu?"true":null,"aria-expanded":o.subMenu?"false":null,"data-index":d}});if(o.icon!=null&&o.icon!==""){const m=I(this.doc,"span",{class:x.icon});j(m,o.icon,`menu:${o.name||d}`),l.appendChild(m)}l.appendChild(I(this.doc,"span",{class:`${x.menuItem}__label`,text:o.name||""})),o.shortcut&&l.appendChild(I(this.doc,"span",{class:`${x.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&l.appendChild(I(this.doc,"span",{class:`${x.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(_(l,"click",()=>this.invoke(i))),this.off.push(_(l,"mouseenter",()=>{this.focus(i),o.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(l),this.root.appendChild(l)}),this.host.appendChild(this.root),this.place(n),this.open=!0,this.off.push(_(this.root,"keydown",o=>this.onKeyDown(o))),V(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=o=>{this.root&&!a(this.root,o.target)&&!(this.child&&this.child.root&&a(this.child.root,o.target))&&this.hide()},!0)),V(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let n=0;n<this.itemNodes.length;n++)if(!this.itemAt(n).disabled)return n;return-1}itemAt(n){const o=this.itemNodes[n];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(n){if(n<0||n>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${x.menuItem}--focused`),this.focused=n;const d=this.itemNodes[n];d.classList.add(`${x.menuItem}--focused`),V(d.focus)&&d.focus(),V(d.scrollIntoView)&&d.scrollIntoView({block:"nearest",inline:"nearest"})}move(n){const o=this.itemNodes.length;if(!o)return;let d=this.focused;for(let l=0;l<o;l++)if(d=(d+n+o)%o,!this.itemAt(d).disabled){this.focus(d);return}}invoke(n){const o=this.itemAt(n);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(n);return}V(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(n){const o=this.itemAt(n);o.subMenu&&(this.closeChild(),this.child=new u({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[n]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(n){switch(n.key){case"ArrowDown":h(n),this.move(1);break;case"ArrowUp":h(n),this.move(-1);break;case"Home":h(n),this.focus(this.firstEnabled());break;case"End":h(n),this.focus(this.itemNodes.length-1);break;case"ArrowRight":h(n),this.openSubMenu(this.focused);break;case"ArrowLeft":h(n),this.parent&&(this.hide(),V(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":h(n),this.invoke(this.focused);break;case"Escape":h(n),this.hideRoot();break;default:n.key&&n.key.length===1&&this.jumpTo(n.key);break}}jumpTo(n){const o=n.toLowerCase(),d=this.itemNodes.length;for(let l=1;l<=d;l++){const i=(this.focused+l+d)%d,m=this.itemAt(i);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(o)){this.focus(i);return}}}hideRoot(){let n=this;for(;n.parent;)n=n.parent;n.hide()}hide(){this.closeChild();for(const n of this.off)n();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&V(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&V(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,V(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function h(t){V(t.preventDefault)&&t.preventDefault(),V(t.stopPropagation)&&t.stopPropagation()}function a(t,n){let o=n;for(;o;){if(o===t)return!0;o=o.parentNode}return!1}const r=u}),Le("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,j=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class g{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(r,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(r,t)}init(r){this.messages=r&&r.messages||r&&r.grid&&r.grid.messages||W;const t=r||{};this.doc=x(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:j.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const r=this.root;if(!r)return;for(const l of this.off)l();this.off.length=0,_(r),this.diffs=new Map;const t=this.views(),n=t.filter(l=>l.builtin),o=t.filter(l=>!l.builtin);n.length&&(r.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),n.length)),r.appendChild(this.buildList(n))),r.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?r.appendChild(this.buildList(o)):r.appendChild(B(this.doc,"p",{class:j.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const d=this.buildFoot();d&&r.appendChild(d)}buildList(r){const t=B(this.doc,"div",{class:j.list,attrs:{role:"list"}});for(const n of r)t.appendChild(this.buildItem(n));return t}views(){const r=H(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?r:r.slice().sort((t,n)=>String(t.name||"").localeCompare(String(n.name||"")))}activeId(){return H(this.host.activeId)?this.host.activeId():null}buildHead(r,t){return B(this.doc,"div",{class:j.head,children:[B(this.doc,"span",{class:j.title,text:String(r)}),B(this.doc,"span",{class:j.count,text:String(t)})]})}buildItem(r){const t=String(r.id),n=this.activeId()===t,o=H(this.host.canEdit)?this.host.canEdit(r)!==!1:!0,d=B(this.doc,"div",{class:[j.item,n?j.itemActive:"",this.editing===t?j.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":r.shared?"true":"false"}});if(this.editing===t)return d.appendChild(this.buildRenameRow(r)),d;const l=B(this.doc,"button",{class:j.apply,attrs:{type:"button","aria-current":n?"true":null,title:[n?`${r.name} is applied`:`Apply ${r.name}`,r.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:j.name,text:String(r.name||"")}),r.isDefault?this.buildBadges(r):null].filter(Boolean)});H(this.host.apply)?this.off.push(I(l,"click",()=>this.applyView(t))):l.setAttribute("disabled",""),r.description&&l.appendChild(B(this.doc,"span",{class:j.description,text:String(r.description)}));const i=this.buildDiff(t,n);return i&&l.appendChild(i),d.appendChild(l),r.builtin||d.appendChild(this.confirming===t?this.buildConfirm(r):this.buildActions(r,o)),d}buildBadges(r){const t=B(this.doc,"span",{class:j.badges});return r.isDefault&&t.appendChild(B(this.doc,"span",{class:[j.badge,j.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(r,t){if(this.props.showDiff!==!0||!H(this.host.diff))return null;const n=this.diffOf(r);if(!n)return null;if(!n.changed)return B(this.doc,"span",{class:[j.diff,j.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const o=u(n);return o.length?B(this.doc,"span",{class:j.diff,text:o.join(" · ")}):null}diffOf(r){if(!H(this.host.diff))return null;if(this.diffs.has(r))return this.diffs.get(r);let t=null;try{t=this.host.diff(r)}catch{t=null}return this.diffs.set(r,t),t}buildActions(r,t){const n=String(r.id),o=B(this.doc,"span",{class:j.actions});if(t&&H(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${r.name}`,()=>{this.editing=n,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),r.isDefault&&H(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${r.name} at load`,()=>{this.host.clearDefault(n),this.refresh()},"pin")):!r.isDefault&&H(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${r.name} when the grid loads`,()=>{this.host.setDefault(n),this.refresh()},"pin")),H(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${r.name}`,()=>this.host.export(n),"share")),t&&H(this.host.remove)){const d=this.buildAction("Delete",`Delete ${r.name}`,()=>{this.confirming=n,this.refresh()},"trash");d.classList.add(j.actionDanger),o.appendChild(d)}return o}buildConfirm(r){const t=String(r.id),n=B(this.doc,"span",{class:j.confirm});n.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:r.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:r.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return o.classList.add(j.actionDanger),n.appendChild(o),n.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),n}buildRenameRow(r){const t=String(r.id),n=B(this.doc,"span",{class:j.confirm}),o=B(this.doc,"input",{class:j.input,attrs:{type:"text","aria-label":`New name for ${r.name}`}});o.value=String(r.name||""),this.input=o;const d=()=>{const i=String(o.value||"").trim();this.editing=null,i&&i!==r.name&&this.host.rename(t,i),this.refresh()},l=()=>{this.editing=null,this.refresh()};return this.off.push(I(o,"keydown",i=>{i.key==="Enter"?d():i.key==="Escape"&&l()})),n.appendChild(o),n.appendChild(this.buildAction("Save","Save the new name",d)),n.appendChild(this.buildAction("Cancel","Leave the name alone",l)),n}buildFoot(){if(this.props.allowSave===!1||!H(this.host.saveAs))return null;const r=B(this.doc,"div",{class:j.foot}),t=B(this.doc,"input",{class:j.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const n=()=>{const d=String(t.value||"").trim();if(!d){H(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(d),this.refresh()};this.off.push(I(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(I(t,"keydown",d=>{d.key==="Enter"&&n()}));const o=B(this.doc,"button",{class:j.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(I(o,"click",n)),r.appendChild(t),r.appendChild(o),r}buildAction(r,t,n,o){const d=B(this.doc,"button",{class:j.action,text:o?null:r,attrs:{type:"button",title:t,"aria-label":t,"data-action":r}});return o&&d.appendChild(w(this.doc,o,{className:j.actionIcon})),this.off.push(I(d,"click",n)),d}applyView(r){this.confirming=null,this.host.apply(r),this.refresh()}focusInput(){const r=this.input;r&&H(r.focus)&&r.focus(),r&&H(r.select)&&r.select()}destroy(){for(const r of this.off)r();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function u(a,r=3){if(!a||!a.changed)return[];const t=a.counts||{},n=[],o=(d,l,i)=>{d&&n.push((d===1?l:i).replace("%",String(d)))};if(o(t.columnsHidden,"hides % column","hides % columns"),o(t.columnsShown,"shows % column","shows % columns"),o(t.columnsMoved,"moves % column","moves % columns"),o(t.columnsPinned,"repins % column","repins % columns"),o(t.columnsResized,"resizes % column","resizes % columns"),a.filters&&a.filters.changed){const d=t.filterColumns||0;n.push(d?`changes ${d} filter${d===1?"":"s"}`:"changes the filter")}return a.quick&&a.quick.changed&&n.push("changes the search"),a.sort&&a.sort.changed&&n.push("changes the sort"),a.group&&a.group.changed&&n.push("changes the grouping"),a.pivot&&a.pivot.changed&&n.push("changes the pivot"),o(t.columnsTotalled,"changes % total","changes % totals"),a.pagination&&a.pagination.changed&&n.push("changes the page size"),n.length<=r?n:[...n.slice(0,r),`and ${n.length-r} more`]}const h=g}),Le("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return X}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(V){this.ctx=V,this.doc=V.document,this.host=V.host||{},this.props=V.props||{},this.root=B(this.doc,"div",{class:`${x.panel}__body`}),this.refresh()}t(V,H){const z=this.host||{};if(typeof z.t=="function")return z.t(V,H);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(V,H);const j=w.grid;return(j&&j.messages?j.messages:_).t(V,H)}element(){return this.root}refresh(){}destroy(){for(const V of this.off)V();this.off.length=0,this.root=null}}}),Le("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,w=K("packages/core/src/formatting/rules.js"),j=w.compileRules,g=w.summariseColumn,u=w.needsDistribution,h=w.DISTRIBUTION_LABELS,a="*",r=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),n=Object.freeze([{op:"topPercent",label:h.topPercent,values:1},{op:"bottomPercent",label:h.bottomPercent,values:1},{op:"topN",label:h.topN,values:1},{op:"bottomN",label:h.bottomN,values:1},{op:"aboveMean",label:h.aboveMean,values:0},{op:"belowMean",label:h.belowMean,values:0},{op:"aboveMedian",label:h.aboveMedian,values:0},{op:"belowMedian",label:h.belowMedian,values:0},{op:"zAbove",label:h.zAbove,values:1},{op:"zBelow",label:h.zBelow,values:1},{op:"outlier",label:h.outlier,values:0}]),o=Object.freeze([...t,...n]),d=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),l=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function m(b){const A=o.find(k=>k.op===b);return A?A.values:1}function c(b){if(!b)return"";if(b.scale){const{min:S,max:R,from:O}=b.scale;if(Number.isFinite(S)&&Number.isFinite(R))return`Colour scale, ${S} to ${R}`;const F=i.find(E=>E.from===O);return F?`Colour scale ${F.label}`:"Colour scale"}const A=b.when||{},k=o.find(S=>S.op===A.op),y=k?k.label:A.op;return!k||k.values===0?`Value ${y}`:k.values===2?`Value ${y} ${A.value} and ${A.value2}`:`Value ${y} ${A.value}`}class f extends z{scope=a;mode="condition";refresh(){const A=this.root;if(A){for(const k of this.off)k();this.off.length=0,X(A),A.appendChild(this.#o()),A.appendChild(this.#i()),A.appendChild(this.#l())}}#e(){const A=V(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:a,title:"All columns"},...A]}#t(){return V(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(A){if(!V(this.host.columnSamples))return[];const k=this.host.columnSamples(A);return Array.isArray(k)?k:[...k||[]]}#r(A,k,y){const S=u(A)?g(k):null;return j(A,S)({value:y})}#o(){const A=I(this.doc,"div",{class:`${x.panel}__row`});A.appendChild(I(this.doc,"label",{class:`${x.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const k=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const S=I(this.doc,"option",{text:y.title,attrs:{value:y.id}});y.id===this.scope&&S.setAttribute("selected","selected"),k.appendChild(S)}return k.value=this.scope,this.off.push(_(k,"change",()=>{this.scope=k.value||a,this.refresh()})),A.appendChild(k),A}#i(){const A=I(this.doc,"ul",{class:`${x.panel}__list`}),k=this.#t();if(!k.length)return A.appendChild(I(this.doc,"li",{class:`${x.panel}__empty`,text:this.t("formatting.noRules")})),A;k.forEach((R,O)=>{const F=I(this.doc,"li",{class:`${x.panel}__item`,attrs:{"data-rule":R.id}}),E=I(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${c(R)}`}});E.checked=R.enabled!==!1,this.off.push(_(E,"change",()=>{this.#c("updateRule",this.scope,R.id,{enabled:E.checked})})),F.appendChild(E);const T=I(this.doc,"span",{class:`${x.panel}__swatch`}),L=R.style||{};if(L.background&&T.style&&T.style.setProperty)T.style.setProperty("background",String(L.background));else if(R.scale&&R.scale.colours&&T.style&&T.style.setProperty){const P=R.scale.colours;T.style.setProperty("background",`linear-gradient(90deg, ${P[0]}, ${P[P.length-1]})`)}F.appendChild(T),F.appendChild(I(this.doc,"span",{class:`${x.panel}__text`,text:c(R)}));const C=I(this.doc,"button",{class:`${x.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(_(C,"click",()=>this.#c("moveRule",this.scope,R.id,O-1))),F.appendChild(C);const D=I(this.doc,"button",{class:`${x.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===k.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,O+1))),F.appendChild(D);const $=I(this.doc,"button",{class:`${x.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(R)}`}});this.off.push(_($,"click",()=>this.#c("removeRule",this.scope,R.id))),F.appendChild($),A.appendChild(F)});const y=this.#s(k);y&&A.appendChild(y);const S=I(this.doc,"button",{class:`${x.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(S,"click",()=>this.#c("clearRules",this.scope))),A.appendChild(S),A}#s(A){const k=this.#n(this.scope);if(!k.length)return null;const y=A.filter(R=>R.enabled!==!1);if(!y.length)return null;const S=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of k.slice(0,r)){const O=this.#r(y,k,R),F=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(R)});O&&F.style&&F.style.setProperty&&(O.background&&F.style.setProperty("background",String(O.background)),O.color&&F.style.setProperty("color",String(O.color))),S.appendChild(F)}return S}#l(){const A=I(this.doc,"div",{class:`${x.panel}__form`}),k=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return k.appendChild(I(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),k.appendChild(I(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),k.value=this.mode,this.off.push(_(k,"change",()=>{this.mode=k.value==="scale"?"scale":"condition",this.refresh()})),A.appendChild(k),this.mode==="scale"?A.appendChild(this.#u()):A.appendChild(this.#a()),A}#a(){const A=I(this.doc,"div",{class:`${x.panel}__form`}),k=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const $ of t)y.appendChild(I(this.doc,"option",{text:$.label,attrs:{value:$.op}}));k.appendChild(y);const S=I(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const $ of n)S.appendChild(I(this.doc,"option",{text:$.label,attrs:{value:$.op}}));k.appendChild(S),k.value="gt",A.appendChild(k);const R=I(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=I(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});A.appendChild(R),A.appendChild(O);const F=()=>{const $=m(k.value);R.style.setProperty("display",$>=1?"":"none"),O.style.setProperty("display",$>=2?"":"none"),C()};this.off.push(_(k,"change",F));const E=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const $ of d)E.appendChild(I(this.doc,"option",{text:$.name,attrs:{value:$.name}}));E.value=d[0].name,A.appendChild(E);const T=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});A.appendChild(T);const L=()=>{const $=d.find(N=>N.name===E.value)||d[0],P=m(k.value),v={op:k.value};return P>=1&&(v.value=R.value),P>=2&&(v.value2=O.value),{when:v,style:{background:$.background,color:$.color}}},C=()=>{X(T);const $=this.#n(this.scope);if($.length)for(const P of $.slice(0,r)){const v=this.#r([L()],$,P),N=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(P)});v&&N.style&&N.style.setProperty&&(v.background&&N.style.setProperty("background",String(v.background)),v.color&&N.style.setProperty("color",String(v.color))),T.appendChild(N)}};this.off.push(_(R,"input",C)),this.off.push(_(O,"input",C)),this.off.push(_(E,"change",C)),F();const D=I(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,L()),R.value="",O.value=""})),A.appendChild(D),A}#u(){const A=I(this.doc,"div",{class:`${x.panel}__form`}),k=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const E of l)k.appendChild(I(this.doc,"option",{text:E.name,attrs:{value:E.name}}));k.value=l[0].name,A.appendChild(k);const y=I(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const E of i)y.appendChild(I(this.doc,"option",{text:E.label,attrs:{value:E.from}}));y.value=i[0].from,A.appendChild(y);const S=I(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});A.appendChild(S);const R=()=>{const E=l.find(T=>T.name===k.value)||l[0];return{scale:{from:y.value,colours:[...E.colours]}}},O=()=>{X(S);const E=this.#n(this.scope);if(E.length)for(const T of E.slice(0,r)){const L=this.#r([R()],E,T),C=I(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(T)});L&&L.background&&C.style&&C.style.setProperty&&C.style.setProperty("background",String(L.background)),S.appendChild(C)}};this.off.push(_(k,"change",O)),this.off.push(_(y,"change",O)),O();const F=I(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(F,"click",()=>{this.#c("addRule",this.scope,R())})),A.appendChild(F),A}#c(A,...k){V(this.host[A])&&this.host[A](...k),this.refresh()}}function s(b={}){const A=new f;return A.init({document:B(b),host:b.host||{}}),A}const p=f}),Le("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"shouldThinLabels",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=70,w=40;function j(t,n){return!t||!n?!1:t<n*2+w}const g=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),u=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),h=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function a(t){if(t==null||!Number.isFinite(t))return"—";if(Number.isInteger(t))return String(t);const n=Math.abs(t);return n!==0&&(n<.001||n>=1e7)?t.toExponential(2):String(Number(t.toPrecision(4)))}class r extends H{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const l of this.off)l();this.off.length=0,_(n);const o=this.#t();if(!o.length){n.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noColumns")}));return}o.some(l=>l.id===this.column)||(this.column=o[0].id),n.appendChild(this.#o(o));const d=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!d&&W(this.host.columnProfileAsync)){const l=B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("facets.computing")});n.appendChild(l);const i=++this.#e,m=this.column;Promise.resolve(this.host.columnProfileAsync(m)).then(c=>{if(i!==this.#e||this.root!==n||this.column!==m)return;const f=B(this.doc,"div",{});this.#n(f,c);for(const s of[...f.children])n.insertBefore(s,l);n.removeChild(l)},()=>{i!==this.#e||this.root!==n||(l.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(n,d)}#n(n,o){if(!o||!o.present){n.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noValues")}));const l=this.#r(o);l&&n.appendChild(l);return}if(n.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:o.rows})})),Array.isArray(o.topValues)){n.appendChild(this.#l(o,u)),n.appendChild(this.#a(o.topValues));const l=this.#r(o);l&&n.appendChild(l);return}if(n.appendChild(this.#l(o)),o.computed!=="source"){for(const i of h){const m=this.#i(i);m&&n.appendChild(m)}const l=this.#s();l&&n.appendChild(l)}o.histogram&&o.histogram.length>1&&n.appendChild(this.#u(o.histogram));const d=this.#r(o);d&&n.appendChild(d)}#r(n){const o=n&&Array.isArray(n.unavailable)?n.unavailable:[];if(!o.length)return null;const d=this.doc.createElement("div");d.setAttribute("data-unavailable",""),d.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.unavailable",{stats:o.map(i=>i.stat).join(", ")})}));const l=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const i of o)l.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:i.stat})),l.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:i.reasonKey?this.t(i.reasonKey,i.reasonParams):i.reason}));return d.appendChild(l),d}#o(n){const o=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const d of n){const l=B(this.doc,"option",{text:d.title,attrs:{value:d.id,selected:d.id===this.column?!0:null}});o.appendChild(l)}return o.value=this.column,this.off.push(I(o,"change",()=>{this.column=o.value,this.refresh()})),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t("stats.column")}),o]})}#i(n){const o=this.host.reduceColumn;if(!W(o)||!this.column)return null;const d=[];for(const m of n.kernels){const c=o(this.column,m);c==null||Number.isNaN(c)||d.push([m,c])}if(!d.length)return null;const l=this.doc.createElement("div");l.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(n.label)}));const i=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const[m,c]of d)i.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(`total.${m}`)})),i.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:typeof c=="number"?a(c):String(c)}));return l.appendChild(i),l}#s(){const n=this.host.columnCapability;if(!W(n)||!this.column)return null;const o=n(this.column);if(!o)return null;const d=this.doc.createElement("div");d.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.section.capability")}));const l=B(this.doc,"dl",{class:`${x.panel}__stats`}),i=[["stats.cp",o.cp,null],["stats.cpk",o.cpk,o.interval],["stats.pp",o.pp,null],["stats.ppk",o.ppk,o.intervalPp],["stats.outOfSpec",o.outOfSpec,null]];for(const[m,c,f]of i){if(c==null)continue;l.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(m)}));const s=[B(this.doc,"span",{text:a(c)})];f&&Number.isFinite(f.lower)&&s.push(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${a(f.lower)} – ${a(f.upper)}`,attrs:{title:`${Math.round(f.confidence*100)}%`}})),l.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:s}))}return d.appendChild(l),d}#l(n,o=g){const d=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const l of o){const i=n[l.key];d.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(l.label)})),d.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:l.kind==="count"?String(i??0):a(i)}))}return d}#a(n){const o=this.doc.createElement("div");o.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.topValues")}));const d=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const l of n)d.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:String(l.value)})),d.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:[B(this.doc,"span",{text:String(l.count)}),B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${Math.round(l.share*100)}%`})]}));return o.appendChild(d),o}#u(n){const o=n.reduce((m,c)=>Math.max(m,c.count),0)||1,d=B(this.doc,"div",{class:`${x.panel}__histogram`});d.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.distribution.detail")}));const l=B(this.doc,"ul",{class:`${x.panel}__histogram-list`,attrs:{role:"list","aria-label":this.t("stats.distribution.detail")}}),i=[];for(const m of n){const c=m.count||0,f=c?Math.max(2,c/o*100):0,s=String(c),p=f>=z,b=B(this.doc,"div",{class:`${x.panel}__bar`,style:{width:`${f}%`},children:p?[B(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--inside`,text:s})]:[]}),A=B(this.doc,"div",{class:`${x.panel}__bin-track`,children:p?[b]:[b,B(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--outside`,text:s})]}),k=B(this.doc,"span",{class:`${x.panel}__bin-range`,text:`${a(m.from)}–${a(m.to)}`});i.push(k);const y=this.t("stats.bin",{count:c,from:a(m.from),to:a(m.to)});l.appendChild(B(this.doc,"li",{class:`${x.panel}__bin`,attrs:{title:y,"aria-label":y},children:[k,A]}))}return d.appendChild(l),this.#c(d,l,i),d}#c(n,o,d){const l=globalThis.ResizeObserver;if(!W(l))return;const i=()=>{const c=n.clientWidth||(W(n.getBoundingClientRect)?n.getBoundingClientRect().width:0);if(!c)return;let f=0;for(const s of d){const p=s.scrollWidth||(W(s.getBoundingClientRect)?s.getBoundingClientRect().width:0);p>f&&(f=p)}o.classList.toggle(`${x.panel}__histogram-list--thin`,j(c,f))},m=new l(i);m.observe(n),this.off.push(()=>m.disconnect()),i()}}}),Le("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.clear,X=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function H(j,g=4){const u=Number(j);return Number.isFinite(u)?u.toFixed(g):u===1/0?"∞":"—"}class z extends V{#e(){const g=this.props||{};if(Array.isArray(g.predictors)&&g.predictors.length&&g.response)return g;const u=this.ctx&&this.ctx.grid,h=u&&X(u.get)?u.get("regression"):null;return h&&Array.isArray(h.predictors)&&h.response?h:null}refresh(){const g=this.root;if(!g)return;I(g);const u=this.#e();if(!u){g.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.noModel")}));return}const h=X(this.host.regressionModel)?this.host.regressionModel(u):null;if(!h){g.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("regression.observations",{count:h.n})})),g.appendChild(this.#t(h)),g.appendChild(this.#n(h));const a=this.#r(h,u);a&&g.appendChild(a),g.appendChild(this.#o(h))}#t(g){const u=B(this.doc,"dl",{class:`${x.panel}__stats`}),h=(a,r)=>{u.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-label`,text:a})),u.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:r}))};return h(this.t("regression.r2"),H(g.r2,4)),h(this.t("regression.adjR2"),H(g.adjR2,4)),u}#n(g){const u=B(this.doc,"div",{class:`${x.panel}__section`});u.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.coefficients")}));const h=B(this.doc,"table",{class:`${x.panel}__coef-table`}),a=B(this.doc,"tr");for(const r of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])a.appendChild(B(this.doc,"th",{text:this.t(r)}));h.appendChild(a);for(const r of g.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:r.name})),t.appendChild(B(this.doc,"td",{text:`${H(r.estimate)} ± ${H(r.stdError)}`})),t.appendChild(B(this.doc,"td",{text:H(r.stdError)})),t.appendChild(B(this.doc,"td",{text:H(r.t,3)})),t.appendChild(B(this.doc,"td",{text:H(r.p,4)})),h.appendChild(t)}return u.appendChild(h),u}#r(g,u){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const h=B(this.doc,"div",{class:`${x.panel}__section`});h.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.vif")}));const a=B(this.doc,"dl",{class:`${x.panel}__stats`});return g.vif.forEach((r,t)=>{a.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-label`,text:u.predictors[t]})),a.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:H(r,3)}))}),h.appendChild(a),h}#o(g){const u=g.heteroscedasticity,h=B(this.doc,"div",{class:`${x.panel}__section`});return h.appendChild(B(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.heteroscedasticity")})),u?(h.appendChild(B(this.doc,"p",{class:`${x.panel}__flag`,attrs:{"data-heteroscedastic":u.heteroscedastic?"true":"false"},text:this.t(u.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:H(u.statistic,3),p:H(u.p,4)})})),h):(h.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")})),h)}}const w=z}),Le("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return j}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const u=Math.abs(g);return u!==0&&(u<.001||u>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class j extends H{first=null;second=null;#e(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const u=this.root;if(!u)return;for(const t of this.off)t();this.off.length=0,_(u);const h=this.#e();if(h.length<2){u.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.needTwo")}));return}h.some(t=>t.id===this.first)||(this.first=h[0].id),(!h.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(h.find(t=>t.id!==this.first)||h[0]).id),u.appendChild(this.#t("compare.first",h,this.first,t=>{this.first=t,this.second===t&&(this.second=(h.find(n=>n.id!==t)||h[0]).id),this.refresh()})),u.appendChild(this.#t("compare.second",h,this.second,t=>{this.second=t,this.first===t&&(this.first=(h.find(n=>n.id!==t)||h[0]).id),this.refresh()}));const a=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!a||!a.n){u.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.noPairs")}));return}u.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("compare.pairs",{count:a.n})}));const r=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const t of z){const n=a[t.key];n!=null&&(r.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(t.label)})),r.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,text:w(n)})))}u.appendChild(r)}#t(u,h,a,r){const t=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const n of h)t.appendChild(B(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push(I(t,"change",()=>r(t.value))),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t(u)}),t]})}}}),Le("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return j}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const u=Math.abs(g);return u!==0&&(u<.001||u>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class j extends H{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const u=this.root;if(!u)return;for(const o of this.off)o();this.off.length=0,_(u);const h=this.#e();if(!h.length){u.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.empty")}));return}const a=this.#t();a&&u.appendChild(a);const r=this.#n();r&&u.appendChild(r),u.appendChild(this.#o(h));const t=this.#s();t&&u.appendChild(t);const n=this.#u();n&&u.appendChild(n)}#t(){if(!W(this.host.subsetVsPopulation))return null;const u=this.host.subsetVsPopulation();if(!u)return null;const h=this.#c("insights.subset");return u.filtered?(h.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:u.subsetN})})),h.appendChild(this.#r(u.ranked)),h):(h.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.noFilter")})),h)}#n(){const u=this.props&&this.props.other;if(!u||!W(this.host.datasetVsDataset))return null;let h;try{h=this.host.datasetVsDataset(u)}catch{return null}if(!h||!h.ranked)return null;const a=this.#c("insights.dataset");return a.appendChild(this.#r(h.ranked)),a}#r(u){const h=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const a of u||[]){const r=B(this.doc,"dt",{class:`${x.panel}__stat-name`});r.appendChild(B(this.doc,"span",{text:String(a.name??a.column)})),r.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(a.measure||"")}));const t=B(this.doc,"dd",{class:`${x.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:w(a.magnitude)})),a.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:this.t("insights.smallSample")})),h.appendChild(r),h.appendChild(t)}return h}#o(u){const h=this.#c("insights.groups");u.some(r=>r.id===this.column)||(this.column=u[0].id),(!u.some(r=>r.id===this.by)||this.by===this.column)&&(this.by=(u.find(r=>r.id!==this.column)||u[0]).id),h.appendChild(this.#d("stats.column",u,this.column,r=>{this.column=r,this.by===r&&(this.by=(u.find(t=>t.id!==r)||u[0]).id),this.refresh()})),h.appendChild(this.#d("insights.by",u,this.by,r=>{this.by=r,this.column===r&&(this.column=(u.find(t=>t.id!==r)||u[0]).id),this.refresh()}));const a=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return a?(h.appendChild(this.#i(a)),h):(h.appendChild(B(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.needGroups")})),h)}#i(u){const h=B(this.doc,"dl",{class:`${x.panel}__stats`});Array.isArray(u.groups)&&u.groups.length===2&&this.#a(h,"insights.groups",`${u.groups[0]} · ${u.groups[1]}`),this.#a(h,"insights.test",String(u.method||u.test||""));const a=u.effectSize||{};this.#a(h,"insights.effect",`${a.name||""} ${w(a.value)}`.trim());const r=u.interval;let t="—";if(r&&Number.isFinite(r.lower)&&Number.isFinite(r.upper)){const o=Number.isFinite(r.confidence)?` (${Math.round(r.confidence*100)}%)`:"";t=`${w(r.lower)} – ${w(r.upper)}${o}`}const n=this.#a(h,"insights.interval",t);return r&&r.method&&n.appendChild(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(r.method)})),Number.isFinite(u.pValue)&&this.#a(h,"insights.pValue",w(u.pValue)),h}#s(){if(!W(this.host.anomalies))return null;let u;try{u=this.host.anomalies()}catch{return null}if(!u)return null;const h=this.#c("insights.anomalies");h.appendChild(B(this.doc,"p",{class:`${x.panel}__count`,text:this.t("insights.anomalyCount",{count:u.flagged||0,n:u.n||0})}));const a=B(this.doc,"dl",{class:`${x.panel}__stats`});this.#a(a,"insights.anomalyMethod",String(u.method||""));const r=this.#l(u);r!==null&&this.#a(a,"insights.anomalyThreshold",w(r)),h.appendChild(a);const t=(u.rows||[]).map(n=>({name:n.rowKey!=null?String(n.rowKey):`#${n.index}`,measure:(n.why||[]).map(o=>o.name||o.column).join(", "),magnitude:n.score}));return h.appendChild(this.#r(t)),h}#l(u){if(u.method==="mahalanobis")return Number.isFinite(u.cutoff)?u.cutoff:null;if(u.method==="iqr")return Number.isFinite(u.k)?u.k:null;const h=Array.isArray(u.columns)?u.columns[0]:null;return h&&Number.isFinite(h.threshold)?h.threshold:null}#a(u,h,a){u.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(h)}));const r=B(this.doc,"dd",{class:`${x.panel}__stat-value`});return r.appendChild(B(this.doc,"span",{text:a})),u.appendChild(r),r}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const u=this.host.columnCapability(this.column);if(!u)return null;const h=this.#c("stats.section.capability"),a=B(this.doc,"dl",{class:`${x.panel}__stats`});for(const r of z){const t=u[r.field];if(t==null)continue;a.appendChild(B(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(r.key)}));const n=[B(this.doc,"span",{text:w(t)})],o=r.interval?u[r.interval]:null;o&&Number.isFinite(o.lower)&&n.push(B(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${w(o.lower)} – ${w(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),a.appendChild(B(this.doc,"dd",{class:`${x.panel}__stat-value`,children:n}))}return h.appendChild(a),h}#c(u){const h=this.doc.createElement("div");return h.appendChild(B(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(u)})),h}#d(u,h,a,r){const t=B(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const n of h)t.appendChild(B(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push(I(t,"change",()=>r(t.value))),B(this.doc,"label",{class:`${x.panel}__field`,children:[B(this.doc,"span",{class:`${x.panel}__label`,text:this.t(u)}),t]})}}}),Le("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.cssEscape,I=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),w=z.isFunction,j=z.nextFrame,g=K("packages/dom/src/cell/icons.js"),u=g.createIcon,h=g.updateIcon,a=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,o=K("packages/dom/src/formattingpanel.js").FormattingPanel,l=K("packages/dom/src/statisticspanel.js").StatisticsPanel,m=K("packages/dom/src/regressionpanel.js").RegressionPanel,f=K("packages/dom/src/comparepanel.js").ComparePanel,p=K("packages/dom/src/insightspanel.js").InsightsPanel,A=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,y=K("packages/core/src/compute/total.js").TOTAL_LABELS;class S extends A{dragging=null;collapsed=new Set;refresh(){const P=this.root;if(!P)return;for(const Z of this.off)Z();this.off.length=0,W(P);const v=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(v.value=this.query),this.off.push(X(v,"input",()=>{this.query=v.value,this.paintList()})),P.appendChild(v),P.appendChild(this.buildZone("group","Row groups")),P.appendChild(this.buildZone("values","Grouped row calculation")),P.appendChild(this.buildZone("pivot","Pivot"));const N=_(this.doc,"div",{class:`${x.panel}__heading`});N.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{const Z=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.showColumns)&&this.host.showColumns(Z),this.refresh()})),this.off.push(X(q,"click",()=>{const Z=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.hideColumns)&&this.host.hideColumns(Z),this.refresh()})),N.appendChild(G),N.appendChild(q),P.appendChild(N),this.list=_(this.doc,"div",{class:`${x.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),P.appendChild(this.list),this.paintList()}columns(){const P=this.host;return w(P.columns)?P.columns()||[]:P.columns&&w(P.columns.all)?P.columns.all():[]}paintList(){const P=this.list;if(!P)return;W(P);const v=String(this.query||"").trim().toLowerCase();this.paintNodes(P,this.bandTree(),v)}paintNodes(P,v,N,G=!1){let q=0;for(const Z of v){if(Z.column){const he=String(Z.column.title||Z.column.id||"");if(N&&!G&&!he.toLowerCase().includes(N))continue;P.appendChild(this.buildColumnRow(Z.column)),q++;continue}const J=!!N&&this.bandTitle(Z.band).toLowerCase().includes(N),ee=_(this.doc,"div",{class:`${x.panel}__bandBody`}),ne=this.paintNodes(ee,Z.children,N,G||J);if(N&&!ne&&!J)continue;const ie=_(this.doc,"div",{class:`${x.panel}__band`,attrs:{role:"group","aria-label":this.bandTitle(Z.band),"data-band":Z.band.id}}),se=!this.collapsed.has(Z.band.id);ie.appendChild(this.buildBandRow(Z,se)),(se||N)&&ie.appendChild(ee),P.appendChild(ie),q++}return q}bandTree(){const P=this.columns(),v=new Map,N=this.host;if(w(N.columnGroups)){const Z=J=>{for(const ee of J||[])Array.isArray(ee.columns)&&(v.set(ee.id,ee.title),Z(ee.columns))};Z(N.columnGroups())}const G=[],q=new Map;for(const Z of P){let J=G,ee="";for(const ne of Z.groupPath||[]){ee+=`/${ne}`;let ie=q.get(ee);ie||(ie={band:{id:ne,title:v.has(ne)?v.get(ne):""},children:[],ids:[]},q.set(ee,ie),J.push(ie)),ie.ids.push(Z.id),J=ie.children}J.push({column:Z})}return G}bandTitle(P){return String(P.title||"")||this.t("columngroup.untitled")}buildColumnRow(P){const v=String(P.title||P.id||""),N=_(this.doc,"div",{class:`${x.panel}__column`,attrs:{"data-col":P.id,draggable:"true",title:this.t("panel.columnDragHint",{column:v})}});N.appendChild(_(this.doc,"span",{class:`${x.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":v}});return G.checked=!(P.layout&&P.layout.hidden),P.layout&&P.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(P.id,G.checked))),N.appendChild(G),N.appendChild(_(this.doc,"span",{text:v})),N.setAttribute("tabindex","0"),N.setAttribute("role","listitem"),this.off.push(X(N,"keydown",q=>this.onRowKey(q,P))),this.off.push(X(N,"dragstart",()=>{this.dragging=P.id})),this.off.push(X(N,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(N,"dragover",q=>{if(!this.dragging||this.dragging===P.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,P)){N.setAttribute("data-drop","into");return}const J=D(q,N);N.setAttribute("data-drop",J?"before":"after")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-drop"))),this.off.push(X(N,"drop",q=>{w(q.preventDefault)&&q.preventDefault();const Z=this.dragging;if(this.dragging=null,this.clearDropMark(),!Z||Z===P.id)return;const J=this.bandDrop(Z,P);if(J==="leave"){this.leaveBand(Z);return}if(J){this.joinBand(Z,J);return}this.moveColumn(Z,P.id,D(q,N))})),N}bandOf(P){const v=typeof P=="string"?this.columns().find(G=>G.id===P):P,N=v&&v.groupPath||[];return N.length?N[N.length-1]:null}bandDrop(P,v){const N=this.host;if(!w(N.groupColumns))return null;const G=this.bandOf(P),q=this.bandOf(v);return q&&q!==G?q:G&&!q?"leave":null}joinBand(P,v){const N=this.columns().find(q=>q.id===P),G=this.titleOf(P);if(N&&N.layout&&N.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([P],{groupId:v}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(v)}),{repeat:!0}),this.refresh()}leaveBand(P){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(P),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(P)}),{repeat:!0}),this.refresh())}bandName(P){const v=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===P)return q.band;const Z=v(q.children);if(Z)return Z}return null},N=v(this.bandTree());return N?this.bandTitle(N):P}buildBandRow(P,v){const{band:N,ids:G}=P,q=this.bandTitle(N),Z=_(this.doc,"div",{class:`${x.panel}__bandRow`,attrs:{"data-band-row":N.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${x.panel}__bandToggle`,attrs:{type:"button","aria-expanded":v?"true":"false","aria-label":this.t(v?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:v?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(N.id))),Z.appendChild(J);const ee=new Map(this.columns().map(ce=>[ce.id,ce])),ne=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.hidden)).length,ie=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":this.t("panel.bandVisible",{band:q})}});ie.checked=ne===G.length,ie.indeterminate=ne>0&&ne<G.length,ne>0&&ne<G.length&&ie.setAttribute("aria-checked","mixed");const se=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.lockVisible));se.length||ie.setAttribute("disabled",""),this.off.push(X(ie,"change",()=>{const ce=this.host;ie.checked?w(ce.showColumns)&&ce.showColumns(se):w(ce.hideColumns)&&ce.hideColumns(se),this.refresh()})),Z.appendChild(ie);const he=_(this.doc,"span",{class:`${x.panel}__bandTitle`,text:q});if(Z.appendChild(he),w(this.host.renameGroup)){const ce=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("columngroup.rename"),attrs:{type:"button","aria-label":this.t("panel.bandRenameFor",{band:q})}});this.off.push(X(ce,"click",()=>this.startBandRename(Z,he,N))),Z.appendChild(ce)}if(w(this.host.dissolveGroup)){const ce=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("columngroup.dissolve"),attrs:{type:"button","aria-label":this.t("panel.bandDissolveFor",{band:q})}});this.off.push(X(ce,"click",()=>this.dissolveBand(N.id))),Z.appendChild(ce)}return this.off.push(X(Z,"keydown",ce=>this.onBandKey(ce,N,Z))),this.off.push(X(Z,"dragover",ce=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===N.id||(w(ce.preventDefault)&&ce.preventDefault(),Z.setAttribute("data-drop","into"))})),this.off.push(X(Z,"dragleave",()=>Z.removeAttribute("data-drop"))),this.off.push(X(Z,"drop",ce=>{w(ce.preventDefault)&&ce.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||!w(this.host.groupColumns)||this.bandOf(te)===N.id)&&this.joinBand(te,N.id)})),Z}toggleBand(P){this.collapsed.has(P)?this.collapsed.delete(P):this.collapsed.add(P),this.paintList(),this.focusBand(P)}focusBand(P){const v=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${B(P)}"]`):null;v&&w(v.focus)&&v.focus()}dissolveBand(P){if(!w(this.host.dissolveGroup))return;const v=this.bandName(P);this.collapsed.delete(P),this.host.dissolveGroup(P),this.announce(this.t("a11y.group.dissolved",{group:v}),{repeat:!0}),this.refresh()}startBandRename(P,v,N){const G=_(this.doc,"input",{class:`${x.panel}__bandRename`,attrs:{type:"text","aria-label":this.t("columngroup.rename")}});G.value=N.title||"";let q=!1;const Z=J=>{q||(q=!0,J?(this.host.renameGroup(N.id,G.value),this.announce(this.t("a11y.group.renamed",{group:G.value}),{repeat:!0}),this.refresh()):this.paintList(),this.focusBand(N.id))};this.off.push(X(G,"keydown",J=>{J.key==="Enter"?(w(J.preventDefault)&&J.preventDefault(),Z(!0)):J.key==="Escape"&&(w(J.preventDefault)&&J.preventDefault(),Z(!1))})),this.off.push(X(G,"blur",()=>Z(!0))),v.parentNode&&v.parentNode.replaceChild(G,v),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(P,v,N){if(P.target&&P.target!==N)return;const G=P.key;G==="Enter"?(w(P.preventDefault)&&P.preventDefault(),this.toggleBand(v.id)):G==="Delete"?(w(P.preventDefault)&&P.preventDefault(),this.dissolveBand(v.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(P.preventDefault)&&P.preventDefault(),this.walk(N,G==="ArrowUp"))}walk(P,v){const N=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=N.indexOf(P),q=N[G+(v?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(P,v){const N=P&&P.key,G=S.zoneKeys[String(N).toLowerCase()];if(G&&!P.ctrlKey&&!P.metaKey&&!P.altKey){w(P.preventDefault)&&P.preventDefault(),this.toggleZone(G,v);return}if(N!=="ArrowUp"&&N!=="ArrowDown")return;const q=N==="ArrowUp",Z=this.columns().map(he=>he.id),J=Z.indexOf(v.id);if(J<0)return;if(w(P.preventDefault)&&P.preventDefault(),!P.shiftKey){const he=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],ce=he.findIndex(oe=>oe.getAttribute("data-col")===v.id),te=he[ce+(q?-1:1)];te&&w(te.focus)&&te.focus();return}const ee=v.layout&&(v.layout.movable===!1||v.layout.lockPosition),ne=String(v.title||v.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:ne}),{repeat:!0});return}const ie=Z[J+(q?-1:1)];if(!ie){this.announce(this.t(q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ne}),{repeat:!0});return}this.moveColumn(v.id,ie,q),this.announce(this.t("a11y.panel.moved",{column:ne,at:q?J:J+2,of:Z.length}),{repeat:!0});const se=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(v.id)}"]`):null;se&&w(se.focus)&&se.focus()}toggleZone(P,v){const N=this.titleOf(v.id),G=this.t(S.zoneLabel[P]||"panel.zone.group");if(this.zoneColumns(P).includes(v.id)){this.dropFromZone(P,v.id),this.announce(this.t("a11y.panel.removedFrom",{column:N,list:G}),{repeat:!0}),this.restoreFocus(v.id);return}if(this.addToZone(P,v.id)){this.announce(this.t("a11y.panel.addedTo",{column:N,list:G}),{repeat:!0}),this.restoreFocus(v.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:N,list:G}),{repeat:!0})}restoreFocus(P){const v=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(P)}"]`):null;v&&w(v.focus)&&v.focus()}announce(P,v){const N=this.host||{};w(N.announce)&&N.announce(P,v)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const P of this.list.querySelectorAll("[data-drop]"))P.removeAttribute("data-drop")}moveColumn(P,v,N){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(P,v,N),this.refresh())}buildZone(P,v){const N=_(this.doc,"div",{class:`${x.panel}__zone`,attrs:{"data-zone":P,role:"group","aria-label":v}});N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneTitle`,text:v}));const G=this.zoneColumns(P);let q=S.zoneAbout[P]||"";P==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneAbout`,text:q}));const Z=_(this.doc,"div",{class:`${x.panel}__zoneBody`});G.length||Z.appendChild(_(this.doc,"span",{class:`${x.panel}__zoneHint`,text:this.t(S.zoneHint[P]||"panel.zoneHint.any")})),P==="values"&&Z.classList.add(`${x.panel}__zoneBody--rows`);for(const J of G){const ee=_(this.doc,"span",{class:[x.chip,P==="values"?`${x.chip}--row`:""]});if(ee.appendChild(_(this.doc,"span",{class:`${x.chip}__label`,text:this.titleOf(J)})),P==="values"&&w(this.host.setValueAggregation)){const ie=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",se=_(this.doc,"select",{class:`${x.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const he of S.aggregations)se.appendChild(_(this.doc,"option",{text:this.t(`total.${he.name}`),attrs:{value:he.name,selected:he.name===ie?"":null}}));se.value=ie,this.off.push(X(se,"change",()=>{this.host.setValueAggregation(J,se.value),this.refresh()})),ee.appendChild(se)}const ne=_(this.doc,"button",{class:x.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(ne,"click",()=>this.dropFromZone(P,J))),ee.appendChild(ne),Z.appendChild(ee)}return this.off.push(X(N,"dragover",J=>{w(J.preventDefault)&&J.preventDefault(),N.setAttribute("data-over","true")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-over"))),this.off.push(X(N,"drop",J=>{w(J.preventDefault)&&J.preventDefault(),N.removeAttribute("data-over"),this.dragging&&this.addToZone(P,this.dragging)})),N.appendChild(Z),N}static aggregations=Object.freeze(Object.keys(y).map(P=>({name:P})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(P){const v=S.zoneApi[P],N=this.host;return v&&w(N[v.read])?N[v.read]()||[]:[]}titleOf(P){const v=this.columns().find(N=>N.id===P);return String(v&&(v.title||v.id)||P)}addToZone(P,v){const N=S.zoneApi[P],G=this.columns().find(Z=>Z.id===v);if(!N||!G||G[N.permission]===!1||!w(this.host[N.write]))return!1;const q=this.zoneColumns(P);return q.includes(v)?!1:(this.host[N.write]([...q,v]),this.refresh(),!0)}dropFromZone(P,v){const N=S.zoneApi[P];return!N||!w(this.host[N.write])?!1:(this.host[N.write](this.zoneColumns(P).filter(G=>G!==v)),this.refresh(),!0)}setVisible(P,v){const N=this.host;v&&w(N.showColumns)?N.showColumns([P]):!v&&w(N.hideColumns)&&N.hideColumns([P])}}class R extends A{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const P=this.root;if(!P)return;for(const ee of this.off)ee();this.off.length=0,W(P);const v=this.host,N=(w(v.columns)?v.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!w(v.filterFor))return;const G=N.filter(ee=>this.isFiltered(ee.id));P.appendChild(this.buildSearch()),P.appendChild(this.buildSummary(G.length,N.length));const q=this.query.trim().toLowerCase(),Z=q?N.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(q)):N;if(!Z.length){P.appendChild(_(this.doc,"p",{class:`${x.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${x.panel}__filters`});for(const ee of Z)J.appendChild(this.buildSection(ee));P.appendChild(J)}isFiltered(P){const v=this.host;return w(v.isFiltered)?v.isFiltered(P)===!0:!1}buildSearch(){const P=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return P.value=this.query,this.off.push(X(P,"input",()=>{this.query=P.value||"",this.refresh();const v=this.root&&this.root.querySelector?this.root.querySelector(`.${x.panel}__search`):null;v&&w(v.focus)&&v.focus()})),P}buildSummary(P,v){const N=_(this.doc,"div",{class:`${x.panel}__filterSummary`});if(N.appendChild(_(this.doc,"span",{class:`${x.panel}__filterCount`,text:P?this.t("panel.filterSummaryActive",{active:P,total:v}):this.t("panel.filterSummaryNone",{total:v}),attrs:{"data-active":P?"true":"false"}})),!P)return N;const G=_(this.doc,"button",{class:`${x.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(X(G,"click",()=>{w(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),N.appendChild(G),N}buildSection(P){const v=P.id,N=String(P.title||v),G=this.isFiltered(v),q=this.open.has(v),Z=_(this.doc,"section",{class:`${x.panel}__filter`,attrs:{"data-col":v,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${x.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:N})},children:[u(this.doc,q?"chevronDown":"chevronRight",{className:`${x.panel}__twisty`}),_(this.doc,"span",{class:`${x.panel}__filterName`,text:N})]});G&&J.appendChild(_(this.doc,"span",{class:`${x.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=_(this.doc,"div",{class:`${x.panel}__filterBody`,style:{display:q?"":"none"}}),ne=()=>{if(ee.firstChild)return;const ie=this.host.filterFor(v);ie&&w(ie.element)&&ee.appendChild(ie.element())};if(this.off.push(X(J,"click",()=>{const ie=this.open.has(v);ie?this.open.delete(v):this.open.add(v),J.setAttribute("aria-expanded",ie?"false":"true"),ee.style.display=ie?"none":"";const se=J.firstElementChild;se&&h(se,ie?"chevronRight":"chevronDown"),ie||ne()})),Z.appendChild(J),G){const ie=_(this.doc,"button",{class:`${x.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:N}),title:this.t("panel.clearFilter")},children:[u(this.doc,"close",{className:x.icon})]});this.off.push(X(ie,"click",se=>{w(se.stopPropagation)&&se.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(v),this.refresh()})),Z.appendChild(ie)}return Z.appendChild(ee),q&&ne(),Z}}class O extends A{refresh(){const P=this.root;if(!P)return;if(this.box){const q=w(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==q&&(this.box.value=q),this.paintCount();return}for(const q of this.off)q();this.off.length=0,W(P);const v=w(this.host.quickFilter)?this.host.quickFilter():"",N=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});N.value=v||"",this.off.push(X(N,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(N.value),this.paintCount()})),P.appendChild(N),this.box=N;const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{N.value="",w(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),w(N.focus)&&N.focus()})),P.appendChild(G),this.count=_(this.doc,"p",{class:`${x.panel}__count`}),P.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){j(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const P=w(this.host.rowCount)?this.host.rowCount():null,v=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(P===null||v===null||P===void 0){this.count.textContent="";return}this.count.textContent=P===v?this.t("count.rows",{count:v}):this.t("panel.rowsOf",{shown:P,total:v})}}const F=Object.freeze({columns:S,filters:R,views:t,quick:O,formatting:o,statistics:l,regression:m,compare:f,insights:p}),E=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),T=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class L{panels=[];actions=[];root=null;openPanel=null;off=[];t(P,v){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(P,v)}init(P){const v=P||{};this.doc=I(v),this.host=v.host||{},this.grid=v.grid||null,this.messages=v.messages||v.grid&&v.grid.messages||H,this.icons=v.icons===void 0?v.side==="left":!!v.icons,this.side=v.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[x.panel,`${x.panel}--${this.side}`,this.icons?`${x.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${x.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${x.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=_(this.doc,"div",{class:`${x.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(v.actions)?v.actions:[])this.registerAction(q);const N=v.registry||{},G=Array.isArray(v.panels)&&v.panels.length?v.panels:["columns","filters"];for(const q of G){const Z=q!==null&&typeof q=="object",J=Z?q.name:q,ee=w(J),ne=ee?J.name||"panel":String(J),ie=Z&&w(q.Ctor)?q.Ctor:ee?J:N[ne]||F[ne];ie&&this.registerPanel(ne,ie,Z?q:{})}v.openPanel&&this.show(v.openPanel)}registerPanel(P,v,N){const G=new v;G.init({document:this.doc,host:this.host,grid:this.grid,props:N&&N.props||{}});const q=N&&N.title||P,Z=N&&N.icon||P,J=_(this.doc,"button",{class:`${x.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":P,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(u(this.doc,Z,{className:`${x.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(P))),this.tabs.appendChild(J),this.panels.push({name:P,title:q,panel:G}),G}registerAction(P){if(!P||!P.name)return null;if(P.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${x.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const v=_(this.doc,"button",{class:`${x.panel}__action`,text:this.icons?null:w(P.title)?String(P.title()):P.title,attrs:{type:"button","data-action":P.name,title:w(P.title)?null:P.title,"aria-label":w(P.title)?null:P.title}});if(this.icons){const q=(w(P.icon)?P.icon():P.icon)||(a(P.name)?P.name:"blank");v.appendChild(u(this.doc,q,{className:`${x.panel}__icon`})),v.setAttribute("data-icon",q)}const N=X(v,"click",()=>{w(P.enabled)&&!P.enabled()||(w(P.run)&&P.run(),this.paintActions())});return this.off.push(N),this.actionGroup.appendChild(v),this.actions.push({...P,button:v,offClick:N}),this.paintActions(),v}removeAction(P){const v=this.actions.findIndex(G=>G.name===P);if(v<0)return!1;const N=this.actions[v];return w(N.offClick)&&N.offClick(),N.button&&N.button.parentNode&&N.button.parentNode.removeChild(N.button),this.actions.splice(v,1),!0}paintActions(){for(const P of this.actions){if(!P.button)continue;const v=w(P.enabled)?!!P.enabled():!0;if(P.button.disabled=!v,P.button.setAttribute("aria-disabled",v?"false":"true"),w(P.active)&&P.button.setAttribute("aria-pressed",P.active()?"true":"false"),w(P.title)){const N=String(P.title());P.button.setAttribute("title",N),P.button.setAttribute("aria-label",N),!this.icons&&P.button.textContent!==N&&(P.button.textContent=N)}if(this.icons&&w(P.icon)){const N=String(P.icon());P.button.getAttribute("data-icon")!==N&&(W(P.button),P.button.appendChild(u(this.doc,N,{className:`${x.panel}__icon`})),P.button.setAttribute("data-icon",N))}}}show(P){const v=this.panels.find(N=>N.name===P);return v?(W(this.body),w(v.panel.refresh)&&v.panel.refresh(),this.body.appendChild(v.panel.element()),this.openPanel=P,this.paintTabs(),w(v.panel.focus)&&v.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(P){this.openPanel===P?this.hide():this.show(P)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let P=0;P<this.tabs.childNodes.length;P++){const v=this.tabs.childNodes[P];v&&v.setAttribute&&v.setAttribute("aria-selected",v.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const P=this.panels.find(v=>v.name===this.openPanel);P&&w(P.panel.refresh)&&!this.#e(P.panel)&&P.panel.refresh(),this.paintActions()}#e(P){const v=this.doc&&this.doc.activeElement;if(!v||v===this.doc.body)return!1;const N=w(P.element)?P.element():null;return!!(N&&w(N.contains)&&N.contains(v))}destroy(){for(const P of this.off)P();this.off.length=0;for(const P of this.panels)w(P.panel.destroy)&&P.panel.destroy();this.panels=[],this.root=null}}const C=L;function D($,P){if(!P.getBoundingClientRect||typeof $.clientY!="number")return!0;const v=P.getBoundingClientRect();return $.clientY<v.top+v.height/2}}),Le("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return j}});const x=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),I=B.CLS,_=B.el,X=B.on,W=B.clear,V=B.cssEscape,z=K("packages/core/src/internal/util.js").isFunction,w="text/x-lattice-col";class j extends x{dragging=null;#e=[];init(u){this.ctx=u,this.doc=u.document,this.host=u.host||{},this.props=u.props||{},this.root=_(this.doc,"div",{class:I.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const u=this.host;return z(u.columns)?u.columns()||[]:u.columns&&z(u.columns.all)?u.columns.all():[]}groups(){return z(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(u){z(this.host.setGroupBy)&&this.host.setGroupBy(u)}titleOf(u){const h=this.columns().find(a=>a.id===u);return String(h&&(h.title||h.id)||u)}canGroup(u){const h=this.columns().find(a=>a.id===u);return!!h&&h.allowGroup!==!1&&!h.generated}announce(u,h){z(this.host.announce)&&this.host.announce(u,h)}refresh(){const u=this.root;if(!u)return;for(const r of this.off)r();this.off.length=0,W(u),u.appendChild(_(this.doc,"span",{class:I.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const h=this.groups(),a=_(this.doc,"div",{class:I.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});h.length||a.appendChild(_(this.doc,"span",{class:I.groupZoneHint,text:this.t("groupZone.hint")})),h.forEach((r,t)=>a.appendChild(this.#t(r,t,h.length))),u.appendChild(a),this.chips=a,u.appendChild(this.#i(h)),this.off.push(X(u,"dragover",r=>{this.dragging==null&&!this.#l(r)||(z(r.preventDefault)&&r.preventDefault(),u.setAttribute("data-over","true"))})),this.off.push(X(u,"dragleave",()=>u.removeAttribute("data-over"))),this.off.push(X(u,"drop",r=>{z(r.preventDefault)&&r.preventDefault(),u.removeAttribute("data-over");const t=this.#l(r)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(u,h,a){const r=this.titleOf(u),t=_(this.doc,"div",{class:[I.chip,I.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":u,"aria-label":this.t("groupZone.chip",{column:r,at:h+1,of:a})}});t.appendChild(_(this.doc,"span",{class:I.groupZoneChipText,text:r}));const n=_(this.doc,"button",{class:I.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:r})}});return this.off.push(X(n,"click",()=>this.#r(u))),t.appendChild(n),this.off.push(X(t,"dragstart",o=>{this.dragging=u,o.dataTransfer&&z(o.dataTransfer.setData)&&o.dataTransfer.setData(w,u)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",o=>{const d=this.#l(o)||this.dragging;d==null||d===u||z(o.preventDefault)&&o.preventDefault()})),this.off.push(X(t,"drop",o=>{const d=this.#l(o)||this.dragging;d!=null&&(z(o.preventDefault)&&o.preventDefault(),z(o.stopPropagation)&&o.stopPropagation(),this.#o(d,h))})),this.off.push(X(t,"keydown",o=>this.#n(o,u,h))),t}#n(u,h,a){const r=u&&u.key,t=this.groups();if(r==="Delete"||r==="Backspace"){z(u.preventDefault)&&u.preventDefault(),this.#r(h,t,a);return}const n=r==="ArrowLeft"||r==="ArrowUp",o=r==="ArrowRight"||r==="ArrowDown",d=r==="Home",l=r==="End";if(!n&&!o&&!d&&!l)return;if(z(u.preventDefault)&&u.preventDefault(),u.shiftKey&&(n||o)){const c=a+(n?-1:1);if(c<0||c>=t.length){this.announce(this.t(n?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(h)}),{repeat:!0});return}const f=t.slice();f.splice(a,1),f.splice(c,0,h),this.setGroups(f),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(h),at:c+1,of:f.length}),{repeat:!0}),this.#a(h);return}let i=a+(n?-1:o?1:0);d&&(i=0),l&&(i=t.length-1);const m=t[i];m&&this.#a(m)}#r(u,h=this.groups(),a=h.indexOf(u)){const r=this.titleOf(u);this.setGroups(h.filter(n=>n!==u)),this.announce(this.t("a11y.panel.removedFrom",{column:r,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(a,t.length-1)]):this.#u()}#o(u,h){if(!this.canGroup(u)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0});return}const a=this.groups(),r=a.indexOf(u),t=a.slice();r>=0&&(t.splice(r,1),r<h&&(h-=1)),t.splice(Math.max(0,Math.min(h,t.length)),0,u),this.setGroups(t);const n=t.indexOf(u);this.announce(this.t(r>=0?"a11y.panel.moved":"a11y.panel.addedTo",r>=0?{column:this.titleOf(u),at:n+1,of:t.length}:{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(u)}#i(u){const h=new Set(u),a=_(this.doc,"label",{class:I.groupZoneAdd}),r=_(this.doc,"select",{class:I.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});r.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())h.has(t.id)||!this.canGroup(t.id)||r.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(r,"change",()=>{const t=r.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=r,a.appendChild(r),a}#s(){for(const h of this.#e)h();this.#e.length=0;const u=this.props&&this.props.header;if(!(!u||!z(u.querySelectorAll)))for(const h of u.querySelectorAll("[data-col]")){const a=z(h.getAttribute)?h.getAttribute("data-col"):null;!a||!this.canGroup(a)||(z(h.setAttribute)&&h.setAttribute("draggable","true"),this.#e.push(X(h,"dragstart",r=>{this.dragging=a,r.dataTransfer&&z(r.dataTransfer.setData)&&r.dataTransfer.setData(w,a)})),this.#e.push(X(h,"dragend",()=>{this.dragging=null})))}}#l(u){const h=u&&u.dataTransfer;if(h&&z(h.getData)){const a=h.getData(w);if(a)return a}return null}#a(u){const h=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${V(u)}"]`):null;h&&z(h.focus)&&h.focus()}#u(){this.adderSelect&&z(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const u of this.#e)u();this.#e.length=0,super.destroy()}}}),Le("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction;class H{root=null;init(g){this.doc=g.document,this.root=I(this.doc,"div",{class:`${x.tooltip}__text`}),this.update(g.content)}update(g){if(!this.root)return;const u=g==null?"":String(g);this.root.textContent!==u&&(this.root.textContent=u)}element(){return this.root}destroy(){this.root=null}}class z{root=null;component=null;timer=null;target=null;off=[];constructor(g){const u=g||{};this.doc=B(u),this.host=u.host||this.doc.body,this.delay=u.delay??400,this.hideDelay=u.hideDelay??0,this.components={text:H,...u.components||{}}}show(g){this.cancelTimer();const u=g.delay??this.delay;if(!u){this.showNow(g);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(g)},u)}showNow(g){const u=g.component||"text",h=typeof u=="function"?u:this.components[u]||H;return this.root||(this.root=I(this.doc,"div",{class:x.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==h?(this.component&&V(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new h,this.componentCtor=h,this.component.init({document:this.doc,content:g.content,...g.props||{}}),this.root.appendChild(this.component.element())):V(this.component.update)&&this.component.update(g.content),this.target=g.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!V(this.target.getBoundingClientRect))return;const g=this.target.getBoundingClientRect(),u=this.doc.defaultView||{};this.root.style.left=`${g.left+(u.scrollX||0)}px`,this.root.style.top=`${g.bottom+(u.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(g,u,h){const a=()=>this.show({target:g,content:u(),...h||{}}),r=()=>this.hide(),t=[_(g,"mouseenter",a),_(g,"mouseleave",r),_(g,"focus",a),_(g,"blur",r)],n=()=>{for(const o of t)o()};return this.off.push(n),n}destroy(){this.hide();for(const g of this.off)g();this.off.length=0,this.component&&V(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const w=z}),Le("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js").isFunction;function w(u){const h=Math.max(1,Number(u.pageSize)||100),a=u.total==null?null:Math.max(0,Number(u.total)),r=a==null?null:Math.max(1,Math.ceil(a/h)),t=Math.max(0,r==null?Number(u.page)||0:Math.min(Number(u.page)||0,r-1)),n=a===0?0:t*h+1,o=a==null?(t+1)*h:Math.min(a,(t+1)*h);return{page:t,pageSize:h,pageCount:r,from:n,to:o,first:t===0,last:r==null?u.hasMore!==!0:t>=r-1,total:a}}class j{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(h){const a=h||{};this.doc=B(a),this.host=a.host||{},this.pageSize=Number(a.pageSize)||100;const r=Array.isArray(a.pageSizes)&&a.pageSizes.length?[...a.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!r.includes(this.pageSize)&&r.push(this.pageSize),this.pageSizes=r.sort((t,n)=>t-n),this.page=Number(a.page)||0,this.total=a.total===void 0?null:a.total,this.locale=a.locale,this.messages=a.messages||null,this.onChange=a.onChange||null,this.root=I(this.doc,"nav",{class:x.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(h,a){const r=this.messages;return(r&&typeof r.t=="function"?r:V).t(h,a)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(h){h.total!==void 0&&(this.total=h.total),h.counting!==void 0&&(this.counting=h.counting===!0),h.hasMore!==void 0&&(this.hasMore=h.hasMore===!0),h.page!==void 0&&(this.page=Number(h.page)||0),this.paint()}goTo(h){const a=this.page;this.page=h;const r=this.model();return this.page=r.page,this.paint(),this.page!==a&&z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const h=this.model();return h.pageCount==null?this.page:this.goTo(h.pageCount-1)}setPageSize(h){const a=this.page*this.pageSize;this.pageSize=Math.max(1,Number(h)||1),this.page=Math.floor(a/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const h=this.root;if(!h)return;for(const i of this.off)i();this.off.length=0,X(h);const a=this.model(),r=I(this.doc,"select",{class:`${x.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)r.appendChild(I(this.doc,"option",{text:String(i),attrs:{value:i}}));r.value=String(this.pageSize),this.off.push(_(r,"change",()=>this.setPageSize(Number(r.value)))),h.appendChild(r);const t=a.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:a.from,to:a.to}):this.t("pagination.summary",{from:a.from,to:a.to,total:a.total});h.appendChild(I(this.doc,"span",{class:`${x.pagination}__summary`,text:t}));const n=(i,m,c,f)=>{const s=I(this.doc,"button",{class:`${x.pagination}__button`,text:i,attrs:{type:"button","aria-label":f,disabled:c?"":null}});return c||this.off.push(_(s,"click",m)),s};h.appendChild(n("«",()=>this.goTo(0),a.first,this.t("pagination.first"))),h.appendChild(n("‹",()=>this.previous(),a.first,this.t("pagination.previous")));const o=I(this.doc,"span",{class:`${x.pagination}__page`});o.appendChild(I(this.doc,"span",{text:`${this.t("pagination.page")} `}));const d=I(this.doc,"input",{class:`${x.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":a.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:a.pageCount}),size:String(Math.max(2,String(a.pageCount??a.page+1).length))}});d.value=String(a.page+1);const l=()=>{const i=parseInt(String(d.value).trim(),10);if(!Number.isFinite(i)){d.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(_(d,"keydown",i=>{i.key==="Enter"?(l(),i.preventDefault?.()):i.key==="Escape"?(d.value=String(this.model().page+1),d.blur?.()):i.stopPropagation?.()})),this.off.push(_(d,"blur",()=>l())),this.off.push(_(d,"focus",()=>d.select?.())),o.appendChild(d),a.pageCount!=null&&o.appendChild(I(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:a.pageCount})}`})),h.appendChild(o),h.appendChild(n("›",()=>this.next(),a.last,this.t("pagination.next"))),h.appendChild(n("»",()=>this.last(),a.last||a.pageCount==null,this.t("pagination.last")))}destroy(){for(const h of this.off)h();this.off.length=0,this.root=null}}const g=j}),Le("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,B=Q.documentFor,I=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/i18n/index.js").defaultMessages;function z(a,r){const t=a&&a.grid&&a.grid.messages;return(t&&W(t.t)?t:H).t(r)}class w{root=null;init(r){this.doc=r.document,this.root=I(this.doc,"div",{class:`${x.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[I(this.doc,"span",{class:`${x.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),I(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||z(r,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class j{root=null;init(r){this.doc=r.document,this.root=I(this.doc,"div",{class:`${x.overlay}__empty`,attrs:{role:"status"},children:[I(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||z(r,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:j});class u{root=null;slot=null;component=null;current=null;init(r){const t=r||{};this.doc=B(t),this.components={...g,...t.components||{}},this.root=I(this.doc,"div",{class:x.overlay,attrs:{"data-open":"false"}}),this.slot=I(this.doc,"div",{class:`${x.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(r,t){const n=typeof r=="function"?r:this.components[r];return n?(this.hide(),this.component=new n,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof r=="string"?r:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&W(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&_(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(r,t){this.components[r]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const h=u}),Le("packages/dom/src/ui/index.js",function(e,K){"use strict";const Q=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Q.formatNumber}});const x=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return x.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return x.resolveMenuItems}});const B=K("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return B.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return B.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return B.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return B.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return B.toolPanels}});const I=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return I.GroupByZone}});const _=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return _.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return _.TextTooltip}});const X=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return X.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return X.pageModel}});const W=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return W.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return W.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return W.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return W.overlays}})}),Le("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,X=K("packages/core/src/internal/util.js"),W=X.isFunction,V=X.warnOnce,z=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,j=K("packages/dom/src/detailhost.js").insideDetail,u=K("packages/dom/src/renderer/renderer.js").displayIndexOf,h=K("packages/dom/src/renderer/viewport.js"),a=h.CLASS,r=h.NAMESPACE,n=K("packages/dom/src/themeof.js").carryTheme,o={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},d=400,l=140,i=6;let m=0;class c{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#p=!1;constructor(p){const b=p||{};this.#e=b.grid,this.#t=b.host,this.#n=b.viewport,this.#r=x(b),m+=1,this.#s=`lat-cell-tooltip-${m}`}mount(){const p=this.#n&&this.#n.root;if(!p||!W(p.addEventListener))return;const b=this.#e.on("cell:mouseover",y=>this.#w(y));W(b)&&this.#f.push(b);const A=this.#e.on("cell:mouseout",()=>this.#k());W(A)&&this.#f.push(A),this.#f.push(I(p,"focusin",y=>this.#O(y))),this.#f.push(I(p,"focusout",()=>this.#k())),this.#f.push(I(this.#r,"keydown",y=>this.#y(y),!0));const k=this.#r.defaultView;k&&W(k.addEventListener)&&this.#f.push(I(k,"scroll",()=>this.hide(),!0))}#m(){const p=W(this.#e.get)?this.#e.get("tooltip"):null,b=p&&typeof p=="object"?p:{},A=Number.isFinite(b.delay)&&b.delay>=0?Number(b.delay):d,k=b.maxWidth;return{delay:A,hideDelay:l,maxWidth:typeof k=="number"&&Number.isFinite(k)?`${k}px`:typeof k=="string"&&k?k:null}}#g(p){const b=p&&p.cell?p.cell.tooltip:null;return!b||typeof b!="object"||Array.isArray(b)||!W(b.render)&&!W(b.mount)?null:b}#b(p){if(!p||!W(p.closest))return null;const b=p.closest(`.${a.row}`);if(!b)return null;const A=u(b);if(A<0)return null;const k=this.#t.rowAt(A);if(!k)return null;const y=p.getAttribute("data-col");if(!y)return null;const S=this.#t.columns.get(y);return S?{row:k,key:k.key,index:A,colId:y,column:S,value:this.#t.cellValue?this.#t.cellValue(k,S):void 0,text:this.#t.cellText?this.#t.cellText(k,S):"",cell:p,grid:this.#e}:null}#w(p){const b=p&&p.target;if(!this.#g(p&&p.column)){this.#k();return}this.#A(b)}#O(p){const b=p&&p.target;if(!b||!W(b.closest)||j(b,this.#n.root))return;const A=b.closest(`.${a.cell}`);if(!A||A!==b){this.#k();return}const k=A.getAttribute("data-col"),y=k?this.#t.columns.get(k):null;if(!this.#g(y)){this.#k();return}this.#A(A)}#y(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#A(p){if(this.#p||!p||(this.#$(),this.#l&&this.#a===p))return;this.#N();const{delay:b}=this.#m();if(!b){this.#T(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#T(p)},b)}#k(){if(this.#N(),!this.#l||this.#h!==null)return;const{hideDelay:p}=this.#m();this.#h=setTimeout(()=>{this.#h=null,this.hide()},p)}#C(){if(this.#o)return this.#o;const p=this.#r,b=B(p,"div",{class:[r,o.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:o.body}),b.appendChild(this.#i),this.#f.push(I(b,"mouseenter",()=>this.#$())),this.#f.push(I(b,"mouseleave",()=>this.#k()));const A=p.body;return A&&W(A.appendChild)&&A.appendChild(b),this.#o=b,b}#S(p,b){const A=this.#i;if(_(A),p==null||p==="")return!1;if(typeof p=="string")return A.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return A.appendChild(p),!0;const k=p;if(typeof k.html=="string")return A.innerHTML=z(k.html),!0;if(k.title!==void 0||k.rows!==void 0||k.note!==void 0)return this.#E(k),!0}return V(`tooltip-content:${b}`,`Column '${b}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#E(p){const b=this.#r,A=this.#i,k=S=>S==null?"":String(S);p.title!==void 0&&p.title!==null&&p.title!==""&&A.appendChild(B(b,"div",{class:o.title,text:k(p.title)}));const y=Array.isArray(p.rows)?p.rows:[];if(y.length){const S=B(b,"div",{class:o.rows});for(const R of y){if(!R||typeof R!="object")continue;const O=B(b,"div",{class:o.row});O.appendChild(B(b,"span",{class:o.label,text:k(R.label)})),O.appendChild(B(b,"span",{class:o.value,text:k(R.value)})),S.appendChild(O)}A.appendChild(S)}p.note!==void 0&&p.note!==null&&p.note!==""&&A.appendChild(B(b,"div",{class:o.note,text:k(p.note)}))}#T(p){if(this.#p)return;const b=this.#b(p);if(!b){this.hide();return}const A=this.#g(b.column);if(!A){this.hide();return}this.hide();const k=this.#C();n(k,this.#n&&this.#n.root);let y;if(W(A.render))try{y=A.render(b)}catch(O){V(`tooltip-render:${b.colId}`,`Column '${b.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const S=this.#S(y,b.colId);if(W(A.mount))try{A.mount(this.#i,b),this.#u=A}catch(O){V(`tooltip-mount:${b.colId}`,`Column '${b.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!S)return;const{maxWidth:R}=this.#m();R&&(k.style.maxWidth=R),this.#a=p,this.#l=!0,k.setAttribute("data-open","true"),this.#P(p),this.#M(p)}#P(p){if(!W(p.setAttribute))return;const b=W(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:b},p.setAttribute("aria-describedby",b?`${b} ${this.#s}`:this.#s)}#M(p){const b=this.#o;if(!b||!W(p.getBoundingClientRect))return;const A=this.#r.defaultView;if(!A)return;const k=p.getBoundingClientRect(),y=W(b.getBoundingClientRect)?b.getBoundingClientRect():{width:0,height:0},S=A.innerWidth||0,R=A.innerHeight||0,O=y.width||0,F=y.height||0;let E=k.bottom+i;const T=k.top-i-F;E+F>R-i&&T>=i&&(E=T),R&&(E=Math.max(i,Math.min(E,Math.max(i,R-F-i))));let L=k.left;S&&(L=Math.min(L,Math.max(i,S-O-i))),L=Math.max(i,L),b.style.left=`${Math.round(L)}px`,b.style.top=`${Math.round(E)}px`}hide(){if(this.#N(),this.#$(),!this.#l)return;if(this.#l=!1,this.#u&&W(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(b){V("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",b)}this.#u=null,this.#i&&_(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const p=this.#c;p&&W(p.cell.setAttribute)&&(p.previous?p.cell.setAttribute("aria-describedby",p.previous):W(p.cell.removeAttribute)&&p.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#$(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#f)p();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const f=c}),Le("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const x=globalThis.navigator,B=String(x&&(x.userAgentData?.platform||x.platform)||"");return/mac|iphone|ipad/i.test(B)}}),Le("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),w=z.aggregatesFor,j=z.totalLabel,g=10,u=150;function h(A,k){const y=(ee,ne)=>(A&&A.messages?A.messages:W).t(ee,ne),S=A.columns.get(k);if(!S)return[];const R=A.sort.get(),O=R.find(ee=>ee.col===k),F=S.layout&&S.layout.pin,E=A.state.get().group||[],T=E.includes(k);if(S.generated&&Array.isArray(S.groupedIds))return n(A,S,E);const L=!S.sort||S.sort.enabled!==!1,C=!S.filter||S.filter.enabled!==!1,D=[];L&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>A.sort.set([{col:k,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>A.sort.set([{col:k,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!O,action:()=>A.sort.set(R.filter(ee=>ee.col!==k))},{separator:!0}),C&&D.push({name:y("menu.filterEllipsis"),action:()=>A.emit("column:filter:open",{colId:k})},{separator:!0}),D.push({name:y("menu.columnStatistics"),action:()=>A.emit("column:profile:open",{colId:k})},{separator:!0}),D.push({name:y("menu.pinColumn"),children:[{name:y("menu.pinStart"),disabled:F==="start",action:()=>A.columns.pin(k,"start")},{name:y("menu.pinEnd"),disabled:F==="end",action:()=>A.columns.pin(k,"end")},{name:y("menu.unpin"),disabled:!F,action:()=>A.columns.pin(k,null)}]});const $=!(S.layout&&(S.layout.movable===!1||S.layout.lockPosition)),P=!(S.layout&&S.layout.resizable===!1),v=ee=>{const ne=A.columns.get(ee);return Number(ne&&ne.layout&&ne.layout.width)||u},N=A.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),G=N.indexOf(k);if(D.push({name:y("menu.sizeToFit"),action:()=>A.columns.autoSize(k)},{name:y("menu.sizeAllToFit"),action:()=>A.columns.fit()},{name:y("menu.width"),disabled:!P,children:[{name:y("menu.narrower"),disabled:!P,action:()=>A.columns.resize(k,Math.max(1,v(k)-g))},{name:y("menu.wider"),disabled:!P,action:()=>A.columns.resize(k,v(k)+g)},{name:y("menu.autosize"),disabled:!P,action:()=>A.columns.autoSize(k)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!$,children:[{name:y("menu.moveLeft"),disabled:!$||G<=0,action:()=>A.columns.move(k,Math.max(0,G-1))},{name:y("menu.moveRight"),disabled:!$||G<0||G>=N.length-1,action:()=>A.columns.move(k,Math.min(N.length-1,G+1))},{name:y("menu.moveToStart"),disabled:!$||G<=0,action:()=>A.columns.move(k,0)},{name:y("menu.moveToEnd"),disabled:!$||G<0||G>=N.length-1,action:()=>A.columns.move(k,N.length-1)}]},{separator:!0}),S.allowGroup!==!1&&D.push({name:y(T?"menu.ungroup":"menu.groupBy"),action:()=>A.columns.group(T?E.filter(ee=>ee!==k):[...E,k])}),E.length&&D.push({name:y("menu.expandAll"),action:()=>A.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>A.rows.collapseAll()}),x(A.columns.groupColumns)){const ee=S.groupPath||[],ne=ee.length?ee[ee.length-1]:null,ie=[{name:y("columngroup.group"),disabled:N.length<2||G<0,action:()=>{const se=N[G+1]??N[G-1];if(!se)return;const he=(A.columns.get(se)||{}).groupPath||[],ce=he.length?he[he.length-1]:null;ce?A.columns.groupColumns([k],{groupId:ce}):A.columns.groupColumns([k,se],{title:y("columngroup.newGroup")})}}];ne&&ie.push({name:y("columngroup.dissolve"),action:()=>A.columns.dissolveGroup(ne)}),D.push({separator:!0},...ie)}const q=A.state&&x(A.state.get)?A.state.get().pivot:null,Z=q&&q.columns||[],J=Z.includes(k);if(S.allowPivot!==!1&&D.push({name:y(J?"menu.unpivot":"menu.pivotBy"),action:()=>A.columns.pivot(J?Z.filter(ee=>ee!==k):[...Z,k])}),S.allowTotal!==!1)if(x(A.get)&&A.get("aggregateChooser")===!0)D.push(a(A,S,y));else{const ne=!!S.total;D.push({name:y(ne?"menu.stopTotalling":"menu.totalColumn"),action:()=>A.columns.setTotal(k,ne?null:"sum")})}return D.push({name:y("menu.hideColumn"),disabled:S.layout&&S.layout.lockVisible===!0,action:()=>A.columns.hide(k)}),D}function a(A,k,y){const S=k.id,R=typeof k.total=="string"?k.total:null,O=[{name:y("menu.aggregateNone"),checked:!k.total,action:()=>A.columns.setTotal(S,null)},{separator:!0},...w(k).map(F=>({name:j(F),checked:R===F,action:()=>A.columns.setTotal(S,F)})),{separator:!0},r(A,k,y,"group",y("menu.aggregateGroup")),r(A,k,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:O}}function r(A,k,y,S,R){const O=k.id,F=S==="grand"?k.grandTotal:k.groupTotal,E=typeof F=="string"?F:null,T=[{name:y("menu.aggregateSame"),checked:F==null,action:()=>A.columns.setTotal(O,null,{scope:S})},{separator:!0},...w(k).map(L=>({name:j(L),checked:E===L,action:()=>A.columns.setTotal(O,L,{scope:S})}))];return{name:R,children:T}}function t(A,k){const y=(E,T)=>(A&&A.messages?A.messages:W).t(E,T),S=A.columns.get(k);if(!S)return[];const R=A.redaction,O=!!(R&&R.has(k)),F=[];return R&&(F.push({name:y(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(k)}),(R.list().length>1||R.active&&!O)&&F.push({name:y("menu.stopRedactingAll"),action:()=>R.clear()}),F.push({separator:!0})),F.push({name:y("menu.hideColumn"),disabled:S.layout&&S.layout.lockVisible===!0,action:()=>A.columns.hide(k)}),F}function n(A,k,y){const S=(T,L)=>(A&&A.messages?A.messages:W).t(T,L),R=y[0],O=A.sort.get(),F=R?O.find(T=>T.col===R):null,E=[];R&&E.push({name:S("menu.sortGroupsAscending"),icon:"↑",disabled:F&&F.dir==="asc",action:()=>A.sort.set([{col:R,dir:"asc"}])},{name:S("menu.sortGroupsDescending"),icon:"↓",disabled:F&&F.dir==="desc",action:()=>A.sort.set([{col:R,dir:"desc"}])},{separator:!0},{name:S("menu.filterGroups"),action:()=>A.emit("column:filter:open",{colId:k.id})},{separator:!0}),E.push({name:S("menu.expandAll"),action:()=>A.rows.expandAll()},{name:S("menu.collapseAll"),action:()=>A.rows.collapseAll()},{separator:!0});for(const T of y){const L=A.columns.get(T);E.push({name:`Remove "${L&&L.title||T}" from grouping`,action:()=>A.columns.group(y.filter(C=>C!==T))})}return E.push({name:S("menu.clearGrouping"),disabled:!y.length,action:()=>A.columns.group([])}),E}function o(){const A=globalThis.navigator&&globalThis.navigator.clipboard;return!!(A&&typeof A.readText=="function")}function d(A){return x(A.get)&&A.get("edit")===!1?!1:(A.columns&&x(A.columns.visible)?A.columns.visible():[]).some(y=>{const S=y&&y.edit;return S?S.enabled===void 0||x(S.enabled)?!0:S.enabled!==!1:!1})}function l(A,k){if(x(A.get)&&A.get("edit")===!1)return!1;const y=k&&k.edit;return y?y.enabled===void 0||x(y.enabled)?!0:y.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function m(A){const k=x(A.get)?A.get("rangeChart"):void 0;return k?x(k)?{enabled:!0,handler:k}:k&&typeof k=="object"&&x(k.onChart)?{enabled:!0,handler:k.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(A){const k=A.selection&&x(A.selection.ranges)?A.selection.ranges():[];if(!Array.isArray(k)||!k.length)return null;const y=k[k.length-1],S=x(A.columns.visible)?A.columns.visible():[],R=new Set(S.filter(O=>O&&i.has(O.type)).map(O=>O.id));return(y.columns||[]).some(O=>R.has(O))?y:null}function f(A,k){const y=(Z,J)=>(A&&A.messages?A.messages:W).t(Z,J),{colId:S,row:R}=k,O=A.selection.keys().length,F=A.selection.cells().length,E=(A.state&&x(A.state.get)?A.state.get().group:null)||[],T=A.ranges||null,L=_()?"Cmd":"Ctrl",C=()=>F||O||0,D=Z=>A.columns&&x(A.columns.get)?A.columns.get(Z):null,$=x(A.selection.cells)?A.selection.cells():[],P=[...new Set($.map(Z=>Z&&Z.colId).filter(Boolean))];!P.length&&S&&P.push(S);const v=P.length?P.some(Z=>l(A,D(Z))):d(A),N=S?l(A,D(S)):!1,G=m(A),q=G.enabled?c(A):null;return[{name:F>1?`Copy ${F} cells`:y("menu.copy"),shortcut:`${L}+C`,disabled:!C(),action:()=>T&&F?T.copy():A.export.clipboard({rows:O?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!C(),action:()=>A.export.clipboard({headers:!0,rows:O?"selected":"range"})},...S==null?[]:[{name:y("menu.paste"),shortcut:`${L}+V`,disabled:!T||!v||!o(),action:()=>T&&T.paste()},{separator:!0},{name:y("menu.clearCells",{count:F||1}),shortcut:"Delete",disabled:!T||!v||!F,action:()=>T&&T.clear()},{name:y("menu.fillDown"),shortcut:`${L}+D`,disabled:!T||!v||F<2,action:()=>T&&T.fillDown()}],...q&&G.handler?[{name:"Chart selection",action:()=>G.handler(A,q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>A.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>A.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>A.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,action:()=>A.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>A.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>A.export.print()},...A.importer&&x(A.importer.openFile)?[{name:y("menu.importCsv"),action:()=>A.importer.openFile()}]:[],{separator:!0},...E.length?[{name:y("menu.expandAll"),action:()=>A.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>A.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>A.selection.clear()},...x(A.get)&&A.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:O||1}),disabled:!O&&!R,action:()=>A.edit.deleteRows(O?void 0:R?R.key:void 0)}]:[],...S==null?[]:[{name:"Edit cell",disabled:!R||!S||!N,action:()=>R&&S&&A.edit.start(R.key,S)}]]}function s(A,k,y,S){if(A==null)return{items:k,spoke:!1,suppress:!1};if(A===!1)return{items:k,spoke:!0,suppress:!0};if(A===!0)return{items:k,spoke:!0,suppress:!1};if(Array.isArray(A))return{items:[...k,...A],spoke:!0,suppress:!1};if(x(A)){const R=A(y,k);return{items:Array.isArray(R)?R:k,spoke:!0,suppress:!1}}return B(`menu-layer:${S}`,`${S} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof A}. Ignoring it.`),{items:k,spoke:!1,suppress:!1}}function p(A,k,y){let S=Array.isArray(A)?A:[],R=!1;for(const O of k){if(!O)continue;const F=s(O.layer,S,y,O.where);S=F.items,F.spoke&&(R=F.suppress)}return R?null:S}class b{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(k){this.#n=k.grid,this.#e=k.cellMenu!==!1,this.#t=k.headerMenu!==!1,this.#i=x(k.items)?k.items:null,this.#s=x(k.headerItems)?k.headerItems:null,this.#r=new H({document:k.document,host:k.host,ctx:{grid:k.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",k=>{const y=String(k.colId),S=this.#c(y,h(this.#n,y));S.length&&this.#r.show({items:S,ctx:this.#u(y),anchor:k.element,placement:"below",returnFocus:k.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",k=>{const y=String(k.colId),S=this.#c(y,t(this.#n,y));S.length&&this.#r.show({items:S,ctx:this.#u(y),x:k.x,y:k.y,returnFocus:k.element})})),this.#o.push(this.#n.on("cell:contextmenu",k=>{const y=k.event;this.#e&&y&&x(y.preventDefault)&&y.preventDefault();const S=this.#l(k),R=f(this.#n,S),O=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(S.column),where:`column '${S.colId}' contextMenu`}],S);!O||!O.length||(!this.#e&&y&&x(y.preventDefault)&&y.preventDefault(),this.#r.show({items:O,ctx:S,x:y?y.clientX:void 0,y:y?y.clientY:void 0}))}))}#l(k){const y=this.#n.columns,S=k.column||(k.colId!=null&&y&&x(y.get)?y.get(k.colId):void 0),R=k.row,O=this.#n.rows,F=k.key!==void 0?k.key:R?R.key:void 0;return{key:F,colId:k.colId,value:k.value!==void 0||F===void 0||k.colId==null?k.value:O&&x(O.value)?O.value(F,k.colId):void 0,row:R,data:R?R.data:void 0,column:S,index:k.index!==void 0?k.index:k.rowIndex,grid:this.#n}}#a(k){if(!(!k||k.contextMenu===void 0||k.contextMenu===null))return k.contextMenu}#u(k){return{colId:k,column:this.#n.columns.get(k),grid:this.#n}}#c(k,y){return this.#s?p(y,[{layer:this.#s,where:"columnMenu"}],this.#u(k))||[]:y}destroy(){for(const k of this.#o)k();this.#o=[],this.#r.destroy()}}}),Le("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return j}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),X=_.groupedShortcuts,W=_.SHORTCUT_IDS,H=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class j{#e;#t;#n=null;#r=null;#o=[];constructor(u){this.#e=u.grid,this.#t=u.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(u,h){const a=this.#e;return(a&&a.messages?a.messages:I).t(u,h)}#s(u){const h=W[u.combo];if(!h)return u.meaning;const a=`shortcut.${h}`,r=this.#i(a);return r===a?u.meaning:r}mount(){const u=this.#t.viewport?.root;if(!u||!x(u.addEventListener))return;const h=a=>{if(this.open||a.key!=="?")return;const r=a.target,t=r&&r.tagName;t==="INPUT"||t==="TEXTAREA"||r&&r.isContentEditable||(a.preventDefault(),a.stopPropagation(),this.show())};u.addEventListener("keydown",h,!0),this.#o.push(()=>u.removeEventListener("keydown",h,!0))}show(){const u=this.#l();if(!u)return;const h=u.ownerDocument;this.#r=h&&h.activeElement,u.style.display="",x(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const u=this.#r;this.#r=null,u&&x(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const u=this.#t.viewport?.overlays,h=u?.ownerDocument;if(!u||!h?.createElement)return null;const a=h.createElement("div");a.className=z,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("tabindex","-1");const r=`${z}-title`;a.setAttribute("aria-labelledby",r);const t=h.createElement("div");t.className=`${z}__head`;const n=h.createElement("h2");n.className=`${z}__title`,n.id=r,n.textContent=this.#i("shortcuts.title");const o=h.createElement("button");o.className=`${z}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",t.appendChild(n),t.appendChild(o),a.appendChild(t);const d=h.createElement("div");d.className=`${z}__body`;for(const i of X())i.items.length&&d.appendChild(this.#a(h,i));a.appendChild(d);const l=h.createElement("p");return l.className=`${z}__hint`,l.textContent=this.#i("shortcuts.hint"),a.appendChild(l),u.appendChild(a),this.#n=a,this.#u(a,o),a}#a(u,h){const a=u.createElement("section");a.className=`${z}__group`;const r=u.createElement("h3");r.className=`${z}__group-title`,r.textContent=this.#i(h.messageKey),a.appendChild(r);const t=u.createElement("dl");t.className=`${z}__list`;const n=H();for(const o of h.items){const d=u.createElement("dt");d.className=`${z}__keys`,o.alternatives.forEach((i,m)=>{if(m>0){const c=u.createElement("span");c.className=`${z}__or`,c.textContent=this.#i("shortcuts.or"),d.appendChild(c)}i.forEach((c,f)=>{f>0&&d.appendChild(u.createTextNode("+"));const s=u.createElement("kbd");s.textContent=n&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,d.appendChild(s)})});const l=u.createElement("dd");l.className=`${z}__meaning`,l.textContent=this.#s(o),t.appendChild(d),t.appendChild(l)}return a.appendChild(t),a}#u(u,h){const a=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const n=[...u.querySelectorAll(w)];if(!n.length){t.preventDefault();return}const o=n[0],d=n[n.length-1],l=u.ownerDocument.activeElement;t.shiftKey&&(l===o||l===u)?(t.preventDefault(),d.focus()):!t.shiftKey&&l===d&&(t.preventDefault(),o.focus())},r=t=>{t.preventDefault?.(),this.hide()};u.addEventListener("keydown",a),h.addEventListener("click",r),this.#o.push(()=>{u.removeEventListener("keydown",a),h.removeEventListener("click",r)})}destroy(){for(const u of this.#o)u();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),Le("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return a}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/renderer.js").displayIndexOf,W="lat-rowdrag",V="lat-rowdrag-marker",H="lat-rowdrag-lifted",z="lat-manual-order",w=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),j=4,g=new Set;function u(r){if(!r)return null;const t=r===!0?{}:typeof r=="object"?r:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function h(r){return r===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!r||typeof r!="object"?null:{column:typeof r.column=="string"?r.column:null,manualOrder:r.manualOrder===!0,betweenGroups:r.betweenGroups===!0}}class a{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=h(t.grid.get("rowReorder")),this.#o=u(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const n=t&&t.transfer;return!n||!n.send?!1:n.group===this.#o.group}get transfer(){return this.#o}#u(t,n){const o=this.#e;return(o&&o.messages?o.messages:I).t(t,n)}#c(t,n){const o=this.#t&&this.#t.announce;x(o)&&o.call(this.#t,t,n)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(n=>!n.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),n=this.#t.viewport?.root;if(!t||!n)return;const o=n.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const d of o){if(d.querySelector(`.${W}`))continue;const l=d.parentNode;if(l&&x(l.getAttribute)&&l.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=W,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",d.insertBefore(i,d.firstChild||null)}this.#f(n,t)}#h(){const t=this.#e.rowOrder;return!!(t&&x(t.manual)&&t.manual())}#f(t,n){const o=this.#h();if(x(t.setAttribute)&&(o?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const d=t.querySelector(`.lat-header-cell[data-col="${n}"]`);if(!d)return;let l=d.querySelector(`.${z}`);l||(l=this.#n.createElement("button"),l.className=z,l.setAttribute("type","button"),l.setAttribute("data-role","manual-order"),l.setAttribute("tabindex","-1"),l.textContent=this.#u("rowOrder.button"),l.addEventListener("click",m=>{m.stopPropagation?.(),this.toggleManual()}),l.addEventListener("pointerdown",m=>m.stopPropagation?.()),d.insertBefore(l,d.firstChild||null)),l.setAttribute("aria-pressed",o?"true":"false");const i=this.#u(o?"rowOrder.exit":"rowOrder.enter");l.setAttribute("title",i),l.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const n=this.#h()?t.exit():t.enter({origin:"user"}),o=d=>{d&&d.reason&&this.#c(this.#u(w[d.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};n&&x(n.then)?n.then(o):o(n)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!x(t.addEventListener))return;const n=m=>this.#p(m),o=m=>this.#m(m),d=()=>this.#g(),l=m=>this.#E(m);if(t.addEventListener("pointerdown",n),t.addEventListener("keydown",l),x(this.#e.on)){let m=this.#h();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#h()!==m&&(m=this.#h(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",o),i.addEventListener?.("pointerup",d),this.#a.push(()=>{t.removeEventListener("pointerdown",n),t.removeEventListener("keydown",l),i.removeEventListener?.("pointermove",o),i.removeEventListener?.("pointerup",d)})}#p(t){const n=t.target;if(!n||!x(n.closest)||!n.closest('[data-role="row-drag"]'))return;const o=n.closest(".lat-row"),d=o?X(o):-1;if(d<0)return;const l=this.#e.rows.get(d);if(!l||l.group)return;const i=this.#N();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:l.key,from:d,at:d,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const n=this.#i;if(!n)return;if(!n.armed){if(Math.abs(t.clientX-n.x)+Math.abs(t.clientY-n.y)<j)return;n.armed=!0,this.#z(n),n.over=this,this.#e.emit("rowDrag:started",this.#b(n,this,n.from,n.key),"user")}this.#l&&this.#H(t.clientX,t.clientY);const o=this.#S(t.clientX,t.clientY);if(n.target=o,o!==this){this.#I(),o&&o.accepts(this)?(o.showDropTarget(t.clientX,t.clientY),n.hit=o.hitAt(t.clientX,t.clientY)):n.hit=null,this.#O(n,o),this.#y(n,o,n.hit?n.hit.at:null,n.hit?n.hit.overKey:null);return}const d=this.#$(t.clientX,t.clientY);if(this.#O(n,o),d<0){this.#y(n,this,null,null);return}n.at=d,this.#L(d);const l=this.#e.rows.get(d);this.#y(n,this,d,l?l.key:null)}#g(){const t=this.#i;this.#i=null,this.#I(),this.#B();for(const d of g)d.hideDropTarget();if(!t||(this.#A(t),!t.armed))return;const n=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),n&&n!==this){this.#C(t,n);return}if(t.at===t.from)return;const o=this.#N();if(o){this.#c(this.#u(o),{repeat:!0});return}this.#P(t.key,t.at)}#b(t,n,o,d){const l=this.#e.rows.byKey(t.key);return{key:t.key,data:l?l.data:null,over:n?n.grid:null,at:o,overKey:d}}#w(t){const n=t.target||null;if(n&&n!==this){if(!n.accepts(this))return{...this.#b(t,n,null,null),dropped:!1};const o=t.hit||{at:n.grid.rows.count(),overKey:null};return{...this.#b(t,n,o.at,o.overKey),dropped:!0}}if(n===this){const o=this.#e.rows.get(t.at);return{...this.#b(t,this,t.at,o?o.key:null),dropped:t.at!==t.from&&this.#N()===null}}return{...this.#b(t,null,null,null),dropped:!1}}#O(t,n){if(t.over===n)return;const o=t.over;t.over=n,o&&(this.#A(t),this.#e.emit("rowDrag:left",this.#b(t,o,null,null),"user"))}#y(t,n,o,d){t.pending={over:n,at:o,overKey:d},t.frame===null&&(t.frame=this.#k(()=>{t.frame=null;const l=t.pending;t.pending=null,!(!l||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#b(t,l.over,l.at,l.overKey),"user")}))}#A(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#k(t){const n=this.#n.defaultView||globalThis;if(x(n.requestAnimationFrame)){const d=n.requestAnimationFrame(t);return()=>{x(n.cancelAnimationFrame)&&n.cancelAnimationFrame(d)}}const o=setTimeout(t,16);return()=>clearTimeout(o)}#C(t,n){if(!n.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const o=this.#e.rows.byKey(t.key);if(!o)return;const d=this.#o.mode,l=t.key,i=t.hit||{at:n.grid.rows.count(),overKey:null};let m=null;const c=n.receive(o.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(l),onCancel:s=>{m=s}}),f=s=>{if(s!==!0){const p=s===!1?"a11y.transfer.refused":m==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(p),{repeat:!0});return}d==="move"?(this.#e.rows.apply({remove:[l]}),this.#e.emit("row:sent",{key:l,data:o.data,mode:d})):this.#e.emit("row:copied",{key:l,data:o.data,mode:d}),this.#c(this.#u(d==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&x(c.then)?c.then(f):f(c)}receive(t,n,o={}){const d=this.#e,l=t&&typeof t=="object"?{...t}:t,i=o.overKey??null,m=o.source||null,c=x(o.onCancel)?o.onCancel:null,f=()=>{const k=d.rows.totalCount(),y=d.rows.apply({add:[l],at:Math.max(0,n||0)}),S=d.rows.totalCount()>k;return S&&d.emit("row:received",{data:l,at:n,overKey:i,rejected:y?.rejected||[]}),S},s=()=>{if(i!==null){const k=d.rows.get(n);if(!k||k.key!==i)return!1}else n=d.rows.count();return!x(o.revalidate)||o.revalidate()},p=x(d.rendererHost)?d.rendererHost():null;if(!p||!x(p.gateBefore))return f();const b=c?d.on("rowReceive:cancelled",k=>c(k.reason)):null,A=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:l,at:n,overKey:i,source:m,origin:"user"},f,s);return b&&(A&&x(A.then)?A.then(b,b):b()),A}hitAt(t,n){const o=this.#$(t,n);if(o<0)return{at:this.#e.rows.count(),overKey:null};const d=this.#e.rows.get(o);return{at:o,overKey:d?d.key:null}}showDropTarget(t,n){const o=this.root;o&&x(o.setAttribute)&&o.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&x(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#S(t,n){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,d=o&&x(o.closest)?o.closest(".lattice"):null;if(!d)return null;for(const l of g)if(l.root===d)return l;return null}#E(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!n)return;const o=this.#n.activeElement,d=o&&x(o.closest)?o.closest(".lat-row"):null,l=d?X(d):-1;if(l<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#N();if(i){this.#c(this.#u(i),{repeat:!0});return}const m=this.#e.rows.get(l);!m||m.group||this.#P(m.key,this.#T(l,n))}#T(t,n){const o=this.#e;if(n>0||!x(o.rows.groupHeadings))return t+n;const d=new Set(o.rows.groupHeadings(t).map(i=>i.key));let l=t+n;for(;l>=0;){const i=o.rows.get(l);if(!i||!d.has(i.key))break;l+=n}return l<0?t:l}#P(t,n){const o=this.#e.rows.count(),d=Math.max(0,Math.min(o-1,n)),l=this.#e.rows.move(t,d,{origin:"user"});l&&x(l.then)?l.then(i=>this.#M(i,o)):this.#M(l,o)}#M(t,n){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const o=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,d=o?this.#u("a11y.reorder.vetoedBecause",{reason:o}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(d,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const o=t.regrouped.map(d=>String(d.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:o}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:n}),{repeat:!0})}#N(){const t=this.#e,n=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return n.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#h()&&!n.betweenGroups)return"a11y.reorder.grouped";const o=t.filters.get();return o&&Object.keys(o).length?"a11y.reorder.filtered":null}#$(t,n){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,d=o&&x(o.closest)?o.closest(".lat-row"):null;return!d||x(d.getAttribute)&&d.getAttribute("data-pinned")?-1:X(d)}#z(t){const n=this.root,o=n&&x(n.querySelector)?n.querySelector(`.lat-row[data-index="${t.from}"]`):null;o&&x(o.classList?.add)&&o.classList.add(H);const d=this.#n.body;if(!d||!x(d.appendChild))return;const l=this.#d(),i=l&&x(this.#e.rows?.text)&&this.#e.rows.text(t.key,l)||this.#u("a11y.reorder.grab"),m=n&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(n):null,c=(s,p)=>m&&m.getPropertyValue(s).trim()||p,f=this.#n.createElement("div");f.textContent=String(i),f.setAttribute("aria-hidden","true"),f.setAttribute("data-role","row-drag-ghost"),f.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${c("--lattice-space","4px")} calc(${c("--lattice-space","4px")} * 2)`,`border-radius:${c("--lattice-radius-sm",c("--lattice-radius","4px"))}`,`border:${c("--lattice-border-width","1px")} solid ${c("--lattice-border-strong","#0003")}`,`background:${c("--lattice-background","#fff")}`,`color:${c("--lattice-foreground","#000")}`,`box-shadow:${c("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${c("--lattice-font-size","13px")} ${c("--lattice-font-family","system-ui, sans-serif")}`].join(";"),d.appendChild(f),this.#l=f}#H(t,n){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(n)+16}px)`)}#B(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,n=t&&x(t.querySelectorAll)?t.querySelectorAll(`.${H}`):[];for(const o of n)o.classList.remove(H)}#L(t){const n=this.#t.viewport?.overlays;if(!n)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=V,n.appendChild(this.#s));const o=this.#t.viewport.root,d=o.querySelector(`.lat-row[data-index="${t}"]`)||o.querySelectorAll(".lat-row")[0];if(!d||!x(d.getBoundingClientRect))return;const l=d.getBoundingClientRect(),i=o.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?l.bottom:l.top)-i.top)}px`}#I(){this.#s&&(this.#s.style.display="none")}destroy(){g.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#A(this.#i),this.#i=null,this.#B(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Le("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function I(W){return(W||[]).map(V=>({id:V.id,width:V.width,flex:V.flex,hidden:V.hidden,pin:V.pin===void 0?null:V.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(V){if(!V||this.#e.has(V))return;this.#e.add(V);const H=[];for(const w of B)H.push(V.on(w,()=>this.#r(V)));H.push(V.on("scroll",w=>this.#i(V,w))),H.push(V.on("destroy",()=>this.remove(V))),this.#t.set(V,H);const[z]=this.#e;z!==V&&this.#o(V,I(z.columns.state()))}remove(V){const H=this.#t.get(V);if(H)for(const z of H)z();this.#t.delete(V),this.#e.delete(V)}get size(){return this.#e.size}destroy(){for(const V of[...this.#e])this.remove(V)}#r(V){if(this.#n)return;const H=I(V.columns.state());this.#n=!0;try{for(const z of this.#e)z!==V&&this.#o(z,H)}finally{this.#n=!1}}#o(V,H){if(!V.columns||!x(V.columns.apply))return;const z=new Map((V.columns.state()||[]).map(j=>[j.id,j])),w=[];for(const j of H){const g=z.get(j.id);g&&(w.push({...g,...j}),z.delete(j.id))}for(const j of z.values())w.push(j);V.columns.apply(w)}#i(V,H){if(this.#n)return;const z=H&&typeof H.left=="number"?H.left:null;if(z!==null){this.#n=!0;try{for(const w of this.#e)w!==V&&w.scroll?.to?.({left:z})}finally{this.#n=!1}}}}function X(W){const V=new _;for(const H of W||[])V.add(H);return V}}),Le("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return W}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(H){if(!H)return null;const z=H===!0?{}:typeof H=="object"?H:null;return z?{multiple:z.multiple===!0,label:typeof z.label=="string"?z.label:null}:null}class W{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(z){this.#e=z.grid,this.#t=z.renderer,this.#n=z.document,this.#r=X(z.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(z,w){const j=this.#e;return(j&&j.messages?j.messages:I).t(z,w)}mount(){if(!this.active)return;const z=this.#t.viewport,w=z?.root;if(!w||!x(w.insertBefore))return;const j=this.#n.createElement("div");j.className=_,j.setAttribute("role","toolbar"),j.setAttribute("aria-label",this.#a("tags.label"));const g=this.#n.createElement("label");g.className=`${_}__label`,g.textContent=this.#r.label||this.#a("tags.label");const u=this.#n.createElement("select");u.className=`${_}__select`,this.#r.multiple&&u.setAttribute("multiple","");const h=`${_}-select-${Math.abs(V(String(w.className)))}`;u.id=h,g.setAttribute("for",h),j.appendChild(g),j.appendChild(u),w.insertBefore(j,z.header||w.firstChild),this.#o=j,this.#i=u;const a=()=>{const t=this.#r.multiple?[...u.selectedOptions||[]].map(n=>n.value).filter(Boolean):u.value?[u.value]:[];this.#e.columns.showTagged(t),this.#u(t)};u.addEventListener("change",a),this.#l.push(()=>u.removeEventListener("change",a));const r=this.#e.on("model:changed",()=>this.refresh());this.#l.push(r),this.refresh()}#u(z){const w=this.#t&&this.#t.announce;if(!x(w))return;const j=z.length?z.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:j}))}refresh(){if(!this.#i||!this.#o)return;const z=this.#e.columns.tags();if(this.#o.style.display=z.length?"":"none",!z.length)return;const w=z.join("\0");if(w===this.#s)return;this.#s=w;const j=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const g=this.#n.createElement("option");g.value="",g.textContent=this.#a("tags.all"),this.#i.appendChild(g)}for(const g of z){const u=this.#n.createElement("option");u.value=g,u.textContent=g,j.includes(g)&&(u.selected=!0),this.#i.appendChild(u)}this.#r.multiple||(this.#i.value=j.length?j[0]:"")}destroy(){for(const z of this.#l)z();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function V(H){let z=0;for(let w=0;w<H.length;w++)z=z*31+H.charCodeAt(w)|0;return z}}),Le("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-anomaly-chip";function X(z){if(!z)return null;const w=z===!0?{}:typeof z=="object"?z:null;return w?{column:typeof w.column=="string"?w.column:null,label:typeof w.label=="string"?w.label:null}:null}function W(z){return z?typeof z=="string"?{kind:z}:typeof z=="object"?z:null:null}function V(z,w){return z?Array.isArray(z.conditions)?z.conditions.some(j=>V(j,w)):z.col===w&&z.op==="eq"&&z.value===!0:!1}class H{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(w){this.#e=w.grid,this.#t=w.renderer,this.#n=w.document,this.#r=X(w.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(w,j){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,j)}#f(){const w=this.#r&&this.#r.column;let j=null;for(const g of this.#e.columns.all()){const u=W(g.shadow);if(!u||u.kind!=="anomalyFlag")continue;const h=u.of||g.field||g.id;if(w){if(g.id===w||h===w)return this.#d=g.id,g}else j||(j=g,this.#d=g.id)}return w?null:j}#p(){if(!this.#d||!x(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(j=>{!j||j.group||j.key==null||this.#e.rows.value(j.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,j=w&&w.root;if(!j||!x(j.insertBefore))return;const g=this.#n.createElement("div");g.className=_,g.setAttribute("role","status");const u=this.#n.createElement("button");u.className=`${_}__button`,u.setAttribute("type","button"),u.setAttribute("aria-pressed","false"),g.appendChild(u),j.insertBefore(g,w.header||j.firstChild),this.#o=g,this.#i=u;const h=()=>this.toggle();u.addEventListener("click",h),this.#s.push(()=>u.removeEventListener("click",h));for(const a of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(a,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const w={col:this.#d,op:"eq",value:!0},j=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(j)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!V(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#b(this.#c,!0);return}const j=this.#p();if(this.#c=j,!j){this.#o.style.display="none";return}this.#b(j,!1)}#b(w,j){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",j?"true":"false"),this.#i.setAttribute("aria-pressed",j?"true":"false");const g=this.#r&&this.#r.label,u=j?this.#h("anomaly.chipActive",{count:w}):g||this.#h("anomaly.chip",{count:w});this.#i.textContent=u}destroy(){for(const w of this.#s)w();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Le("packages/dom/src/rowform.js",function(e,K){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,H=K("packages/dom/src/editors/index.js").createEditor,w=K("packages/dom/src/renderer/renderer.js").displayIndexOf,g=K("packages/dom/src/themeof.js").themeOf,u="lat-rowform",h='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function a(d){if(!d)return null;const l=d===!0?{}:typeof d=="object"?d:null;if(!l)return null;const i=x(l.load)?l.load:null,m=Array.isArray(l.fields)&&l.fields.length?l.fields:null;return{timeout:n(l.timeout),container:l.container??null,mode:l.container?"inline":l.mode==="dialog"?"dialog":"drawer",load:i,create:x(l.create)?l.create:null,fields:m,title:l.title??null,width:typeof l.width=="string"?l.width:null,trigger:l.trigger===!1?"none":"dblclick"}}function r(d,l){const i=x(d)?d():d;return i?typeof i=="string"?l&&x(l.querySelector)?l.querySelector(i):null:i&&x(i.appendChild)?i:null:null}const t=2e3;function n(d){return d===!1||d===0?0:typeof d!="number"||!Number.isFinite(d)||d<=0?t:d}class o{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#h=null;#f=0;#p=null;#m=!1;#g=[];constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document,this.#r=l.registry||null,this.#o=a(l.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#b(l,i){const m=this.#e;return(m&&m.messages?m.messages:_).t(l,i)}mount(){if(!this.active)return;const l=this.#t.viewport?.root;if(!l||!x(l.addEventListener)||this.#o.trigger==="none")return;const i=m=>{const c=m.target;if(!c||!x(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const f=c.closest(".lat-row"),s=f?w(f):-1;if(s<0)return;const p=this.#e.rows.get(s);!p||p.group||p.detail||(m.preventDefault?.(),m.stopPropagation?.(),this.openRow(p.key))};l.addEventListener("dblclick",i,!0),this.#g.push(()=>l.removeEventListener("dblclick",i,!0))}openRow(l){const i=this.#e.rows.byKey(l);if(!i)return!1;const m=this.#C();if(!m)return!1;this.#a=i,this.#u=!1,this.#k(),this.#h=this.#n.activeElement,m.style.display="",this.#L(m),this.#E(i);const c=this.#o.load;if(!c)this.#H(i.data);else{this.#N();const f=++this.#f;this.#T(f,s=>{this.#$(new Error(`Loading the record timed out after ${s}ms`),l,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:i,data:i.data,key:l,grid:this.#e})).then(s=>{f!==this.#f||!this.open||(this.#M(),this.#H(s||i.data))}).catch(s=>{f!==this.#f||!this.open||(this.#M(),this.#$(s,l))})}return x(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:l,row:i}),!0}openNew(l){const i=this.#C();if(!i)return!1;this.#f+=1,this.#M(),this.#a=null,this.#u=!0,this.#k(),this.open||(this.#h=this.#n.activeElement),i.style.display="",this.#L(i);const m=i.querySelector(`.${u}__title`);return m&&(m.textContent=this.#b("form.newTitle")),this.#H(l&&typeof l=="object"?{...l}:{}),x(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#f+=1,this.#M(),this.#ge(),this.#i.style.display="none";const l=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#k();const i=this.#h;this.#h=null,i&&x(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:l})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const l=this.#a?this.#a.key:null,i={},m={},c=[],f=[];for(const s of this.#d){const p=x(s.editor.commit)?s.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#_(s,p.message),!1;if(i[s.field]=p.value,s.readOnly){f.push(s.field);continue}const b=s.initial;Object.is(b,p.value)||(m[s.field]=p.value,s.colId?c.push({key:l,colId:s.colId,value:p.value}):f.push(s.field))}return this.#u?this.#w(i):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:l,values:i,changed:m,unmapped:f}),this.close(),!0)}#w(l){const i=this.#d.filter(f=>!f.colId).map(f=>f.field),m=this.#o.create;if(!m)return this.#O(l)?(this.#y(l,l,i),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#k(),this.#P(!1);const c=++this.#f;return this.#T(c,f=>{this.#A(new Error(`Adding the record timed out after ${f}ms`),l,!0)}),Promise.resolve().then(()=>m(l)).then(f=>{if(!(c!==this.#f||!this.open)){if(this.#M(),!this.#O(f)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#A(new Error("rowForm.create answered with a row that carries no row key"),l,!1);return}this.#y(f,l,i)}}).catch(f=>{c!==this.#f||!this.open||(this.#M(),this.#A(f,l,!1))}),!0}#O(l){if(!l||typeof l!="object")return!1;const i=W(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:x(i.keyEmpty)?!i.keyEmpty(l):!0}#y(l,i,m){const c=this.#e,f=c.rows.apply({add:[l]}),s=f&&Array.isArray(f.added)?f.added[0]:null;if(!s){this.#A(new Error("The new row could not be added"),i,!1);return}const p=s.key;c.emit("form:saved",{key:p,values:i,changed:i,unmapped:m,created:!0}),this.close();const b=c.get("selection");(typeof b=="string"?b!=="none":b&&typeof b=="object"&&b.mode!=="none")&&c.selection&&x(c.selection.set)&&c.selection.set([p]),c.scroll&&x(c.scroll.toRow)&&c.scroll.toRow(p)}#A(l,i,m){this.#P(!0),this.#k();const c=this.#n.createElement("div");c.className=`${u}__failure`;const f=this.#n.createElement("p");f.className=`${u}__note ${u}__note--error`,f.setAttribute("role","alert"),f.textContent=this.#b("form.createFailed");const s=this.#n.createElement("button");s.className=`${u}__retry`,s.type="button",s.textContent=this.#b("form.retry"),s.addEventListener("click",()=>this.save()),c.appendChild(f),c.appendChild(s),x(this.#s.insertBefore)?this.#s.insertBefore(c,this.#s.firstChild):this.#s.appendChild(c),this.#c=c,this.#e.emit("form:error",{key:null,error:l,timedOut:m,created:!0})}#k(){const l=this.#c;this.#c=null,l&&l.parentNode&&l.parentNode.removeChild(l)}#C(){if(this.#i)return this.#i;const l=this.#t.viewport?.overlays,i=this.#n||l?.ownerDocument;if(!i?.createElement)return null;const m=r(this.#o.container,i),c=m||l;if(!c)return null;this.#o.container&&!m&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!m;const f=i.createElement("div"),s=this.#m?"lattice ":"";f.className=`${s}${u} ${u}--${this.#m?"inline":this.#o.mode}`,f.setAttribute("role",this.#m?"region":"dialog"),this.#m||f.setAttribute("aria-modal","true"),f.setAttribute("tabindex","-1"),this.#o.width&&f.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${u}-title`;f.setAttribute("aria-labelledby",p);const b=i.createElement("div");b.className=`${u}__head`;const A=i.createElement("h2");A.className=`${u}__title`,A.id=p,b.appendChild(A);const k=i.createElement("div");k.className=`${u}__body`;const y=i.createElement("div");y.className=`${u}__foot`;const S=i.createElement("button");S.className=`${u}__cancel`,S.type="button",S.textContent=this.#b("form.cancel");const R=i.createElement("button");return R.className=`${u}__save`,R.type="button",R.textContent=this.#b("form.save"),y.appendChild(S),y.appendChild(R),f.appendChild(b),f.appendChild(k),f.appendChild(y),c.appendChild(f),this.#i=f,this.#s=k,this.#l=R,this.#S(f,R,S),f}#S(l,i,m){const c=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const b=[...l.querySelectorAll(h)];if(!b.length){p.preventDefault();return}const A=b[0],k=b[b.length-1],y=l.ownerDocument.activeElement;p.shiftKey&&(y===A||y===l)?(p.preventDefault(),k.focus()):!p.shiftKey&&y===k&&(p.preventDefault(),A.focus())},f=p=>{p.preventDefault?.(),this.save()},s=p=>{p.preventDefault?.(),this.close()};l.addEventListener("keydown",c),i.addEventListener("click",f),m.addEventListener("click",s),this.#g.push(()=>{l.removeEventListener("keydown",c),i.removeEventListener("click",f),m.removeEventListener("click",s)})}#E(l){const i=this.#i.querySelector(`.${u}__title`);if(!i)return;const m=this.#o.title;x(m)?i.textContent=String(m({row:l,data:l.data})??""):typeof m=="string"?i.textContent=m:i.textContent=this.#b("form.title")}#T(l,i){this.#M();const m=this.#o.timeout;if(!m)return;const c=this.#n.defaultView||globalThis;x(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(l!==this.#f||!this.open)&&(this.#f+=1,i(m))},m))}#P(l){this.#l&&(this.#l.disabled=!l,l?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#M(){if(this.#p===null)return;const l=this.#n.defaultView||globalThis;x(l.clearTimeout)&&l.clearTimeout(this.#p),this.#p=null}#N(){this.#ge(),this.#P(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const l=this.#n.createElement("p");l.className=`${u}__note`,l.setAttribute("role","status"),l.textContent=this.#b("form.loading"),this.#s.appendChild(l)}#$(l,i,m="form.loadFailed"){this.#ge(),this.#P(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${u}__note ${u}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#b(m);const f=this.#n.createElement("button");f.className=`${u}__retry`,f.type="button",f.textContent=this.#b("form.retry"),f.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(c),this.#s.appendChild(f),this.#e.emit("form:error",{key:i,error:l,timedOut:m==="form.loadTimeout"})}#z(){return this.#o.fields?this.#o.fields.map(l=>typeof l=="string"?{field:l}:l):this.#e.columns.all().filter(l=>!l.generated&&l.field).map(l=>({field:l.field,label:l.title,colId:l.id}))}#H(l){this.#ge(),this.#P(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=l&&typeof l=="object"?l:{};for(const m of this.#z()){const c=m.field;if(!c)continue;const f=m.colId?this.#e.columns.get(m.colId):this.#ae(c),s=Object.hasOwn(i,c)?i[c]:null,p=this.#n.createElement("div");p.className=`${u}__field`;const b=this.#n.createElement("label");b.className=`${u}__label`,b.textContent=String(m.label??(f&&f.title)??c);const A=this.#n.createElement("div");A.className=`${u}__control`,p.appendChild(b),p.appendChild(A),this.#s.appendChild(p);const k={field:c,colId:f?f.id:null,editor:null,initial:s,opener:null,wrap:p,readOnly:!1},S=!!(f&&(f.computed||f.generated))?null:H({grid:this.#e,column:this.#se(m,f,c),colId:f?f.id:c,row:this.#a,data:i,value:s,text:s==null?"":String(s),locale:this.#e.get("locale"),props:m.props||f&&f.edit&&f.edit.props,lookup:m.lookup||f&&f.lookup,document:this.#n,cell:A,overlay:this.#I(),stop:()=>this.#X(k)},this.#r);if(!S){k.readOnly=!0,k.colId=null,k.editor={commit:()=>({ok:!0,value:k.initial})},this.#B(A,f,s),this.#d.push(k);continue}k.editor=S;try{x(S.value)&&(k.initial=S.value())}catch{}if(this.#d.push(k),S.popup===!0)this.#D(A,k);else{const R=x(S.element)?S.element():null;R&&A.appendChild(R)}}this.#d.length||B("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#B(l,i,m){const c=this.#n.createElement("div");c.className=`${u}__static`,c.setAttribute("aria-readonly","true");let f="";try{const s=i&&i.dataType&&i.dataType.format;x(s)&&(f=s({value:m,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{f=""}(f===""||f==null)&&(f=m==null?"":String(m)),c.textContent=f,l.appendChild(c)}#L(l){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!x(i.getAttribute)))for(const m of["data-theme","data-density","dir"]){const c=m==="data-theme"?g(i):i.getAttribute(m);c?l.setAttribute(m,c):x(l.removeAttribute)&&l.removeAttribute(m)}}#I(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#D(l,i){const m=this.#n.createElement("button");m.className=`${u}__opener`,m.type="button",i.opener=m,this.#ue(i);const c=()=>{x(i.editor.attached)&&i.editor.attached()};m.addEventListener("click",c),this.#g.push(()=>m.removeEventListener("click",c)),l.appendChild(m)}#_(l,i){const m=l.wrap;m&&x(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const c=l.opener||(x(l.editor.focusTarget)?l.editor.focusTarget():null);c&&x(c.focus)&&c.focus();const f=this.#t&&this.#t.announce;x(f)&&i&&f.call(this.#t,String(i))}#X(l){if(!l.opener||!l.editor)return;const i=x(l.editor.popupHandle)?l.editor.popupHandle():null;i&&x(i.hide)&&i.hide(),this.#ue(l),x(l.opener.focus)&&l.opener.focus()}#ue(l){if(!l.opener)return;let i="";try{const c=l.colId?this.#e.columns.get(l.colId):null,f=c&&c.dataType&&c.dataType.format;x(f)&&(i=f({value:x(l.editor.value)?l.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&x(l.editor.toClipboard)&&(i=l.editor.toClipboard())}catch{i=""}const m=i===""||i==null;l.opener.textContent=m?this.#b("form.choose"):String(i),l.opener.classList.toggle(`${u}__opener--empty`,m)}#se(l,i,m){const c=l.editor||l.type||l.lookup||l.props,f={...i&&i.edit?i.edit:{},enabled:!0};return l.editor&&(f.editor=l.editor),l.props&&(f.props=l.props),i&&!c?{...i,edit:f}:{...i||{id:m,field:m},type:l.type||i&&i.type||"text",lookup:l.lookup||i&&i.lookup||void 0,edit:f}}#ae(l){for(const i of this.#e.columns.all())if(!i.generated&&i.field===l)return i;return null}#ge(){for(const l of this.#d)x(l.editor.destroy)&&l.editor.destroy();this.#d=[]}destroy(){this.#f+=1,this.#M(),this.#ge();for(const l of this.#g)l();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Le("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=K("packages/dom/src/ui/toolpanel.js"),_=I.ToolPanel,X=I.toolPanels,W=I.toolPanelTitles,V=I.toolPanelIcons,H=K("packages/dom/src/filters/index.js"),z=H.createFilter,w=H.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,u=K("packages/dom/src/filters/engineset.js"),h=u.EngineSetFilter,a=u.VALUE_LIMIT,r=K("packages/dom/src/editors/common.js"),t=r.CLS,n=r.documentFor,o=r.scannableRows,d=r.el,l=K("packages/dom/src/filtermenu.js"),i=l.mergeColumnFilter,m=l.branchFor,c=l.valueSource,f=l.isSetFilter,s=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function p(L,C,D){const $=d(L,"div",{class:`${t.panel}__filterRefusal`});return $.appendChild(d(L,"div",{class:`${t.filter}__note`,text:D,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),$.appendChild(C.element()),{get:()=>C.get(),set:P=>C.set(P),active:()=>C.active(),...x(C.clear)?{clear:()=>C.clear()}:{},destroy:()=>C.destroy(),element:()=>$}}function b(L){const{grid:C,container:D}=L||{};if(!C)throw new Error("[lattice] mountPanel needs a grid");if(!D||!D.appendChild)throw new Error("[lattice] mountPanel needs a container element");const $=x(L.panel)?L.panel:X[String(L.panel)];if(!$)throw new Error(`[lattice] unknown panel "${L.panel}"; known panels are ${Object.keys(X).join(", ")}`);const P=D.ownerDocument||n(D),v=E(C,P,L.announce),N=new $;N.init({document:P,host:v,grid:C,props:L.props||{}});const G=N.element();D.appendChild(G);const q=[];for(const Z of s)x(C.on)&&q.push(C.on(Z,()=>N.refresh()));return x(C.on)&&q.push(C.on("config:changed",Z=>{Z&&(Z.key==="regression"||Array.isArray(Z.keys)&&Z.keys.includes("regression"))&&N.refresh()})),{element:G,refresh(){N.refresh()},destroy(){for(const Z of q)Z();q.length=0,x(N.destroy)&&N.destroy(),G&&G.parentNode&&G.parentNode.removeChild(G)}}}const A=260,k=30,y=`${t.panel}-dock`;function S(L,C,D){if(!L||!x(L.set))return;const $=m(D.filters.get(),C)||null,P=x(L.get)&&(!x(L.active)||L.active())&&L.get()||null;JSON.stringify(P)!==JSON.stringify($)&&($?L.set($):x(L.clear)?L.clear():L.set(null))}function R(L,C){if(L==="insights"){const P=C&&x(C.get)?C.get("insights"):null;return{other:(P&&typeof P=="object"?P:{}).compareWith||null}}if(L!=="views")return{};const D=C&&x(C.get)?C.get("views"):null,$=D&&typeof D=="object"?D:{};return{allowSave:$.allowSave!==!1,showDiff:$.showDiff===!0,builtinTitle:$.builtinTitle,savedTitle:$.savedTitle}}function O(L,C){const D=L!==null&&typeof L=="object",$=D?L.name:L,P=x($),v=P?$.name||"panel":String($),N=P?$:X[v];if(!N)return B(`toolpanel:${v}`,`unknown tool panel "${v}"`),null;const G=D&&L.props||{};return{name:v,title:D&&L.title||(W[v]?C.messages.t(W[v]):v),icon:D&&L.icon||V[v]||v,Ctor:N,props:{...P?{}:R(v,C),...G}}}function F(L){const C=L.pagination&&x(L.pagination.get)?L.pagination.get():null;return C&&Number.isFinite(C.total)?C.total:L.rows.count()}function E(L,C,D){const $=new Map;return{announce(P,v){x(D)&&D(P,v)},t(P,v){return L.messages.t(P,v)},grid:L,document:C,columns:()=>L.columns.all(),columnGroups:()=>L.state.get().columnGroups||[],groupColumns:(P,v)=>L.columns.groupColumns(P,v),ungroupColumn:P=>L.columns.ungroupColumn(P),renameGroup:(P,v)=>L.columns.renameGroup(P,v),dissolveGroup:P=>L.columns.dissolveGroup(P),showColumns:P=>L.columns.show(P),hideColumns:P=>L.columns.hide(P),groupBy:()=>L.state.get().group||[],setGroupBy:P=>L.columns.group(P),pivotBy:()=>(L.state.get().pivot||{}).columns||[],setPivotBy:P=>L.columns.pivot(P),valueColumns:()=>L.columns.all().filter(P=>P.total).map(P=>P.id),setValueColumns:P=>L.columns.totals(P),valueAggregation(P){const v=L.columns.get(P);return!v||!v.total?"sum":typeof v.total=="string"?v.total:"custom"},setValueAggregation(P,v){L.columns.setTotal(P,v)},quickFilter:()=>L.state.get().quick||"",setQuickFilter:P=>L.filters.quick(P),rowCount:()=>F(L),totalRowCount:()=>x(L.rows.totalCount)?L.rows.totalCount():L.rows.count(),formattableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),formattingRules:P=>L.formatting.list(P),columnSamples:P=>{let v=P;if(!v||v==="*"){const q=L.columns.visible().find(Z=>!Z.generated);v=q?q.id:null}if(!v)return[];const N=[],G=new Set;for(const q of o(L)){const Z=L.rows.value(q.key,v);if(Z==null||Z==="")continue;const J=typeof Z=="object"?N.length:Z;if(!G.has(J)&&(G.add(J),N.push(Z),N.length>=24))break}return N},profilableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),columnProfile:P=>{const v=L.config().source;return((L.state.get().pivot||{}).columns||[]).length&&v&&typeof v=="object"&&x(v.aggregate)?null:L.statistics.profile(P)},columnProfileAsync:P=>L.statistics.profileAsync(P),reduceColumn:(P,v)=>L.statistics.reduce(P,v),columnCapability:P=>L.statistics.capability(P),regressionModel:P=>x(L.statistics.regressionModel)?L.statistics.regressionModel(P):null,insightsColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id),type:P.type})),subsetVsPopulation:()=>L.statistics.subsetVsPopulation(),datasetVsDataset:P=>L.statistics.datasetVsDataset(P),compareGroups:(P,v)=>L.statistics.compareGroups(P,v),anomalies:P=>L.statistics.anomalies(P||{}),compareColumns:(P,v)=>{if(!P||!v||P===v)return null;const N=L.statistics.regression(P,v);return{n:N?N.n:0,pearson:L.statistics.correlation(P,v),spearman:L.statistics.spearman(P,v),kendall:L.statistics.kendall(P,v),covariance:L.statistics.covariance(P,v),slope:N?N.slope:null,intercept:N?N.intercept:null,r2:N?N.r2:null,stdError:N?N.stdError:null,weighted:L.statistics.weightedAverage(P,v)}},addRule:(P,v)=>L.formatting.add(P,v),removeRule:(P,v)=>L.formatting.remove(P,v),updateRule:(P,v,N)=>L.formatting.update(P,v,N),moveRule:(P,v,N)=>L.formatting.move(P,v,N),clearRules:P=>L.formatting.clear(P),views:()=>L.views.list(),activeId:()=>L.views.activeId,apply:P=>{L.views.apply(P)},saveAs:P=>L.views.save(P),rename:(P,v)=>L.views.rename(P,v),setDefault:P=>L.views.setDefault(P),clearDefault:()=>L.views.setDefault(null),remove:P=>L.views.remove(P),export:P=>L.views.export(P),diff:P=>L.views.diff(P),moveColumn(P,v,N){const G=L.columns.all().map(ee=>ee.id),q=G.indexOf(P),Z=G.indexOf(v);if(q<0||Z<0)return;let J=N?Z:Z+1;q<J&&(J-=1),J!==q&&L.columns.move(P,J)},isFiltered(P){return m(L.filters.get(),P)!==null},clearFilter(P){L.filters.set(i(L.filters.get(),P,null));const v=$.get(P);v&&x(v.clear)?v.clear():v&&x(v.set)&&v.set(null)},clearAllFilters(){L.filters.set(null);for(const P of $.values())x(P.clear)?P.clear():x(P.set)&&P.set(null)},filterFor(P){if($.has(P))return S($.get(P),P,L),$.get(P);const v=L.columns.get(P);if(!v)return null;const N=v.filter&&v.filter.props&&v.filter.props.values,G=c(L),q=G?L.config().context??null:null,Z=G?ie=>G.columnValues(P,{...ie||{},context:q}):null,J={grid:L,column:v,colId:P,type:v.type,locale:L.get("locale"),props:{...v.filter&&v.filter.props,values:N||(v.lookup?void 0:G?()=>Z({limit:a}).then(ie=>ie&&ie.supported?ie.values.map(se=>se.value):[]):()=>L.columns.distinct(P)),...G?{valueList:!1}:{}},lookup:v.lookup,document:C,value:ie=>L.rows.value(ie.row&&ie.row.key,P),rows:G?()=>[]:v.lookup?void 0:()=>o(L),changed:()=>{const se=(x(ee.active)?ee.active():!0)&&x(ee.get)?ee.get():null;L.filters.set(i(L.filters.get(),P,se||null))},fetchValues:Z};let ee=null;const ne=G&&!N&&!v.lookup?w(v):null;if(ne&&f(ne)){const ie=G.columnValuesRefusal(P);if(ie){const se=new g;se.init({...J,props:{...J.props,valueList:!1}}),ee=p(C,se,L.messages.t("filter.valuesUnsupported",{column:v.title||P})),B(`filter:values-unsupported:${P}`,`the filter on column "${P}" cannot list its values: ${ie}. It offers the text condition editor instead.`)}else ee=new h,ee.init(J)}else ee=z(J);return ee&&(S(ee,P,L),$.set(P,ee)),ee},destroyFilters(){for(const P of $.values())x(P.destroy)&&P.destroy();$.clear()}}}class T{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(C){this.#e=C.grid,this.#t=C.document,this.#n=C.root,this.#o=E(C.grid,C.document,C.announce);const $=(C.panels||["columns","filters"]).map(P=>O(P,C.grid)).filter(Boolean);this.#l=C.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:C.document,host:this.#o,grid:C.grid,panels:$,actions:C.actions,icons:C.icons,side:this.#l,openPanel:C.openPanel})}mount(){const C=this.#t.createElement("div");C.className=`${y} ${y}--${this.#l}`,C.appendChild(this.#r.element()),this.#n.appendChild(C),this.#i=C;const D=this.#r.show.bind(this.#r),$=this.#r.hide.bind(this.#r);this.#r.show=P=>{const v=D(P);return this.#f(),v},this.#r.hide=()=>{$(),this.#f()};for(const P of[...s,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(P,()=>this.#r.refresh()));this.#s.push(this.#e.on("config:changed",P=>{P&&(P.key==="regression"||Array.isArray(P.keys)&&P.keys.includes("regression"))&&this.#r.refresh()})),this.#s.push(this.#e.on("presentation:started",P=>{this.#u=!0;const v=P&&P.options&&Array.isArray(P.options.chrome)?P.options.chrome:[];this.#c=v.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",P=>{const v=P&&P.colId,N=this.#r.panels.find(G=>G.name==="statistics");N&&v!=null&&(N.panel.column=String(v)),this.open("statistics")})),this.#f()}open(C){this.#r.show(C),this.#f()}close(){this.#r.hide(),this.#f()}toggle(C){this.#r.toggle(C),this.#f()}addAction(C){if(!(!C||!C.name)&&!this.#r.actions.some(D=>D.name===C.name)){if(this.#r.registerAction(C),this.#a&&!C.annotation){const D=this.#r.actions.find($=>$.name===C.name);D&&this.#h(D.button)}else!this.#a&&C.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(C){this.#r.removeAction(C)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(C=>C.annotation&&C.button)?(this.#d(),!0):!1}#d(){const C=this.#r;this.#a={hidden:[],reopen:C.openPanel||null},this.#a.reopen&&C.hide(),this.#h(C.body);for(const D of[...C.tabs?.children||[]])D!==C.actionGroup&&this.#h(D);for(const D of[...C.actionGroup?.children||[]]){const $=C.actions.find(P=>P.button===D);(!$||!$.annotation)&&this.#h(D)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const C=this.#a;if(!C)return!1;this.#a=null;for(const D of C.hidden)D.el&&D.el.style&&(D.el.style.display=D.display);return C.reopen&&this.#r.show(C.reopen),this.#f(),!0}#h(C){if(!C||!C.style||!this.#a)return;const D=C.style.display||"";D!=="none"&&(C.style.display="none",this.#a.hidden.push({el:C,display:D}))}#f(){if(!this.#i)return;const C=!!this.#r.openPanel;this.#i.setAttribute("data-open",C?"true":"false"),this.#i.style.width=C?`${A}px`:"";const D=`${C?A:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?D:"",this.#n.style.paddingRight=this.#l==="left"?"":D,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?D:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":D)}#p(){const C=this.#r&&x(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,D=C&&(C.offsetWidth||C.getBoundingClientRect?.().width)||0;return D>0?Math.ceil(D):k}destroy(){for(const C of this.#s)C();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Le("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,X=K("packages/dom/src/editors/common.js"),W=X.CLS,V=X.markInvalid,H=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,j=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;#h=null;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",m=>{const c=m.key||m.row&&m.row.key;this.#h=c&&m.colId?{key:c,colId:m.colId}:null,this.open(m)})),this.#u.push(this.#e.on("cell:edit:end",()=>{this.#h=null,this.close(!0)}));const t=this.#n.viewport.root,n=this.#e.get("edit"),o=n&&typeof n=="object"&&n.start||"double",d=m=>{if(w(m.target,t))return;const c=u(m.target,A=>A.getAttribute&&A.getAttribute("data-col"));if(!c)return;const f=u(c,A=>A.getAttribute&&A.getAttribute("data-key"));if(!f)return;const s=this.#e.rows.byKey(f.getAttribute("data-key"));if(!s||s.group)return;const p=c.getAttribute("data-col"),b=this.#e.columns.get(p);!b||!b.edit||!b.edit.enabled||this.#e.edit.start(s.key,p)},l=o==="key"?null:o==="single"?"click":"dblclick";l&&(t.addEventListener(l,d),this.#u.push(()=>t.removeEventListener(l,d)));const i=m=>{!this.#i||!this.#l||this.#g(m.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){const n=t.key||t.row&&t.row.key,o=t.colId;if(!n||!o)return;if(this.#i&&this.#l&&this.#l.key===n&&this.#l.colId===o){this.#m();return}this.close();const d=this.#e.columns.get(o),l=this.#e.rows.byKey(n);if(!d||!l||!H({column:d,edit:d.edit,row:l,value:this.#e.rows.value(n,o),grid:this.#e}))return;const i=this.#y(n,o);if(this.#c=i,!i){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,c=!!(m&&x(m.isSecret)&&m.isSecret(o)),f=_({grid:this.#e,column:d,colId:o,row:l,data:l.data,value:c?null:this.#e.rows.value(n,o),text:c?"":this.#e.rows.text(n,o),locale:this.#e.get("locale"),props:d.edit&&d.edit.props,lookup:d.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:b=>this.#p({value:b,key:n,colId:o}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:b=>{this.#d||this.#e.edit.stop(b)}},this.#r);if(!f){B(`celledit.noeditor:${o}`,`column "${o}" has no editor.`);return}this.#i=f,this.#s=i,this.#l={key:n,colId:o},this.#d=!1,this.#a=this.#O(i);const s=f.element();f.popup?(this.#n.viewport.overlays.appendChild(s),h(s,i,this.#n.viewport.root)):i.replaceChildren(s),i.classList.add(j),x(f.attached)&&f.attached(),a(s);const p=b=>this.#f(b);s.addEventListener("keydown",p),this.#u.push(()=>s.removeEventListener("keydown",p))}#f(t){const n=t.key;if(n!=="Enter"&&n!=="Tab"&&n!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),n==="Escape"){this.#e.edit.stop(!0);return}const o=n==="Enter"?this.#b(t.shiftKey?-1:1):this.#w(t.shiftKey?-1:1);this.commit()&&o&&this.#e.edit.start(o.key,o.colId)}#p(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(x(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#l;if(x(this.#i.value)){const o=this.#i.value();if(x(this.#i.validate)){const d=this.#i.validate(o);if(d!==!0){if(V(this.#c,d),x(this.#i.focusTarget)){const l=this.#i.focusTarget();l&&x(l.focus)&&l.focus()}return!1}V(this.#c,null)}this.#p({value:o,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(){const t=x(this.#i.element)?this.#i.element():null;if(!t)return;const n=t.querySelector&&t.querySelector("input, select, textarea, [tabindex]")||t;x(n.focus)&&n.focus()}#g(t){if(!t)return!1;const n=x(this.#i.element)?this.#i.element():null;if(n&&x(n.contains)&&n.contains(t))return!0;const o=this.#c;return!!(o&&x(o.contains)&&o.contains(t))}#b(t){if(!this.#l||this.#a<0)return null;for(let n=this.#a+t;n>=0&&n<this.#e.rows.count();n+=t){const o=this.#e.rows.get(n);if(o&&!o.group)return{key:o.key,colId:this.#l.colId}}return null}#w(t){if(!this.#l)return null;const n=this.#e.columns.visible(),o=n.findIndex(d=>d.id===this.#l.colId);for(let d=o+t;d>=0&&d<n.length;d+=t){const l=n[d];if(l.edit&&l.edit.enabled)return{key:this.#l.key,colId:l.id}}return null}#O(t){const n=u(t,d=>d.getAttribute&&d.getAttribute("data-index"));if(!n)return-1;const o=Number(n.getAttribute("data-index"));return Number.isFinite(o)?o:-1}#y(t,n){const o=this.#n.viewport.root;if(!o||!o.querySelectorAll)return null;for(const d of o.querySelectorAll(`[data-col="${n}"]`)){const l=u(d,i=>i.getAttribute&&i.getAttribute("data-key"));if(l&&l.getAttribute("data-key")===t)return d}return null}close(t=!1){const n=this.#l,o=this.#d;this.#c&&V(this.#c,null);const d=this.#A();if(this.#i&&x(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(j),this.#o&&x(this.#o.releaseCell)){const l=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,l)}this.#s.replaceChildren&&this.#s.replaceChildren(),d&&this.#k(this.#s),this.#n.refresh({force:!0})}if(this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1,!t&&n&&!o){const l=this.#h;l&&l.key===n.key&&l.colId===n.colId&&this.#e.edit.stop(!1)}}#A(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&x(this.#i.element)?this.#i.element():null,o=d=>!!d&&x(d.contains)&&d.contains(t);return o(n)||o(this.#s)}#k(t){const o=x(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;o&&x(o.focus)&&o.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function u(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function h(r,t,n){if(!x(t.getBoundingClientRect))return;const o=t.getBoundingClientRect(),d=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(o.top-d.top)}px`,r.style.minWidth=`${Math.round(o.width)}px`,r.style.left=`${Math.round(o.left-d.left)}px`;const l=r.offsetWidth||Math.round(o.width),i=Math.round(o.left-d.left)+l-Math.round(d.width);i>0&&(r.style.left=`${Math.max(0,Math.round(o.left-d.left)-i)}px`)}function a(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;x(t.focus)&&t.focus(),x(t.select)&&t.select()}}),Le("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,V=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class H{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root}mount(){const w=this.#t,j=w.createElement("div");j.className=V;const g=w.createElement("span");g.className=`${V}__ref`,g.textContent="";const u=w.createElement("div");u.className=`${V}__slot`;const h=w.createElement("span");h.className=`${V}__readonly`,j.appendChild(g),j.appendChild(u),this.#n.insertBefore(j,this.#n.firstChild),this.#r=j,this.#o=g,this.#i=u,this.#l=h;for(const a of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(a,r=>this.#f(r)))}bind(w,j){const g=this.#e.columns.get(j),u=w?this.#e.rows.byKey(w):null;this.#a=u&&g&&!u.group?{key:w,colId:j}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:w,colId:j}=this.#a,g=this.#e.columns.get(j);if(!g)return;if(this.#o.textContent=g.title||j,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,j),this.#i.appendChild(this.#l);return}const h=this.#e.rows.byKey(w);if(!h)return;const a=_({grid:this.#e,column:g,colId:j,row:h,data:h.data,value:this.#e.rows.value(w,j),text:this.#e.rows.text(w,j),locale:this.#e.get("locale"),props:g.edit&&g.edit.props,lookup:g.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:d=>d?this.cancel():this.commit(!0)});if(!a){B(`editbar.noeditor:${j}`,`column "${j}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,j),this.#i.appendChild(this.#l);return}this.#s=a;const r=a.element();a.popup?(this.#l.textContent=this.#e.rows.text(w,j),this.#i.appendChild(this.#l)):this.#i.appendChild(r),x(a.attached)&&a.attached();const t=d=>this.#p(d),n=()=>{this.#u=!0},o=[r,this.#i];for(const d of o)d.addEventListener("keydown",t),d.addEventListener("input",n),d.addEventListener("change",n);this.#c=()=>{for(const d of o)d.removeEventListener("keydown",t),d.removeEventListener("input",n),d.removeEventListener("change",n)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&x(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(w){if(w&&w.colId&&(w.key||w.row&&w.row.key)){this.bind(w.key||w.row.key,w.colId);return}this.refresh()}#p(w){if(w.key==="Enter"){w.preventDefault(),this.commit();return}w.key==="Escape"&&(w.preventDefault(),this.cancel())}commit(w){if(!this.#a||!this.#u&&!w)return!1;const{key:j,colId:g}=this.#a;if(!this.#s||!x(this.#s.value))return!1;const u=this.#s.value();return this.#u=!1,this.#e.edit.start(j,g),this.#e.edit.stop(!1,{value:u,key:j,colId:g}),this.refresh(),!0}destroy(){this.#h();for(const w of this.#d)w();this.#d=[],this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Le("packages/dom/src/pastepreview.js",function(e,K){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return z}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.clear,V="lat-pastepreview",H='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class z{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(j){this.#e=j.grid,this.#t=j.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(j,g){const u=this.#e;return(u&&u.messages?u.messages:I).t(j,g)}#d(j){const g=`paste.preview.reason.${j}`,u=this.#c(g);return u===g?j:u}#h(j){return j==null||j===""?"":String(j)}#f(j,g){const u=this.#e.columns&&x(this.#e.columns.get)?this.#e.columns.get(g):null;return`${u&&(u.title||u.headerName)||g} · ${j}`}show(j,g){const u=this.#w();if(!u)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const h=j&&j.changes||[],a=j&&j.rejected||[],r=h.filter(n=>n.changed);this.#p(r,a);const t=u.ownerDocument;return this.#s=t&&t.activeElement,u.style.display="",x(u.focus)&&u.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:r.length,changes:r.length,rejected:a.length}),{repeat:!0}),!0}#p(j,g){const u=this.#r.ownerDocument;W(this.#r);const h=X(u,"p",{class:`${V}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:j.length,changes:j.length,rejected:g.length})});if(this.#r.appendChild(h),!j.length&&!g.length){this.#r.appendChild(X(u,"p",{class:`${V}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!j.length;return}this.#o.disabled=!j.length,j.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading`,text:this.#c("paste.preview.changesHeading",{count:j.length})})),this.#r.appendChild(this.#m(u,j))),g.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading ${V}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:g.length})})),this.#r.appendChild(this.#g(u,g)))}#m(j,g){const u=X(j,"tr",{children:[X(j,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(j,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(j,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),h=g.map(a=>X(j,"tr",{children:[X(j,"th",{attrs:{scope:"row"},text:this.#f(a.key,a.colId)}),X(j,"td",{class:`${V}__old`,text:this.#h(a.oldValue)}),X(j,"td",{class:`${V}__new`,text:this.#h(a.newValue)})]}));return X(j,"table",{class:`${V}__table`,children:[X(j,"thead",{children:[u]}),X(j,"tbody",{children:h})]})}#g(j,g){const u=X(j,"tr",{children:[X(j,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(j,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),h=g.map(a=>X(j,"tr",{children:[X(j,"th",{attrs:{scope:"row"},text:this.#f(a.key,a.colId)}),X(j,"td",{class:`${V}__reason`,text:this.#d(a.reason)})]}));return X(j,"table",{class:`${V}__table ${V}__table--rejected`,children:[X(j,"thead",{children:[u]}),X(j,"tbody",{children:h})]})}confirm(){const j=this.#l;this.#b(),x(j)&&j()}cancel(){const j=this.#a;this.#b(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),x(j)&&j()}#b(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const j=this.#s;this.#s=null,j&&x(j.focus)&&j.focus()}#w(){if(this.#n)return this.#n;const j=this.#t.viewport&&this.#t.viewport.overlays,g=j&&j.ownerDocument;if(!j||!g||!x(g.createElement))return null;const u=`${V}-title`,h=X(g,"h2",{class:`${V}__title`,attrs:{id:u},text:this.#c("paste.preview.title")}),a=X(g,"div",{class:`${V}__body`}),r=X(g,"button",{class:`${V}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(g,"button",{class:`${V}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),n=X(g,"div",{class:`${V}__foot`,children:[t,r]}),o=X(g,"div",{class:V,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":u},children:[X(g,"div",{class:`${V}__head`,children:[h]}),a,n]});return j.appendChild(o),this.#n=o,this.#r=a,this.#o=r,this.#i=t,this.#O(o,r,t),o}#O(j,g,u){const h=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const n=[...j.querySelectorAll(H)].filter(i=>!i.disabled);if(!n.length){t.preventDefault();return}const o=n[0],d=n[n.length-1],l=j.ownerDocument.activeElement;t.shiftKey&&(l===o||l===j)?(t.preventDefault(),d.focus()):!t.shiftKey&&l===d&&(t.preventDefault(),o.focus())},a=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.confirm()},r=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.cancel()};j.addEventListener("keydown",h),g.addEventListener("click",a),u.addEventListener("click",r),this.#u.push(()=>{j.removeEventListener("keydown",h),g.removeEventListener("click",a),u.removeEventListener("click",r)})}#y(j,g){const u=this.#t&&this.#t.announce;x(u)&&u.call(this.#t,j,g)}destroy(){for(const j of this.#u)j();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Le("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),X=_.extendSeries,W=_.resolveSelectionConfig,V=K("packages/dom/src/renderer/textentry.js"),H=V.isTextEntry,z=V.isFindBarControl,j=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),u=g.chartableRange,h=g.rangeChartConfig,a="lat-cell--range",r="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),n=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,m=p=>this.#c(p),c=p=>this.#d(p),f=()=>this.#h(),s=p=>this.#f(p);i.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",f),i.addEventListener("keydown",s),this.#o.push(()=>{i.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",f),i.removeEventListener("keydown",s)});for(const p of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(p,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const m=i.target;if(!m||!x(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#M())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const c=this.#I(m);if(!c)return;if(i.shiftKey&&this.#e.selection.corner()){const s=this.#P(c);this.#e.selection.extendRange(s.rowIndex,s.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const f=this.#T(c);this.#u=f,this.#e.selection.startRange(f.rowIndex,f.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(i.clientX-m.fromX)+Math.abs(i.clientY-m.fromY)<n)return;m.armed=!0}const c=this.#D(i.clientX,i.clientY);if(!c)return;if(m.mode==="fill"){this.#l=c,this.paint();return}const f=this.#P(c);this.#e.selection.extendRange(f.rowIndex,f.colId)}#h(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#f(i){if(this.#z()||z(i.target)||H(i.target))return;const m=i.ctrlKey||i.metaKey,c=i.key;if(m&&(c==="c"||c==="C")){this.copy(),i.preventDefault();return}if(m&&(c==="v"||c==="V")){this.paste(),i.preventDefault();return}if(m&&(c==="d"||c==="D")){this.fillDown(),i.preventDefault();return}if(m&&!i.altKey&&(c==="z"||c==="Z"||c==="y"||c==="Y")){const O=this.#e.edit;if(!O||O.undoShortcuts===!1)return;const F=c==="y"||c==="Y"||i.shiftKey;this.#y(F)&&i.preventDefault();return}if(c==="Delete"||c==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),i.preventDefault();return}if(i.altKey&&c==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const f={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!f)return;if(m){const O=this.#L();if(!O)return;if(!this.#r){const C=this.#T(O);this.#u=C,this.#e.selection.startRange(C.rowIndex,C.colId,{additive:!0}),this.#r=!0}const F=this.#e.columns.visible().map(C=>C.id),E=F.indexOf(O.colId),T=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},L=this.#P({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,T.row+f[0])),colId:F[Math.min(F.length-1,Math.max(0,(E<0?0:E)+f[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),i.preventDefault();return}this.#r=!1;const s=this.#e.selection.corner(),p=this.#L(),b=s||p;if(!b)return;if(!s&&p){const O=this.#T(p);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const A=this.#e.columns.visible().map(O=>O.id),k=A.indexOf(b.colId??b.colId),y=A[Math.min(A.length-1,Math.max(0,k+f[1]))],S=Math.min(this.#e.rows.count()-1,Math.max(0,(s?s.row:p.rowIndex)+f[0])),R=this.#P({rowIndex:S,colId:y});this.#e.selection.extendRange(R.rowIndex,R.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const m=globalThis.navigator&&globalThis.navigator.clipboard;if(!m||!x(m.writeText))return!1;try{return await m.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!x(i.readText))return 0;let m="";try{m=await i.readText()}catch{return 0}return this.pasteText(m)}pasteText(i){if(!i)return 0;const m=this.#e.selection.cells(),c=m.length?m[0]:this.#O();if(!c)return 0;const f=m.length>1?{rows:new Set(m.map(s=>s.key)).size,columns:new Set(m.map(s=>s.colId)).size}:void 0;if(this.#p()){const s=this.#e.edit.previewPaste(c,i,f);if(s.changes.length+s.rejected.length>1)return this.#m().show(s,{onConfirm:()=>this.#g(c,i,f)}),0}return this.#g(c,i,f)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&x(i.previewPaste))}#m(){return this.#a||(this.#a=new j({grid:this.#e,renderer:this.#t})),this.#a}#g(i,m,c){const f=this.#e.edit.pasteInto(i,m,c,{origin:"user"}),s=p=>this.#w(p?this.#b("a11y.range.written",{count:p}):this.#b("a11y.range.refused"),{repeat:!0});return f&&x(f.then)?f.then(s):s(f),f}#b(i,m){const c=this.#e;return(c&&c.messages?c.messages:I).t(i,m)}#w(i,m){const c=this.#t&&this.#t.announce;x(c)&&c.call(this.#t,i,m)}#O(){const i=this.#L();if(!i)return null;const m=this.#e.rows.get(i.rowIndex);return m?{key:m.key,colId:i.colId}:null}#y(i){const m=this.#e.history;return!(!m||!(i?m.canRedo():m.canUndo())||!(i?m.redo():m.undo()))}clear(){let i=this.#e.selection.cells();const m=this.#O(),c=this.#n&&this.#n.activeElement;if(!!(m&&c&&x(c.matches)&&c.matches('[data-col][tabindex="0"]'))&&!i.some(b=>b.key===m.key&&b.colId===m.colId)?i=[m]:i.length||(i=m?[m]:[]),!i.length)return 0;const s=this.#e.edit.setCells(i.map(b=>({key:b.key,colId:b.colId,value:null})),"cell",{origin:"user"}),p=b=>{b&&this.#w(this.#b("a11y.range.cleared",{count:b}),{repeat:!0})};return s&&x(s.then)?s.then(p):p(s),s}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const m=[...new Set(i.map(s=>s.key))];if(m.length<2)return 0;const c=m[0],f=[];for(const{key:s,colId:p}of i)s!==c&&f.push({key:s,colId:p,value:this.#e.rows.value(c,p)});return this.#e.edit.setCells(f,"cell",{origin:"user"})}chartSelection(){const i=h(this.#e);if(!i.handler)return!1;const m=u(this.#e);return m?(i.handler(this.#e,m),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const m=this.#e.selection.cells();if(!m.length)return 0;const c=[...new Set(m.map(y=>y.key))],f=[...new Set(m.map(y=>y.colId))],s=this.#B(c[c.length-1]);if(s<0||i<=s)return 0;const p=[];for(let y=s+1;y<=i;y++){const S=this.#e.rows.get(y);if(!S)break;p.push(S)}if(!p.length)return 0;const b=[];for(const y of f){const S=c.map(O=>this.#e.rows.value(O,y)),R=this.#A(S,p,y);for(let O=0;O<p.length;O++)b.push({key:p[O].key,colId:y,value:R[O]})}const A=this.#e.edit.setCells(b,"cell",{origin:"user"}),k=this.#e.selection.corner();return k&&this.#e.selection.extendRange(i,k.colId),A}#A(i,m,c){const f=this.#e.get("selection"),s=f&&typeof f=="object"?f.fill:void 0;if(x(s)){const p=this.#e.columns.get(c),b=m.map(k=>({row:k,column:p})),A=s({source:i,target:b,direction:"down"});if(Array.isArray(A)&&A.length===m.length)return A}return X(i,m.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const m=this.#e.selection,c=m.ranges().length>0,f=this.#l;for(const s of i.querySelectorAll("[data-col]")){const p=s.getAttribute("data-col"),b=s.parentNode,A=s.getAttribute?s.getAttribute("data-index"):null,k=A!==null&&A!==""?A:b&&b.getAttribute?b.getAttribute("data-index"):null;if(k===null||k==="")continue;const y=Number(k);if(!Number.isFinite(y)||y<0)continue;const S=c&&m.inRange(y,p),R=!!f&&this.#k(y,p,f);s.classList.toggle(a,S||R);const O=S||R?this.#C(y,p,m):null;s.classList.toggle(r,!!O&&O.any);for(const[F,E]of Object.entries(t))s.classList.toggle(E,!!O&&O[F])}this.#S()}#k(i,m,c){const f=this.#e.selection.cells();if(!f.length||!new Set(f.map(b=>b.colId)).has(m))return!1;const p=this.#B([...new Set(f.map(b=>b.key))].pop());return i>p&&i<=c.rowIndex}#C(i,m,c){const f=this.#e.columns.visible().map(k=>k.id),s=f.indexOf(m),p=s>0?f[s-1]:null,b=s>=0&&s<f.length-1?f[s+1]:null,A={top:!c.inRange(i-1,m),bottom:!c.inRange(i+1,m),left:!p||!c.inRange(i,p),right:!b||!c.inRange(i,b)};return A.any=A.top||A.bottom||A.left||A.right,A}#S(){const i=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!i||this.#$()===!1||this.#e.selection.ranges().length>1||this.#M()){this.#s&&(this.#s.style.display="none");return}const c=this.#_(i.row,i.colId);if(!c||!x(c.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#b("a11y.fillHandle")),m.appendChild(this.#s));const f=c.getBoundingClientRect(),s=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const b=this.#t.viewport.rtl===!0?f.left:f.right;this.#s.style.left=`${Math.round(b-s.left)-4}px`,this.#s.style.top=`${Math.round(f.bottom-s.top)-4}px`}#E(i){const m=this.#t;return!i||typeof m.spanAt!="function"?null:m.spanAt(i.rowIndex,i.colId)}#T(i){const m=this.#E(i);return m?{rowIndex:m.row,colId:m.columnId}:i}#P(i){const m=this.#E(i);if(!m)return i;const c=this.#u,f=!!c&&c.rowIndex>=m.row+m.rows,s=this.#N(),p=c?s.indexOf(c.colId):-1,b=p>=0&&p>=m.col+m.cols;return{rowIndex:f?m.row:m.row+m.rows-1,colId:b?m.columnId:m.endColumnId}}#M(){const i=this.#e.selection.corner();if(!i)return!1;const m=this.#E({rowIndex:i.row,colId:i.colId});return!!m&&(m.rows>1||m.cols>1)}#N(){const i=this.#e.columns;return i&&x(i.visible)?i.visible().map(m=>m.id):[]}#$(){return W(this.#e.get("selection")).fillHandle}#z(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#H(){const i=this.#e.selection.cells();return i.length?i[0]:null}#B(i){for(let m=0;m<this.#e.rows.count();m++){const c=this.#e.rows.get(m);if(c&&c.key===i)return m}return-1}#L(){const i=this.#t.viewport.root,m=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return m?this.#I(m):null}#I(i){if(!i||!x(i.closest))return null;const m=i.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const c=m.closest("[data-index]");if(!c)return null;const f=Number(c.getAttribute("data-index"));return!Number.isFinite(f)||f<0?null:{rowIndex:f,colId:m.getAttribute("data-col")}}#D(i,m){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(i,m):null;return c?this.#I(c):null}#_(i,m){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const f of c.querySelectorAll(`[data-col="${m}"]`)){const s=f.closest?f.closest("[data-index]"):null;if(s&&Number(s.getAttribute("data-index"))===i)return f}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&x(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&x(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const d=o}),Le("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),X=_.parseDelimited,W=_.inferColumns,V=_.mapRecords,H=_.readXlsx,z=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),j=w.el,g=w.clear,u=w.on,a=K("packages/dom/src/renderer/textentry.js").isTextEntry,r="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',n=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document;const i=l.settings&&typeof l.settings=="object"?l.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const l=this.#t&&this.#t.viewport?this.#t.viewport.root:null;l&&(this.#r.drop&&(this.#o.push(u(l,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),l.classList.add("lat-import--dropzone"))})),this.#o.push(u(l,"dragleave",()=>l.classList.remove("lat-import--dropzone"))),this.#o.push(u(l,"drop",i=>{l.classList.remove("lat-import--dropzone");const m=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];m&&(i.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(u(l,"paste",i=>{if(a(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=i.clipboardData&&i.clipboardData.getData("text/plain");!m||!m.includes(`
|
|
57
|
-
`)||(i.preventDefault(),this.fromText(m))})))}openFile(){const l=j(this.#n,"input",{attrs:{type:"file",accept:n}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(x(l.arrayBuffer)){l.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(x(l.text)){l.text().then(m=>this.fromText(m,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:m,rows:c}=await H(l);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(l,i){const{header:m,rows:c,delimiter:f}=X(l);if(!m.length)return;const s=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:s,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&x(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,i){const m=this.#t&&this.#t.announce;x(m)&&m.call(this.#t,l,i)}#f(l,i){return(this.#e&&this.#e.messages?this.#e.messages:I).t(l,i)}#p(){const l=this.#n,i=j(l,"div",{class:r,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=j(l,"div",{class:`${r}__panel`});m.appendChild(j(l,"h2",{class:`${r}__title`,text:this.#f("import.title")})),this.#s=j(l,"div",{class:`${r}__body`}),m.appendChild(this.#s);const c=j(l,"div",{class:`${r}__footer`}),f=j(l,"button",{class:`${r}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),s=j(l,"button",{class:`${r}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(f,"click",()=>this.close())),this.#o.push(u(s,"click",()=>this.#g())),c.appendChild(f),c.appendChild(s),m.appendChild(c),i.appendChild(m),this.#o.push(u(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const A=[...i.querySelectorAll(t)].filter(S=>!S.hidden);if(!A.length)return;const k=A[0],y=A[A.length-1];b.shiftKey&&this.#n.activeElement===k?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),k.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:s}=this.#l;i.appendChild(j(l,"p",{class:`${r}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const S of s)i.appendChild(j(l,"p",{class:`${r}__warning`,text:S}));const p=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),b=j(l,"table",{class:`${r}__map`}),A=j(l,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])A.appendChild(j(l,"th",{text:this.#f(S)}));b.appendChild(A),c.forEach((S,R)=>{const O=j(l,"tr",{});O.appendChild(j(l,"td",{text:S.source}));const F=j(l,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:S.source})}});F.appendChild(j(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const T of p)F.appendChild(j(l,"option",{text:T,attrs:{value:T,selected:T===S.field?!0:null}}));S.field&&!p.includes(S.field)&&F.appendChild(j(l,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const E=j(l,"td",{});E.appendChild(F),O.appendChild(E),O.appendChild(j(l,"td",{class:`${r}__type`,text:S.type})),b.appendChild(O)}),i.appendChild(b);const k=j(l,"div",{class:`${r}__mode`}),y=j(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(j(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(j(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(j(l,"label",{text:this.#f("import.modeLabel")})),k.appendChild(y),i.appendChild(k)}#g(){const{rows:l,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,s=V(l,i);this.#e.import.apply(s,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&x(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Le("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V=_.clear,H=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,h){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(u,h)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||I;const h=u||{};if(this.doc=H(h),this.host=h.host||{},this.props=h.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const a=X(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(a,"click",()=>this.toggle())),this.root.appendChild(a),this.toggleButton=a,this.menu=X(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,h,a){const r=X(this.doc,"button",{class:`${z}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:a,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:h})]});return this.off.push(W(r,"click",()=>{const t=this.host[u];x(t)&&t(),this.refresh()})),r}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,h=x(u.canUndo)?u.canUndo():!1,a=x(u.canRedo)?u.canRedo():!1,r=x(u.peek)?u.peek("undo"):null,t=x(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",h,r),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(u,h,a,r){if(!u)return;u.disabled=!a;const t=h==="undo",n=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${z}__label`);o&&(o.textContent=n);const d=r&&r.label?this.t("history.described",{action:n,label:r.label}):n;u.setAttribute("title",a?d:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",a?d:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const h=x(this.host.list)?this.host.list():[];if(!h.length){u.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}h.forEach((a,r)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":a.type,"data-undone":a.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:a.type}),X(this.doc,"span",{class:`${z}__text`,text:a.label||a.type})]});this.off.push(W(t,"click",()=>{const n=r+1;for(let o=0;o<n;o++)x(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&x(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const j=w}),Le("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",V="lat-cell--added-column";class H{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const u=this.#e.diff,h=u&&u.enabled;for(const a of g.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key"),t=h?u.statusOf(r):"unchanged";for(const o of Object.values(X))a.classList.remove(o);h&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",h?t:"");const n=h&&t==="changed";for(const o of a.querySelectorAll("[data-col]")){const d=o.getAttribute("data-col");if(o.classList.remove(W,V),o.removeAttribute("data-before"),!n)continue;const l=u.cellStatus(r,d);if(l==="changed"){o.classList.add(W);const i=this.#r(u,r,d);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(V)}}}#r(g,u,h){const a=this.#e,r=a&&a.columns,t=r&&x(r.get)?r.get(h):null,n=a&&a.permissions;if(t&&n&&x(n.isSecret)&&n.isSecret(t))return null;const o=g.before(u,h);if(o==null)return this.#o("diff.empty");if(!t||!x(t.formatValue))return String(o);const d=x(g.beforeRow)?g.beforeRow(u):void 0,i={...(a.rows&&x(a.rows.byKey)?a.rows.byKey(u):null)||{},data:d===void 0?{}:d};try{const m=t.formatValue(o,i,i.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${h}`,`the formatter for column "${h}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(o)}}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:_).t(g,u)}destroy(){for(const u of this.#n)u();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const u of g.querySelectorAll("[data-key]")){for(const h of Object.values(X))u.classList.remove(h);u.removeAttribute("data-diff")}for(const u of g.querySelectorAll("[data-col]"))u.classList.remove(W,V),u.removeAttribute("data-before")}}}function z(j){return!!(j&&j.diff&&(x(j.diff)||typeof j.diff=="object"))}const w=H}),Le("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",I="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#l();if(H){H.sweep();for(const z of V.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const j of z.querySelectorAll("[data-col]")){const g=H.active?H.colourFor(w,j.getAttribute("data-col")):null;g?(j.classList.add(B),j.style.setProperty(I,g)):j.classList.contains(B)&&(j.classList.remove(B),j.style.removeProperty(I))}}this.#s(H)}}#s(V){this.#r!==null&&x(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=V.nextExpiry;if(!Number.isFinite(H)||!x(this.#i.setTimeout))return;const z=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const V=this.#e.highlight;return V&&x(V.model)?V.model():null}destroy(){this.#r!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const H of V.querySelectorAll(`.${B}`))H.classList.remove(B),H.style.removeProperty(I)}}const X=_}),Le("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",I="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#e.find;if(!H||!x(H.stateFor))return;const z=x(H.model)?H.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let j=!1;for(const g of V.querySelectorAll("[data-key]")){const u=g.getAttribute("data-key");for(const h of g.querySelectorAll("[data-col]")){const a=w?H.stateFor(u,h.getAttribute("data-col")):null;a?(j=!0,h.classList.add(B),h.classList.toggle(I,a==="current")):h.classList.contains(B)&&h.classList.remove(B,I)}}this.#o=j}destroy(){for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const H of V.querySelectorAll(`.${B}`))H.classList.remove(B,I);this.#o=!1}}}const X=_}),Le("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,j=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#b=null;#w=null;#O=!1;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document||a.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=a.settings&&typeof a.settings=="object"?a.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(a,r){const t=this.#e;return(t&&t.messages&&H(t.messages.t)?t.messages:W).t(a,r)}mount(){const a=this.#A();if(!a)return;a.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),a.attachDriver({run:()=>this.#P()});const r=this.#t.viewport?.root;if(r&&H(r.addEventListener)&&this.#o.shortcut!==!1){const t=n=>{if(!(n.ctrlKey||n.metaKey)||n.altKey||n.shiftKey||n.key!=="f"&&n.key!=="F")return;const o=n.target;if(this.#s&&o===this.#s){n.preventDefault(),n.stopPropagation(),H(this.#s.select)&&this.#s.select();return}_(o)||(n.preventDefault(),n.stopPropagation(),this.show())};r.addEventListener("keydown",t,!0),this.#g.push(()=>r.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#C())),this.#g.push(this.#e.on("column:visible",()=>this.#C()))}show(a){const r=this.#k();if(!r)return;const t=r.style.display!=="none";r.style.display="",t||this.#y(),this.#A().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#E()),this.#s.focus(),H(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#H();const a=this.#A();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),a&&(a.clear(),a.setOpen(!1));const r=this.#t.viewport?.root;if(!r||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(H(r.querySelector)?r.querySelector('[tabindex="0"]'):null)||r;H(o.focus)&&o.focus()}search(){this.#E()}destroy(){this.#O=!0,this.#H();for(const r of this.#g)r();this.#g=[];const a=this.#A();a&&(a.attachUi(null),a.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const a=this.#t;a&&H(a.invalidate)&&a.invalidate("size")}#A(){const a=this.#e&&this.#e.find;return a&&H(a.model)?a.model():null}#k(){if(this.#i)return this.#i;const a=this.#t.viewport,r=a?.root,t=this.#n;if(!r||!t||!H(r.insertBefore))return null;const n=x(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=x(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=x(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=x(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=x(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=x(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),d=x(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=x(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=x(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=x(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=x(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=x(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,d,l,i])n.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(d,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#E()})),this.#g.push(B(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#E()})),this.#g.push(B(l,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#b!==null&&(this.#$(),this.#E()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return n.addEventListener("keydown",m),this.#g.push(()=>n.removeEventListener("keydown",m)),n.style.display="none",r.insertBefore(n,a.header||r.firstChild),this.#i=n,this.#C(),n}#C(){const a=this.#h;if(!a)return;const r=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(x(r,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,n=t&&H(t.visible)?t.visible():[];let o=!1;for(const d of n){if(!d||d.id===void 0)continue;const l=String(d.id);a.appendChild(x(r,"option",{text:d.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),a.value=this.#m||""}#S(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):j;if(this.#$(),a===0||!H(this.#r.setTimeout)){this.#E();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#E()},a)}#E(){const a=this.#A();if(!a||this.#O)return;const r=this.#s?this.#s.value:"";if(!r){this.#z(),a.clear();return}a.begin(r,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#T()}),this.#P()}#T(){const a=this.#t&&this.#t.window,r=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,r)}#P(){if(this.#w!==null||this.#O)return;const a=()=>{this.#w=null,this.#M()};H(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(a):H(this.#r.setTimeout)?this.#w=this.#r.setTimeout(a,0):a()}#M(){const a=this.#A();!a||this.#O||!a.active||(a.stale&&a.rescan({from:this.#T()}),!a.complete&&(a.step(w)||this.#P()))}#N(){if(!this.#i||this.#O)return;const a=this.#e.find.count(),r=this.#A().active;let t="",n="idle";r&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),n=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),n=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",n);const o=r&&a.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",r?a.complete&&(this.#u.textContent=a.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#$(){this.#b!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#z(){this.#w!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#H(){this.#$(),this.#z()}}const u=g}),Le("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="lat-cell--redacted",x="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const V=W.active;for(const H of X.querySelectorAll(`.${x}[data-col]`))V&&W.has(H.getAttribute("data-col"))?H.classList.add(Q):H.classList.contains(Q)&&H.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Le("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,V){let H=W;for(;H;){if(V(H))return H;H=H.parentNode}return null}class _{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const H=I(V,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const z of H.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),j=this.#r(z),g=j?V.errorFor(j,w):null;x(z,g?g.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=_}),Le("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",V="lat-presenting--changing",H="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class j{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(h){this.#e=h.grid,this.#t=h.renderer,this.#n=h.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",a=>this.#a(a))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&x(this.#n.watch)&&this.#r.push(this.#n.watch(a=>{a||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const h=this.#t.viewport?.root;if(h&&x(h.addEventListener)){const a=r=>this.#l(r);h.addEventListener("keydown",a),this.#r.push(()=>h.removeEventListener("keydown",a))}}#l(h){const a=this.#e.presentation;if(!a?.active)return;const r=h.ctrlKey||h.metaKey,t=h.key;if(t==="Escape"&&!this.#n){h.defaultPrevented||(a.stop(),h.preventDefault?.());return}if(r){t==="="||t==="+"?(a.nudge(1),h.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),h.preventDefault?.()):t==="0"&&(a.setScale(1.5),h.preventDefault?.());return}if(!a.views.length||I(h.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),h.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),h.preventDefault?.()):t==="Home"?(a.goTo(0),h.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),h.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),h.preventDefault?.())}#a(h){!h||!h.viewId||(this.#u(),this.#e.views?.apply?.(h.viewId),this.#c(h))}#u(){const h=this.#t.viewport?.root;h?.classList&&(h.classList.remove(V),h.offsetWidth,h.classList.add(V))}#c(h){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const r=a.ownerDocument;if(!r?.createElement)return;if(!this.#i){const o=r.createElement("div");o.className=H,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),a.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(h.viewId),n=t&&t.name?t.name:"";this.#i.textContent=n?`${n} · ${(h.index||0)+1} / ${h.count||0}`:`${(h.index||0)+1} / ${h.count||0}`}#d(){if(this.#o){this.#f();return}const h=!!(this.#n&&this.#n.active());this.#n&&!h&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),r=[];for(const n of w){if(a.has(n)||n==="toolPanel"&&this.#O())continue;const o=this.#y(n);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",r.push(o))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",r.push(t)),this.#o={maximised:h,hidden:r},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const h=this.#o;this.#o=null;const a=this.#t.viewport?.root;if(a?.classList?.remove(W),a?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),a?.classList?.remove(V),this.#p(),h){const r=this.#e.toolPanel;r&&x(r.presentRestore)&&r.presentRestore();for(const t of h.hidden)t.style.display="";this.#n&&!h.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const h=this.#t.viewport?.root;!h||!h.style||(h.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const h=this.#t.viewport?.root;if(!h?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,r=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const n of h.querySelectorAll("[data-key]")){const o=!r||r.has(n.getAttribute("data-key"));for(const d of n.querySelectorAll("[data-col]"))!a||o&&(!t||t.has(d.getAttribute("data-col")))?d.classList.remove(z):d.classList.add(z)}}#m(){this.#g();const h=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(h)||h<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const r=this.#e.presentation;r.active&&r.goTo(r.index>=r.views.length-1?0:r.index+1)},Math.max(1e3,h)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const h=this.#e.element;return!h||!x(h.querySelector)?null:h.querySelector(`.${X.statusBar}`)}#w(h){const a=h.children||[];for(const r of a)if(!r.style||r.style.display!=="none")return!1;return!0}#O(){const h=this.#e.toolPanel;return!!(h&&x(h.presentOnly)&&h.presentOnly())}#y(h){const a=this.#e.element;if(!a||!x(a.querySelector))return null;const r={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[h];return r?a.querySelector(r):null}destroy(){this.#o&&this.#h();for(const h of this.#r)h();this.#r=[]}}const g=j}),Le("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const x=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(H,z,w){const j=w.getComputedStyle(H),g=z.style;if(g)for(let u=0;u<j.length;u++){const h=j[u];B.has(h)||g.setProperty(h,j.getPropertyValue(h),j.getPropertyPriority(h))}}function _(H,z,w){if(I(H,z,w),H.tagName==="CANVAS"&&x(H.toDataURL))try{const u=H.toDataURL("image/png"),h=z.style;h&&(h.setProperty("background-image",`url(${u})`),h.setProperty("background-size","100% 100%"),h.setProperty("background-repeat","no-repeat"))}catch{}const j=H.children||[],g=z.children||[];for(let u=0;u<j.length&&u<g.length;u++)_(j[u],g[u],w)}function X(H,z){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,z).origin===z}catch{return!0}}async function W(H,z={}){const w=H.ownerDocument,j=w?.defaultView;if(!j||typeof j.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(g.width)),h=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(z.scale)||2),r=j.location?.origin||"";for(const m of H.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,r))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=H.cloneNode(!0);_(H,t,j),t.style.width=`${u}px`,t.style.height=`${h}px`,t.style.margin="0";const n=new j.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${h}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${n}</div></foreignObject></svg>`,d=new j.Image;await new Promise((m,c)=>{d.onload=()=>m(void 0),d.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=w.createElement("canvas");l.width=Math.round(u*a),l.height=Math.round(h*a);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||j.getComputedStyle(H).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(d,0,0,l.width,l.height),new Promise((m,c)=>{l.toBlob(f=>f?m({blob:f,width:l.width,height:l.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const V=W}),Le("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.uid,I=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),H=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,j="system-ui, -apple-system, sans-serif";function g(f,s){if(!f||typeof f!="object")return null;const p=H[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:B("mark"),A=Array.isArray(f.points)?f.points:[],k=[];for(const S of A){const R=Number(S&&S.x),O=Number(S&&S.y);Number.isFinite(R)&&Number.isFinite(O)&&k.push({x:R,y:O})}const y=typeof f.colour=="string"&&f.colour?f.colour:s;if(p==="text"){const S=typeof f.text=="string"?f.text:"";if(!k.length||!S)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:S,region:u(f.region)},O=Number(f.fontSize);return Number.isFinite(O)&&O>0&&(R.fontSize=O),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:u(f.region)}}function u(f){return f==="start"||f==="end"?f:"centre"}function h(f){const s={id:f.id,type:z[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(s.region=f.region),f.tool==="text"&&(s.text=f.text,f.fontSize!==void 0&&(s.fontSize=f.fontSize),f.background!==void 0&&(s.background=f.background)),s}const a="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function n(f,s){return{id:f,count:s,valueOf(){return this.count}}}const o=10;function d(f,s,p){const b=p.x-s.x,A=p.y-s.y,k=b*b+A*A;let y=k?((f.x-s.x)*b+(f.y-s.y)*A)/k:0;y=Math.max(0,Math.min(1,y));const S=s.x+y*b,R=s.y+y*A;return Math.hypot(f.x-S,f.y-R)}function l(f){const s=f.points;if(!s.length)return null;if(f.tool==="text"){const y=f.fontSize||w,S=(f.text||"").length*y*.6;return{x1:s[0].x,y1:s[0].y,x2:s[0].x+S,y2:s[0].y+y*1.2}}let p=1/0,b=1/0,A=-1/0,k=-1/0;for(const y of s)p=Math.min(p,y.x),b=Math.min(b,y.y),A=Math.max(A,y.x),k=Math.max(k,y.y);return{x1:p,y1:b,x2:A,y2:k}}function i(f,s){const p=l(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const k=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let S=0;S<4;S++)y=Math.min(y,d(s,k[S],k[(S+1)%4]));return y}if(b.length===1)return Math.hypot(s.x-b[0].x,s.y-b[0].y);let A=1/0;for(let k=0;k<b.length-1;k++)A=Math.min(A,d(s,b[k],b[k+1]));return A}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const p=g(s,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#E(),this.redraw(),this.#M(),n(p.id,this.#s.length)):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),n(null,this.#s.length))}list(){return this.#s.map(h)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${s}".`),!1):(this.#s.splice(p,1),this.#c===s&&(this.#c=null),this.redraw(),this.#M(),!0)}replaceAll(s){const p=Array.isArray(s)?s:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#E(),this.redraw(),this.#M()}#d(){const s=this.#t.viewport?.root;if(!s||!x(s.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#h(s){if(!this.#s.length){this.#$("a11y.annotate.noMarks");return}s.preventDefault?.();const p=this.#c?this.#s.findIndex(k=>k.id===this.#c):-1,b=s.shiftKey?-1:1,A=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[A].id,this.redraw(),this.#$("a11y.annotate.focusedMark",{at:A+1,of:this.#s.length})}#f(s){if(!this.#c)return;s.preventDefault?.();const p=this.#c;this.remove(p),this.#$("a11y.annotate.erased")}#p(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!x(s.matchMedia))return;let p=null;const b=()=>{const A=s.devicePixelRatio||1;let k;try{k=s.matchMedia(`(resolution: ${A}dppx)`)}catch{return}p=k;const y=()=>{this.redraw(),b()};x(k.addEventListener)?k.addEventListener("change",y,{once:!0}):x(k.addListener)&&k.addListener(y)};b(),this.#a.push(()=>{p=null})}use(s,p={}){const b=!!p.colour&&s===this.#o;p.colour&&(this.#i=String(p.colour));const A=s&&W.includes(s)?s:null;this.#o=A&&A===this.#o&&!b?null:A,this.#o!=="erase"&&(this.#c=null);const k=this.#o?this.#E():this.#n;return k&&(k.style.pointerEvents=this.#o?"auto":"none",k.style.cursor=this.#o?"crosshair":""),this.#M(),this.#o}undo(){const s=this.#s.pop();return s&&this.#c===s.id&&(this.#c=null),this.redraw(),this.#M(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#M())}#m(){const s=this.#s.filter(p=>p.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#M())}redraw(){!this.#n&&this.#s.length&&this.#E();const s=this.#n,p=this.#r;if(!s||!p)return;this.#T();const{left:b,top:A}=this.#S();p.clearRect(0,0,s.width,s.height);const k=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const S=k.filter(R=>u(R.region)===y);if(S.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-A||0);for(const R of S)this.#y(p,R),R.id===this.#c&&this.#k(p,R);p.restore()}}}#g(s,p="centre"){const b=this.#n,A=this.#t.viewport?.bodyViewport;if(!x(b?.getBoundingClientRect)||!x(A?.getBoundingClientRect))return;const k=b.getBoundingClientRect(),y=A.getBoundingClientRect();if(!y.width||!y.height)return;const S=this.#b(p,y);S&&(s.beginPath(),s.rect(S.left-k.left,y.top-k.top,S.width,y.height),s.clip())}#b(s,p){const b=O=>{if(!x(O?.getBoundingClientRect))return null;const F=O.getBoundingClientRect();return F&&F.width>0?{left:F.left,width:F.width}:null},A=b(this.#t.viewport?.bodyStart),k=b(this.#t.viewport?.bodyEnd);if(s==="start")return A;if(s==="end")return k;let y=p.left,S=p.left+p.width;const R=p.left+p.width/2;for(const O of[A,k]){if(!O)continue;const F=O.left+O.width;O.left+O.width/2<R?y=Math.max(y,F):S=Math.min(S,O.left)}return S>y?{left:y,width:S-y}:null}#w(s){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!x(b?.getBoundingClientRect))continue;const A=b.getBoundingClientRect();if(A&&A.width>0&&s>=A.left&&s<A.left+A.width)return p}return"centre"}#O(s){const p=this.#t.viewport?.bodyViewport;if(!x(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:s.clientX>=b.left&&s.clientX<=b.right&&s.clientY>=b.top&&s.clientY<=b.bottom}#y(s,p){const b=p.points;if(!b.length)return;const A=this.#e.presentation?.scale||1;s.lineWidth=(r[p.tool]||3)*A,s.strokeStyle=p.colour,s.fillStyle=p.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=p.tool==="highlight"?.32:1;const k=b[0],y=b[b.length-1];if(p.tool==="text"){const S=(p.fontSize||w)*A;s.font=`${S}px ${j}`,s.textBaseline="top";const R=p.text||"";if(p.background){let O=R.length*S*.6;if(typeof s.measureText=="function"){const F=s.measureText(R);F&&Number.isFinite(F.width)&&(O=F.width)}s.fillStyle=p.background,s.fillRect(k.x-S*.15,k.y-S*.1,O+S*.3,S*1.2)}s.fillStyle=p.colour,s.fillText(R,k.x,k.y),s.globalAlpha=1;return}if(p.tool==="rect")s.strokeRect(k.x,k.y,y.x-k.x,y.y-k.y);else if(p.tool==="arrow")s.beginPath(),s.moveTo(k.x,k.y),s.lineTo(y.x,y.y),s.stroke(),this.#A(s,k,y,s.lineWidth);else{s.beginPath(),s.moveTo(k.x,k.y);for(let S=1;S<b.length;S++)s.lineTo(b[S].x,b[S].y);s.stroke()}s.globalAlpha=1}#A(s,p,b,A){const k=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,A*3);s.beginPath(),s.moveTo(b.x,b.y),s.lineTo(b.x-y*Math.cos(k-Math.PI/7),b.y-y*Math.sin(k-Math.PI/7)),s.lineTo(b.x-y*Math.cos(k+Math.PI/7),b.y-y*Math.sin(k+Math.PI/7)),s.closePath(),s.fill()}#k(s,p){const b=l(p);if(!b||!x(s.strokeRect))return;const A=6;s.save(),s.setLineDash?.([4,3]),s.strokeStyle="#1a73e8",s.lineWidth=2,s.globalAlpha=1,s.strokeRect(b.x1-A,b.y1-A,b.x2-b.x1+A*2,b.y2-b.y1+A*2),s.restore()}#C(s,p){const b=this.#e.presentation?.scale||1,A=o*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(u(y.region)===p&&i(y,s)<=A)return y}return null}#S(){const s=x(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(s?.left||0,p),top:s?.top||0}}#E(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,p=s?.ownerDocument;if(!s||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=a,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",s.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#T(),this.#P(b),b}#T(){const s=this.#n,p=this.#t.viewport?.root;if(!s||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),k=s.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*k)),S=Math.max(1,Math.round(b.height*k));s.width===y&&s.height===S||(s.width=y,s.height=S,s.style&&(s.style.width=`${Math.max(1,b.width)}px`,s.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(k,0,0,k,0,0))}#P(s){const p=(S,R="centre")=>{const O=s.getBoundingClientRect(),{left:F,top:E}=this.#S();return{x:S.clientX-O.left+(R==="centre"?F:0),y:S.clientY-O.top+E}},b=S=>{if(!this.#o||!this.#O(S))return;const R=this.#w(S.clientX);if(this.#o==="erase"){const O=this.#C(p(S,R),R);O&&(this.remove(O.id),this.#$("a11y.annotate.erased")),S.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(S,R)],region:R},s.setPointerCapture?.(S.pointerId),S.preventDefault?.()},A=S=>{if(!this.#l)return;const R=p(S,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},k=S=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(S.pointerId),this.redraw(),this.#M())},y=S=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let O=!1;S.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=S.deltaY,O=!0),S.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=S.deltaX,O=!0),O&&S.preventDefault?.()};s.addEventListener("pointerdown",b),s.addEventListener("pointermove",A),s.addEventListener("pointerup",k),s.addEventListener("pointercancel",k),s.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",b),s.removeEventListener("pointermove",A),s.removeEventListener("pointerup",k),s.removeEventListener("pointercancel",k),s.removeEventListener("wheel",y)})}#M(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#N(s,p){const b=this.#e.messages;return b&&x(b.t)?b.t(s,p):s}#$(s,p){this.#t.announce?.(this.#N(s,p),{repeat:!0})}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Le("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(z){if(!Number.isFinite(z)||z<1e3)return"now";const w=Math.round(z/1e3);if(w<60)return`${w}s ago`;const j=Math.round(w/60);return j<60?`${j}m ago`:`${Math.round(j/60)}h ago`}function W(z,w){return Number.isFinite(z)?new Date(z).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class V{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,j=w.depth,g=w.position;this.#r.max=String(Math.max(1,j)),this.#r.value=String(Math.max(0,j-g)),this.#r.disabled=j===0;const u=w.at(),h=w.live;this.#o&&(this.#o.textContent=h?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",h?"true":"false")),this.#i&&(this.#i.textContent=j===0?this.#l("timeline.recording"):W(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",h?"true":"false")}#l(w,j){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,j)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,j=w?.ownerDocument;if(!w||!j?.createElement)return;const g=j.createElement("div");g.className=_;const u=j.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const h=j.createElement("input");h.className=`${_}__range`,h.type="range",h.min="0",h.step="1",h.setAttribute("aria-label",this.#l("timeline.scrub"));const a=j.createElement("span");a.className=`${_}__clock`;const r=j.createElement("button");r.className=`${_}__live`,r.type="button",r.textContent=this.#l("timeline.goLive"),r.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(u),g.appendChild(h),g.appendChild(a),g.appendChild(r),w.appendChild(g),this.#n=g,this.#r=h,this.#o=u,this.#i=a;const t=()=>{const d=this.#e.timeline.depth;this.#e.timeline.seek(d-Number(h.value))};h.addEventListener("input",t);const n=()=>this.#e.timeline.toLive();r.addEventListener("click",n);const o=d=>d.stopPropagation();h.addEventListener("keydown",o),this.#s.push(()=>{h.removeEventListener("input",t),r.removeEventListener("click",n),h.removeEventListener("keydown",o)})}#u(){this.#n&&(x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const H=V}),Le("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",V="lat-cell--commented",H="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const h=[];for(const a of u.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key");if(r){h.push(r);for(const t of a.querySelectorAll("[data-col]")){const n=t.getAttribute("data-col"),o=g.at(r,n),d=!!(o&&o.count);t.classList.toggle(V,d),t.classList.toggle(H,d&&o.unresolved>0),this.#i(t,o,n)}}}(h.length!==this.#r.length||h.some((a,r)=>a!==this.#r[r]))&&(this.#r=h,g.request(h))}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:I).t(g,u)}#i(g,u,h){if(!u||!u.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=u.count,r=u.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",r>0?this.#o("comments.someUnresolved",{comments:t,unresolved:r}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!x(g.addEventListener))return;const u=a=>{const r=this.#e.comments;if(!r||!r.enabled)return;const t=a.target&&x(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,a))return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.stopPropagation(),a.preventDefault(),r.open(o,t.getAttribute("data-col")))},h=a=>{const r=this.#e.comments;if(!r||!r.enabled||!a.altKey||a.key!=="m"&&a.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&x(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.preventDefault(),a.stopPropagation(),r.open(o,t.getAttribute("data-col")))};g.addEventListener("click",u,!0),g.addEventListener("keydown",h,!0),this.#n.push(()=>{g.removeEventListener("click",u,!0),g.removeEventListener("keydown",h,!0)})}#l(g,u){if(!x(g.getBoundingClientRect))return!1;const h=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,h.height*.6));return(X(g)?u.clientX<=h.left+a:u.clientX>=h.right-a)&&u.clientY<=h.top+a}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Le("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,h=>this.#l(u,h)));this.#a(),this.paint()}}#l(g,u){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=u&&u.peer;a&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,u=g?.ownerDocument;if(!g||!u?.createElement)return;const h=this.#e.get("presence")||{},a=u.createElement("span");if(a.className=`${H}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,h.roster===!1)return;const r=u.createElement("div");r.className=H,h.roster&&h.roster.side==="start"&&r.setAttribute("data-side","start"),r.style.pointerEvents="auto",g.appendChild(r),this.#n=r}paint(){const g=this.#e.presence,u=this.#t.viewport?.root;if(!g||!g.enabled||!u?.querySelectorAll)return;this.#d(u);const h=g.peers(),a=[...h].sort((r,t)=>r.at-t.at);for(const r of a)for(const t of r.ranges||[])for(const n of t.rowIds||[])for(const o of t.columns||[])this.#c(u,n,o,r,"range");for(const r of a)r.cursor&&this.#c(u,r.cursor.rowId,r.cursor.colId,r,"cursor");for(const r of a)r.editing&&this.#c(u,r.editing.rowId,r.editing.colId,r,"edit");this.#h(),this.#u(h)}#u(g){if(this.#s!==null)return;const u=g.filter(r=>r.cursorFresh);if(!u.length)return;const a=Math.max(...u.map(r=>r.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,u,h,a,r){const t=g.querySelector(`[data-key="${X(u)}"]`),n=t&&t.querySelector(`[data-col="${X(h)}"]`);n&&(n.setAttribute("data-presence",r),n.style.setProperty("--lat-peer",a.colour),n.setAttribute("data-peer-name",a.name),n.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?n.setAttribute("data-peer-idle","true"):n.removeAttribute("data-peer-idle"),r==="cursor"&&a.cursorFresh&&n.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${h}`))}#d(g){if(this.#o.size){for(const u of g.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of u){const r=g.createElement("button");r.className=`${H}__peer`,r.type="button",r.style.setProperty("--lat-peer",a.colour),r.toggleAttribute("data-idle",!!a.idle),r.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),r.setAttribute("aria-label",this.#f(t,{name:a.name}));const n=g.createElement("span");n.className=`${H}__dot`,n.setAttribute("aria-hidden","true"),n.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),r.appendChild(n);const o=g.createElement("span");o.className=`${H}__name`,o.textContent=a.name,r.appendChild(o),r.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(r)}const h=u.filter(a=>a.hidden).length;if(h){const a=g.createElement("span");a.className=`${H}__hidden`,a.textContent=this.#f("presence.hidden",{count:h}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const u=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(g,u){const h=this.#e;return(h&&h.messages?h.messages:I).t(g,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Le("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function j(a,r){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((r-a)/1e3));if(t<60)return"just now";const n=Math.round(t/60);if(n<60)return`${n}m ago`;const o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function g(a,r,t,n){r.textContent="";const o=String(t??"");if(!n){r.textContent=o;return}const d=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=d.exec(o);for(;i;){i.index>l&&r.appendChild(a.createTextNode(o.slice(l,i.index)));const m=i[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),r.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),r.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),s=m.slice(c+2,-1);if(z.test(s)){const p=a.createElement("a");p.href=s,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",r.appendChild(p)}else r.appendChild(a.createTextNode(f))}l=i.index+m.length,i=d.exec(o)}l<o.length&&r.appendChild(a.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",r=>this.#a(r))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(r){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(r.rowId,r.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&x(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const r=this.#s;this.#s=null,r&&x(r.focus)&&r.focus()}#c(){const r=this.#e.comments.openKey;if(!r)return;const{rowId:t}=V(r);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(r){if(!this.#r)return;const n=this.#r.ownerDocument.createElement("p");n.className=`${H}__note`,n.setAttribute("role","status"),n.textContent=r,this.#r.appendChild(n)}#h(r,t){const n=this.#t.viewport?.root;if(!n||!n.querySelector)return null;const o=n.querySelector(`[data-key="${X(r)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#f(r,t){const n=this.#e;return(n&&n.messages?n.messages:I).t(r,t)}#p(r){const t=r.createElement("div");t.className=H,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const n=r.createElement("header");n.className=`${H}__head`;const o=r.createElement("div");o.className=`${H}__title`,n.appendChild(o);const d=r.createElement("button");d.className=`${H}__resolve`,d.type="button",n.appendChild(d);const l=r.createElement("button");l.className=`${H}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",n.appendChild(l);const i=r.createElement("div");i.className=`${H}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=r.createElement("form");m.className=`${H}__composer`;const c=r.createElement("textarea");c.className=`${H}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=r.createElement("button");f.className=`${H}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(n),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=d;const s=k=>{k.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#b()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},A=k=>{if(k.stopPropagation(),k.key==="Escape"){k.preventDefault(),this.#e.comments.close();return}if(k.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(F=>F.offsetParent!==null||F===c);if(!y.length)return;const S=y[0],R=y[y.length-1],O=t.ownerDocument.activeElement;k.shiftKey&&O===S?(k.preventDefault(),R.focus()):!k.shiftKey&&O===R&&(k.preventDefault(),S.focus())};m.addEventListener("submit",s),l.addEventListener("click",p),d.addEventListener("click",b),t.addEventListener("keydown",A),this.#l.push(()=>{m.removeEventListener("submit",s),l.removeEventListener("click",p),d.removeEventListener("click",b),t.removeEventListener("keydown",A)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const r=this.#e.comments;if(!this.#n||!r.openKey)return;const t=this.#n.ownerDocument,n=this.#e.get("comments")||{},o=Date.now(),d=r.openKey,{rowId:l,field:i}=V(d),m=this.#e.columns.get(i),c=this.#e.rows.byKey(l),f=x(n.rowLabel)&&c?n.rowLabel(c):l;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#b()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",r.loading){this.#d(this.#f("comments.loading"));return}const s=r.thread||[];if(!s.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of s)this.#r.appendChild(this.#O(t,b,o,p,n))}#O(r,t,n,o,d){const l=r.createElement("article");l.className=`${H}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=r.createElement("div");i.className=`${H}__meta`;const m=r.createElement("span");m.className=`${H}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=r.createElement("time");c.className=`${H}__time`;const f=j(t.at,n);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),l.appendChild(i);const s=r.createElement("div");if(s.className=`${H}__body`,g(r,s,t.body,!!d.markdown),l.appendChild(s),t.value!==void 0&&!Object.is(t.value,o)){const A=r.createElement("p");A.className=`${H}__moved`,A.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(A)}const p=t.can||{},b=A=>p[A]!==!1;if(b("edit")||b("delete")){const A=r.createElement("div");if(A.className=`${H}__actions`,b("delete")){const k=r.createElement("button");k.type="button",k.className=`${H}__action`,k.textContent=this.#f("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),A.appendChild(k)}l.appendChild(A)}return l}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:n,field:o}=V(t),d=this.#h(n,o)||this.#i,l=this.#t.viewport?.root;if(!d||!l||!x(d.getBoundingClientRect))return;const i=d.getBoundingClientRect(),m=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let s=i.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const r of this.#l)r();this.#l=[],this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const h=u}),Le("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V="lat-watermark",H="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class j{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(h){this.#e=h.grid,this.#t=h.document,this.#n=h.element,this.#i=h.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),x(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const h=this.#e.licence&&this.#e.licence.ready;h&&x(h.then)&&h.then(()=>this.refresh(),()=>this.refresh())}refresh(){const h=this.#d();h&&!this.#r?(this.#h(),this.#u()):!h&&this.#r&&(this.#f(),this.#c())}#a(){const h=this.#i;if(!h||!x(h.matchMedia))return!1;try{return!!h.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),x(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%z.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const h=this.#e.licence;return!!(h&&x(h.watermark)&&h.watermark())}#h(){const h=this.grid&&this.grid.messages?this.grid.messages:I,a=X(this.#t,"a",{class:`${V}__link`,text:h.t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}}),r=X(this.#t,"span",{class:`${V}__free`,text:h.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${V} ${V}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,r]}),this.#o.push(W(this.#r,"pointerdown",t=>{x(t.stopPropagation)&&t.stopPropagation()})),this.#n&&x(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const h of this.#o)h();this.#o=[],this.#f()}}const g=j}),Le("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isFunction,I=K("packages/dom/src/editors/common.js"),_=I.el,X=I.on,V=K("packages/dom/src/themeof.js").themeOf,H="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},w="lat-maximised-host",j="lat-maximise-placeholder";class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(a){this.#e=a.element,this.#t=a.document,this.#n=B(a.onChange)?a.onChange:null,this.#r=B(a.captureScroll)?a.captureScroll:null,this.#o=B(a.restoreScroll)?a.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const a=this.#e.parentNode;if(!a||!this.#t.body)return x("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:j}),this.#i.style.visibility="hidden";const r=this.#e.offsetWidth,t=this.#e.offsetHeight;r&&(this.#i.style.width=`${r}px`),t&&(this.#i.style.height=`${t}px`);const n=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(a):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),a.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[d,l]of Object.entries(z))this.#a[d]=this.#e.style[d]||"",this.#e.style[d]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(w),n&&this.#o&&this.#o(n),this.#s=X(this.#t,"keydown",d=>this.#h(d)),this.#f(),!0}exit(){if(!this.active())return!1;const a=this.#r?this.#r():null,r=this.#i,t=r.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,r)),B(r.remove)&&r.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[n,o]of Object.entries(this.#a))this.#e.style[n]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(w),a&&this.#o&&this.#o(a),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(a){const r=this.#t.activeElement,t=r&&r!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(r)?r:null;a(),t&&B(t.focus)&&t.focus()}#h(a){!a||a.key!=="Escape"||a.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const a of this.#l)a(this.active())}watch(a){return B(a)?(this.#l.add(a),()=>this.#l.delete(a)):()=>{}}destroy(){this.exit()}}const u=g}),Le("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,j=z.promptText,g=K("packages/core/src/ai/intent.js"),u=g.applyPlan,h=g.buildPrompt,a=g.planIntent,r="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#O=!1;#y=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||W,this.#e=x(l),this.#t=l.grid||null,this.#n=H(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:H(l.onPlan)?l.onPlan:null,onApply:H(l.onApply)?l.onApply:null,onError:H(l.onError)?l.onError:null},this.#s=B(this.#e,"div",{class:r,attrs:{"data-state":"idle",role:"search"}}),this.#A(l)}element(){return this.#s}refresh(){this.#O||!this.#s||this.#b!=="busy"&&this.#E()}destroy(){this.#O=!0,this.#w++;for(const l of this.#y)l();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#O||this.#b==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#P("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#w;this.#k("busy"),this.#T("Thinking…");let c;try{const f=w(this.#t,this.#r),s=j(f);if(c=await this.#n({prompt:i,schema:f,schemaText:s,message:h(i,s),context:this.#o}),this.#O||m!==this.#w)return null;const p=a(c,f);return this.#C(p),p}catch(f){return this.#O||m!==this.#w||(this.#i.onError&&this.#i.onError(f),this.#P(f instanceof Error?f.message:String(f))),null}}apply(){const l=this.#g;if(this.#O||!l||!l.ok)return null;const i=this.#t?.ai,m=H(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(m,l),this.#E(),this.#l&&(this.#l.value=""),m.failed.length?this.#P(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#T(`Applied: ${l.describe()}`),m}discard(){this.#O||(this.#E(),this.#T("Discarded."))}#A(l){const i=this.#e,m=B(i,"div",{class:`${r}__row`});this.#l=B(i,"input",{class:`${r}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(I(this.#l,"keydown",f=>{const s=f&&f.key;s==="Enter"?(H(f.preventDefault)&&f.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(H(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(i,"button",{class:`${r}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(i,"div",{class:`${r}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${r}__summary`}),this.#d=B(i,"ul",{class:`${r}__notes`});const c=B(i,"div",{class:`${r}__buttons`});this.#h=B(i,"button",{class:`${r}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=B(i,"button",{class:`${r}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(I(this.#h,"click",()=>{this.apply()})),this.#y.push(I(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${r}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${r}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(l){if(this.#b=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";n(this.#l,i),n(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#C(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#P(`I could not turn that into a change: ${m}`);return}this.#g=l,this.#T(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#k("preview")}#S(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const m of l.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${r}__note`,text:m.reason}));l.length>6&&i.appendChild(B(this.#e,"li",{class:`${r}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#T(l){this.#p&&(this.#p.textContent=l)}#P(l){this.#g=null,this.#T(""),this.#m&&(this.#m.textContent=l),this.#k("error")}}function n(d,l){d&&(d.disabled=l,l?d.setAttribute("disabled",""):d.removeAttribute("disabled"))}function o(d,l){d&&(d.hidden=l,l?d.setAttribute("hidden",""):d.removeAttribute("hidden"))}}),Le("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.isObject,I=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,V=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,j=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",h=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),a=Object.freeze({direction:"flat",change:null,percent:null});function r(s,p){if(!Number.isFinite(s)||!Number.isFinite(p))return a;const b=s-p,A=b>0?"up":b<0?"down":"flat",k=p===0?null:b/Math.abs(p)*100;return{direction:A,change:b,percent:k}}function t(s,p){return s==="flat"||p==="neither"?"flat":s===p?"good":"bad"}function n(s,p,b=null){if(x(p)){const O=p(s,b);return O==="good"||O==="warn"||O==="bad"?O:null}if(!B(p))return null;const A=typeof s=="number"&&Number.isFinite(s)?s:null;if(A===null)return null;const k=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,S=String(p.direction||"up")==="down",R=O=>S?A<=O:A>=O;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function o(s){return!(x(s.value)||s.value!==void 0&&!B(s.value))}function d(s){return!s||!s.rows||!x(s.rows.totalCount)?!0:s.rows.totalCount()>0}function l(s){const p=B(s)?s:{},b=p.grid||null,A=c(p.container,b);if(!A)return I("stat.container","createStat needs a `container`: an element or a selector."),f();const k=A.ownerDocument||(typeof document>"u"?null:document);if(!k)return I("stat.document","createStat needs a document; it draws DOM."),f();const y=k.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const S=k.createElement("div");S.className=g.title;const R=k.createElement("div");R.className=g.value;const O=k.createElement("div");O.className=g.interval;const F=k.createElement("div");F.className=g.delta;const E=k.createElement("div");E.className=g.footer;const T=k.createElement("div");if(T.className=g.note,T.hidden=!0,p.icon!=null&&p.icon!==""){const ee=k.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),j(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(S),ne.appendChild(R),ne.appendChild(T),ne.appendChild(O),ne.appendChild(F),ne.appendChild(E),y.appendChild(ne)}else y.appendChild(S),y.appendChild(R),y.appendChild(T),y.appendChild(O),y.appendChild(F),y.appendChild(E);A.appendChild(y);let C=null;const D=[];let $=!1;function P(){if(x(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const ee=B(p.value)?p.value:p,ne=ee.of,ie=ee.fn||"sum",se=ee.show;return b?ie==="count"?N().length:ne?se?G(String(ne),String(ie),String(se)):v()==="filtered"&&b.statistics&&x(b.statistics.reduce)?b.statistics.reduce(String(ne),String(ie)):X(N().map(he=>m(he,String(ne))),String(ie)):null:null}function v(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const ee=v();if(ee==="all"){const ie=[];return x(b.rows.forEachAll)&&b.rows.forEachAll(se=>{se.group||ie.push(i(se))}),ie}if(ee==="selected")return(b.selection&&x(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const ne=[];return x(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||ne.push(i(ie))}),ne}function G(ee,ne,ie){if(ne!=="min"&&ne!=="max")return I(`stat.show.${ne}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ne}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,he=null;for(const ce of N()){const te=Number(m(ce,ee));Number.isFinite(te)&&(se===null||(ne==="max"?te>se:te<se))&&(se=te,he=ce)}return he===null?null:m(he,ie)}function q(ee){if(x(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const ne=B(p.value)?p.value:p,ie=ne.show||ne.of;if((ne.show?!0:h.has(String(ne.fn||"sum")))&&b&&ie&&x(b.columns?.get)){const he=b.columns.get(String(ie));if(he&&x(he.formatValue))return he.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Z(ee){return ee?(b&&b.messages||z).t(`stat.tone.${ee}`):""}function J(){if($)return;const ee=P(),ne=o(p)&&!!b&&!d(b),ie=ne?null:ee,se=x(p.baseline)?p.baseline(b):p.baseline;C=ie,S.textContent=p.title??"",S.hidden=!p.title,R.textContent=q(ie),T.hidden=!ne,ne&&(T.textContent=b.messages.t("stat.noData"));const he=ne||se===void 0||se===null?a:r(typeof ie=="number"?ie:null,Number(se)),ce=t(he.direction,p.goodWhen||"up");if(F.hidden=he.change===null,he.change!==null){const de=he.direction==="up"?"↑":he.direction==="down"?"↓":"→",we=he.percent===null?q(Math.abs(he.change)):`${Math.abs(he.percent).toFixed(1)}%`;F.textContent=`${de} ${we}`,F.setAttribute("data-tone",ce),F.setAttribute("data-direction",he.direction)}const te=x(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);O.hidden=!oe,oe&&(O.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&O.setAttribute("title",`${Math.round(te.confidence*100)}%`));const fe=ne?u:p.bands?n(ie,p.bands,b):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),E.textContent=x(p.footer)?String(p.footer(ie,b)):p.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?T.textContent:"",oe?O.textContent:"",he.change===null?"":F.textContent,he.change===null?"":Z(ce),E.textContent].filter(Boolean).join(", "))}if(b&&x(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=ie=>{ee==="model:changed"&&!V(ie)||J()};b.on(ee,ne),D.push(()=>x(b.off)&&b.off(ee,ne))}return J(),{element:()=>y,value:()=>C,refresh:J,destroy(){$=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(s){return B(s)&&"data"in s?s.data:s}function m(s,p){if(!B(s))return;if(!p.includes("."))return s[p];let b=s;for(const A of p.split(".")){if(!B(b))return;b=b[A]}return b}function c(s,p){if(s&&typeof s=="object")return s;if(typeof s!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(s):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Le("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isObject,I=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:H,kpis:z}){this.#e=V,this.#t=H,this.#n=Array.isArray(z)?z.filter(x):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${_.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const z of this.#n){const w=I({...z,grid:this.#e,container:H});this.#o.push(w)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Le("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const x=K("packages/core/src/index.js").createHeadlessGrid,I=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),V=W.fail,H=W.isFunction,z=W.warnOnce,j=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,r=K("packages/dom/src/cell/icons.js"),t=r.icon,n=r.iconNames,d=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,s=m.Pagination,p=m.GroupByZone,A=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,F=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,C=K("packages/dom/src/alignedgrids.js").AlignedGrids,$=K("packages/dom/src/columntagbar.js").ColumnTagBar,v=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Z=q.ToolPanelDock,J=q.panelHost,ne=K("packages/dom/src/celledit.js").CellEditController,se=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Te=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,be=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Oe=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,st=K("packages/dom/src/validationpaint.js").ValidationPainter,yt=K("packages/dom/src/presentation.js").PresentationController,Ct=K("packages/dom/src/capture.js").captureElement,Et=K("packages/dom/src/annotate.js").AnnotationLayer,It=K("packages/dom/src/timelinebar.js").TimelineBar,nt=K("packages/dom/src/commentpaint.js").CommentPainter,ve=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,ke=K("packages/dom/src/maximise.js").Maximiser,je=K("packages/dom/src/promptbar.js").PromptBar,ze=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(Ve,pt,ct){const ot=pt==="redo"?"toolbar.redo":"toolbar.undo";return!ct||!ct.label?Ve(ot):Ve(pt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:ct.label})}const De=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Se=2e3;function xe(Ve,pt,ct,ot){const St=pt.annotate===!0?Be(Ve,ot):[];if(pt.actions===!1)return[];if(pt.actions===void 0&&pt.side!=="left")return St;const At=Array.isArray(pt.actions)?pt.actions:De,ft=(Dt,_t)=>Ve.messages.t(Dt,_t),Nt={undo:{name:"undo",title:()=>_e(ft,"undo",Ve.history.peek("undo")),icon:"undo",run:()=>Ve.history.undo(),enabled:()=>Ve.history.canUndo()},redo:{name:"redo",title:()=>_e(ft,"redo",Ve.history.peek("redo")),icon:"redo",run:()=>Ve.history.redo(),enabled:()=>Ve.history.canRedo()},export:{name:"export",title:()=>ft("toolbar.exportCsv"),icon:"download",run:()=>Ve.export.csv({download:!0,fileName:pt.exportName})},excel:{name:"excel",title:()=>ft("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ve.export.excel({download:!0,fileName:pt.exportName})},clipboard:{name:"clipboard",title:()=>ft("toolbar.clipboard"),icon:"copy",run:()=>Ve.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>ft("toolbar.print"),icon:"print",run:()=>Ve.export.print()},pause:{name:"pause",title:()=>{if(!Ve.updates.paused)return ft("toolbar.pause");const Dt=Ve.updates.stats().pending;return Dt?ft("toolbar.applyHeld",{count:Dt}):ft("toolbar.resume")},icon:()=>Ve.updates.paused?"play":"pause",run:()=>Ve.updates.paused?Ve.updates.resume():Ve.updates.pause()},restore:{name:"restore",title:()=>ft("toolbar.restoreView"),icon:"restore",run:()=>Ve.state.reset(),enabled:()=>Ve.state.modified()},maximise:{name:"maximise",title:()=>ft(ct&&ct.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>ct&&ct.active()?"minimise":"maximise",run:()=>ct.toggle()}};return ct||delete Nt.maximise,At.map(Dt=>Dt==="-"?{name:"-",separator:!0}:typeof Dt=="string"?Nt[Dt]:!Dt||typeof Dt!="object"||!Dt.name?null:{...Dt,run:H(Dt.run)?()=>Dt.run({grid:Ve,keys:Ve.selection&&H(Ve.selection.keys)?Ve.selection.keys():[],cells:Ve.selection&&H(Ve.selection.cells)?Ve.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Be(Ve,pt){const ct={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ot=(At,ft)=>Ve.messages.t(At,ft),St=["pen","arrow","rect","highlight","erase"].map(At=>({name:At,title:()=>ot(`toolbar.annotate.${At}`),icon:ct[At],run:()=>Ve.annotate?.use(At),active:()=>Ve.annotate?.tool===At,annotation:!0}));return St.push(Je(Ve,ot,pt)),St}function Je(Ve,pt,ct){return{name:"clearAll",title:()=>pt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ve.annotate?.count||0)>0,annotation:!0,run:()=>Qe(Ve,pt,ct)}}function Qe(Ve,pt,ct){const ot=Ve.toolPanel;if(!ot)return;const St=ft=>ct?.announce?.(pt(ft),{repeat:!0});ot.removeAction("clearAll");const At=()=>{ot.removeAction("clearAllConfirm"),ot.removeAction("clearAllKeep"),ot.addAction(Je(Ve,pt,ct))};ot.addAction({name:"clearAllConfirm",title:()=>pt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ve.annotate?.clear(),At(),St("a11y.annotate.cleared")}}),ot.addAction({name:"clearAllKeep",title:()=>pt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>At()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function it(Ve){let pt=null,ct=null;return Ve.on("source:error",ot=>{const St=ot&&ot.error;ct=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(Ve.messages?Ve.messages.t("overlay.error"):"Something went wrong")}),Ve.on("rows:changed",()=>{ct=null}),{loadError:()=>ct,rowCount:()=>{if(H(Ve.rows.matchCount))return Ve.rows.matchCount();const ot=Ve.pagination&&H(Ve.pagination.get)?Ve.pagination.get():null;return ot&&Number.isFinite(ot.total)?ot.total:Ve.rows.count()},totalRowCount:()=>H(Ve.rows.totalCount)?Ve.rows.totalCount():Ve.rows.count(),selectedAcrossSource:()=>{pt||(pt=H(Ve.rendererHost)?Ve.rendererHost():{});const ot=H(pt.selectionSummary)?pt.selectionSummary():null;return ot&&ot.predicate?{count:ot.count}:null},selectedCount:()=>{const ot=Ve.selection&&Ve.selection.keys?Ve.selection.keys():null;return ot?ot.length:0},rangeValues:()=>{const ot=Ve.selection;return!ot||!H(ot.cells)?[]:ot.cells().map(({key:St,colId:At})=>Ve.rows.value(St,At))},hiddenUnresolved:()=>H(Ve.comments&&Ve.comments.hiddenUnresolved)?Ve.comments.hiddenUnresolved():0,progress:()=>H(Ve.source&&Ve.source.progress)?Ve.source.progress():null,updateStats:()=>Ve.updates?Ve.updates.stats():null}}function gt(Ve,pt){for(const[ct,ot]of Object.entries(d||{}))Ve.register("editor",ct,ot);for(const[ct,ot]of Object.entries(i||{}))Ve.register("filter",ct,ot);for(const[ct,ot]of Object.entries(pt.components||{}))Ve.register("component",ct,ot);for(const[ct,ot]of Object.entries(pt.pipes||{}))Ve.register("pipe",ct,ot);for(const[ct,ot]of Object.entries(pt.totalFns||{}))Ve.register("totalFn",ct,ot)}function wt(Ve,pt,ct,ot,St,At){const ft=[],Nt=pt.viewport;let Dt=null;if(ct.maximise!==!1&&(Dt=new ke({element:At,document:ot,onChange:()=>pt.invalidate("all"),captureScroll:()=>pt.scrollState(),restoreScroll:lt=>pt.restoreScroll(lt)}),Ve.maximise=Dt,ft.push(()=>Dt.destroy())),ct.statusBar){const lt=typeof ct.statusBar=="object"?ct.statusBar:{},vt=new c;vt.init({document:ot,host:it(Ve),panels:lt.panels,registry:lt.registry,locale:Ve.get("locale"),messages:Ve.messages}),Nt.statusBar.appendChild(vt.element());const Rt=()=>{const on=Nt.statusBar.offsetHeight||Nt.statusBar.getBoundingClientRect?.().height||0;Nt.root.style.setProperty("--lattice-status-height",`${Math.ceil(on)}px`)},Ht=()=>{vt.refresh(),Rt()},Gt=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(on=>Ve.on(on,Ht));Ht(),Rt(),ft.push(()=>{for(const on of Gt)on();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const _t=oe(ct.selection);if(_t.ranges){const lt=new ce({grid:Ve,renderer:pt,document:ot});lt.mount(),Ve.ranges=lt,ft.push(()=>lt.destroy())}if(ct.import){const lt=new de({grid:Ve,renderer:pt,document:ot,settings:typeof ct.import=="object"?ct.import:{}});Ve.importer=lt,ft.push(()=>lt.destroy())}if(ct.historyBar){const lt=typeof ct.historyBar=="object"?ct.historyBar.element:null,vt=new Te;vt.init({document:ot,host:{undo:()=>Ve.history.undo(),redo:()=>Ve.history.redo(),canUndo:()=>Ve.history.canUndo(),canRedo:()=>Ve.history.canRedo(),peek:Ht=>Ve.history.peek(Ht),list:()=>Ve.history.list()},props:typeof ct.historyBar=="object"?ct.historyBar:{}}),(lt||Nt.root).appendChild(vt.element());const Rt=[Ve.on("history:changed",()=>vt.refresh())];Ve.historyBar=vt,ft.push(()=>{for(const Ht of Rt)Ht();vt.destroy()})}if(ct.diff){const lt=new Ce({grid:Ve,renderer:pt});lt.mount(),Ve.diffPainter=lt,ft.push(()=>lt.destroy())}if(ct.ai&&H(ct.ai.ask)){const lt=new je;lt.init({document:ot,grid:Ve,ask:ct.ai.ask,schemaOptions:ct.ai.schemaOptions,context:ct.ai.context,placeholder:ct.ai.placeholder});const vt=ct.ai.element||Nt.root;vt===Nt.root?vt.insertBefore(lt.element(),vt.firstChild):vt.appendChild(lt.element()),Ve.promptBar=lt,ft.push(()=>lt.destroy())}if(ct.groupPanel){const lt=typeof ct.groupPanel=="object"?ct.groupPanel:{},vt=new p;vt.init({document:ot,grid:Ve,host:J(Ve,ot,(Rt,Ht)=>pt.announce?.(Rt,Ht)),props:{header:Nt.header,hint:lt.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),Ve.groupPanel=vt;for(const Rt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ve.on)&&ft.push(Ve.on(Rt,()=>vt.refresh()));ft.push(()=>vt.destroy())}if(ct.kpis){const lt=new ze({grid:Ve,document:ot,kpis:ct.kpis});lt.active&&(lt.mount(),Nt.root.insertBefore(lt.element(),Nt.header),Ve.kpiStrip=lt,ft.push(()=>lt.destroy()))}if(ct.toolPanel){const lt=typeof ct.toolPanel=="object"?ct.toolPanel:{},vt=new Z({grid:Ve,document:ot,root:Nt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:xe(Ve,lt,Dt,pt),announce:(Rt,Ht)=>pt.announce?.(Rt,Ht)});vt.mount(),Ve.toolPanel=vt,ft.push(()=>vt.destroy()),lt.annotate===void 0&&(ft.push(Ve.on("presentation:started",()=>{for(const Rt of Be(Ve,pt))vt.addAction(Rt)})),ft.push(Ve.on("presentation:ended",()=>{for(const Rt of at)vt.removeAction(Rt)})))}if(!!ct.pagination&&(()=>{const lt=typeof ct.pagination=="object"?ct.pagination:{};return Ve.pagination.set({pageSize:Number(lt.pageSize)||100}),Ve.pagination.get().pageSize>0})()){const lt=typeof ct.pagination=="object"?ct.pagination:{},vt=new s;vt.init({document:ot,pageSize:lt.pageSize,pageSizes:lt.pageSizes,page:lt.page,total:lt.total,locale:Ve.get("locale"),messages:Ve.messages,onChange:({page:Gt,pageSize:on})=>Ve.pagination.set({page:Gt,pageSize:on})});const Rt=()=>{const Gt=Ve.pagination.get();vt.total=Gt.total,vt.counting=Gt.counting===!0,vt.hasMore=Gt.total==null&&Gt.pageCount>Gt.page+1,vt.page=Gt.page,vt.paint()};Ve.pagination.set({pageSize:vt.pageSize}),Rt();const Ht=["rows:changed","filter:changed","model:changed"].map(Gt=>Ve.on(Gt,Rt));Nt.statusBar.appendChild(vt.element()),ft.push(()=>{for(const Gt of Ht)Gt();vt.destroy?.()})}if(ct.edit!==!1)if(ct.editBar){const lt=new se({grid:Ve,document:ot,root:Nt.root});lt.mount(),Ve.editBar=lt,ft.push(()=>lt.destroy())}else{const lt=new ne({grid:Ve,document:ot,renderer:pt,registry:St,cellLayer:pt.cellLayer});lt.mount(),ft.push(()=>lt.destroy())}const cn=new y({grid:Ve,document:ot,layer:Nt.overlays,registry:St});cn.mount(),ft.push(()=>cn.destroy());const qt=new R({grid:Ve,document:ot,host:Nt.root,cellMenu:ct.contextMenu!==!1,headerMenu:ct.columnMenu!==!1,items:H(ct.contextMenu)?ct.contextMenu:void 0,headerItems:H(ct.columnMenu)?ct.columnMenu:void 0});if(qt.mount(),ft.push(()=>qt.destroy()),Array.isArray(ct.alignedGrids)&&ct.alignedGrids.length){const lt=new C;lt.add(Ve);for(const vt of ct.alignedGrids)vt&&vt!==Ve&<.add(vt);ft.push(()=>lt.destroy())}const Wt=new G({grid:Ve,renderer:pt,document:ot,registry:St});Wt.active&&(Wt.mount(),ft.push(()=>Wt.destroy())),Object.defineProperty(Ve,"form",{configurable:!0,value:Object.freeze({open(lt){return Wt.active?Wt.openRow(lt):!1},openNew(lt){return Wt.active?Wt.openNew(lt):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){Wt.active&&Wt.close()},save(){return Wt.active?Wt.save():!1},isOpen(){return Wt.active?Wt.open:!1}})}),ft.push(()=>{delete Ve.form}),Object.defineProperty(Ve,"icons",{configurable:!0,value:Object.freeze({get(lt){const vt=t(lt);return vt?{viewBox:vt.viewBox,paths:vt.paths.slice(),paint:vt.paint==="stroke"?"stroke":"fill"}:null},names(){return n()}})}),ft.push(()=>{delete Ve.icons});const Mt=new $({grid:Ve,renderer:pt,document:ot});Mt.active&&(Mt.mount(),ft.push(()=>Mt.destroy()));const xt=new v({grid:Ve,renderer:pt,document:ot});xt.active&&(xt.mount(),ft.push(()=>xt.destroy()));const Bt=new T({grid:Ve,renderer:pt,document:ot});if(Bt.active){Bt.mount(),Bt.paint();const lt=Ve.on("render:done",()=>Bt.paint());ft.push(()=>{lt(),Bt.destroy()})}if(ct.shortcuts!==!1){const lt=new F({grid:Ve,renderer:pt});lt.mount(),ft.push(()=>lt.destroy())}const Kt=new Ne({grid:Ve,renderer:pt,window:ot.defaultView||void 0});Kt.mount(),ft.push(()=>Kt.destroy());const Qt=new He({grid:Ve,renderer:pt,window:ot.defaultView||void 0});if(Qt.mount(),ft.push(()=>Qt.destroy()),ct.find!==!1){const lt=new Oe({grid:Ve,renderer:pt,document:ot,settings:ct.find});lt.mount(),ft.push(()=>lt.destroy())}const Yt=new Ze({grid:Ve,renderer:pt});Yt.mount(),ft.push(()=>Yt.destroy());const Jt=new st({grid:Ve,renderer:pt});Jt.mount(),ft.push(()=>Jt.destroy());const nn=new yt({grid:Ve,renderer:pt,maximiser:Dt});nn.mount(),ft.push(()=>nn.destroy());const en=new It({grid:Ve,renderer:pt});en.mount(),ft.push(()=>en.destroy()),ct.environment||Ve.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let un=null;for(const[lt,vt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ft.push(Ve.on(lt,()=>{un=vt}));ft.push(Ve.on("render:done",lt=>{Ve.diagnostics.render(un||lt.cause,lt.phases),un=null}));const an=ot.defaultView;if(an&&H(an.requestAnimationFrame)){let lt=an.requestAnimationFrame(function vt(Rt){Ve.diagnostics.frame(Rt),lt=an.requestAnimationFrame(vt)});ft.push(()=>{H(an.cancelAnimationFrame)&&an.cancelAnimationFrame(lt)})}const gn=new ve({grid:Ve,renderer:pt});if(gn.mount(),ft.push(()=>gn.destroy()),ft.push(Ve.on("presence:lockRefused",lt=>gn.announceRefusal(lt.peer))),Ve.presence&&Ve.presence.enabled){for(const Rt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ft.push(Ve.on(Rt,()=>Ve.presence.publish()));let lt="";ft.push(Ve.on("render:done",()=>{const Rt=pt.focusState&&pt.focusState(),Ht=Rt?`${Rt.rowKey}${Rt.colId}`:"";Ht!==lt&&(lt=Ht,Ve.presence.publish())}));const vt=At.ownerDocument;if(vt&&H(vt.addEventListener)){const Rt=()=>Ve.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Rt),Rt(),ft.push(()=>vt.removeEventListener("visibilitychange",Rt))}}const yn=new nt({grid:Ve,renderer:pt});yn.mount(),ft.push(()=>yn.destroy());const bn=new We({grid:Ve,renderer:pt});bn.mount(),ft.push(()=>bn.destroy()),ft.push(Ve.on("facet:computed",()=>pt.refreshHeader?.())),_t&&_t.headerCheckbox===!0&&ft.push(Ve.on("selection:changed",()=>pt.refreshHeader?.())),ft.push(Ve.on("facet:expanded",()=>pt.invalidate("columns"))),ft.push(Ve.on("model:changed",()=>pt.invalidate("rows")));const Zt=(lt,vt)=>pt.announce?.(lt,vt),dn=Ve.messages,Vt=(lt,vt)=>dn.t(lt,vt),mn=lt=>Vt("count.rows",{count:lt});ft.push(Ve.on("sort:changed",()=>{const lt=Ve.sort.get();if(!lt.length){Zt(Vt("a11y.sort.cleared"));return}const vt=lt.map(Rt=>{const Ht=Ve.columns.get(Rt.col);return Vt("a11y.sort.column",{column:Ht&&Ht.title||Rt.col,direction:Vt(Rt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Vt("a11y.sort.by",{columns:dn.list(vt)}))})),ft.push(Ve.on("filter:changed",()=>{const lt=Ve.rows.matchCount?Ve.rows.matchCount():Ve.rows.count();if(lt===null)return;const vt=Ve.rows.totalCount?Ve.rows.totalCount():lt;Zt(lt===vt?Vt("a11y.filter.cleared",{rows:mn(vt)}):Vt("a11y.filter.applied",{shown:mn(lt),total:mn(vt)}))})),ft.push(Ve.on("selection:changed",()=>{const lt=Ve.selection.keys().length;Zt(lt===0?Vt("a11y.selection.cleared"):Vt("a11y.selection.count",{count:lt}))})),ft.push(Ve.on("group:toggled",lt=>{const vt=Ve.rows.byKey?Ve.rows.byKey(lt.key):null,Rt=(vt&&(vt.groupLabel??vt.groupValue))??lt.key;Zt(Vt(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Rt,rows:mn(Ve.rows.count())}))})),ft.push(Ve.on("column:grouped",lt=>{const vt=Array.isArray(lt.columns)?lt.columns:[];if(!vt.length){Zt(Vt("a11y.group.cleared"));return}const Rt=vt.map(Ht=>{const Gt=Ve.columns.get(Ht);return Gt&&Gt.title||Ht});Zt(Vt("a11y.group.by",{columns:dn.list(Rt)}))})),ft.push(Ve.on("page:changed",lt=>{const vt=Number(lt.size)||0,Rt=Number(lt.total)||0,Ht=vt>0?Math.max(1,Math.ceil(Rt/vt)):1;Zt(Vt("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Ht}))}));let rn={added:0,removed:0},Xt=null;const Fn=()=>{Xt=null;const lt=[];rn.added&<.push(Vt("count.rowsAdded",{count:rn.added})),rn.removed&<.push(Vt("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},lt.length&&Zt(dn.list(lt))};ft.push(Ve.on("rows:changed",lt=>{if(!lt||typeof lt.added!="number")return;const vt=Number(lt.added)||0,Rt=Number(lt.removed)||0;!vt&&!Rt||(rn.added+=vt,rn.removed+=Rt,Xt||(Xt=setTimeout(Fn,Se)))})),ft.push(()=>{Xt&&clearTimeout(Xt)}),ft.push(Ve.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),rn={added:0,removed:0},Zt(Vt("a11y.updates.paused"),{repeat:!0})})),ft.push(Ve.on("rows:resumed",()=>Zt(Vt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},fn=null;const Pn=()=>{fn=null;const{count:lt,first:vt}=hn;if(hn={count:0,first:null},!lt||!vt)return;const Rt=Ve.columns.get(vt.colId),Ht=Rt&&Rt.title||vt.colId,Gt=vt.reason?Vt("a11y.edit.reason",{reason:vt.reason}):"";if(lt===1){const on=vt.restored===void 0||vt.restored===null||vt.restored===""?Vt("value.empty"):String(vt.restored);Zt(Vt("a11y.edit.refusedOne",{column:Ht,value:on,reason:Gt}),{repeat:!0});return}Zt(Vt("a11y.edit.refusedMany",{count:lt,reason:Gt}),{repeat:!0})};ft.push(Ve.on("cell:reverted",lt=>{!lt||!lt.applied||(hn.count+=1,hn.first||(hn.first=lt),fn||(fn=setTimeout(Pn,150)))})),ft.push(()=>{fn&&clearTimeout(fn)}),ft.push(Ve.on("history:applied",lt=>{const vt=!!(lt&<.direction==="redo"),Rt=lt&<.step&<.step.label;Zt(Rt?Vt(vt?"a11y.history.redo":"a11y.history.undo",{label:Rt}):Vt(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Et({grid:Ve,renderer:pt,seed:ct.state&&Array.isArray(ct.state.annotations)?ct.state.annotations:null});wn.mount(),ft.push(()=>wn.destroy()),Ve.annotate=wn,Ve.capture=async(lt={})=>{const{blob:vt,width:Rt,height:Ht}=await Ct(pt.viewport.root,lt);return(lt.download===!0||lt.download!==!1&<.fileName)&&X(vt,lt.fileName||`${Ve.get("exportName")||"grid"}.png`),Ve.emit("presentation:captured",{width:Rt,height:Ht,bytes:vt.size,mimeType:vt.type,fileName:lt.fileName||null},"api"),vt};const Cn=new qe({grid:Ve,document:ot,element:Nt.overlays,window:ot.defaultView||void 0});Cn.mount(),ft.push(()=>Cn.destroy());const xn=new f({grid:Ve,document:ot,element:Nt.overlays});xn.mount?.(),ft.push(()=>xn.destroy?.());const En=new A({grid:Ve,host:Ve.rendererHost(),viewport:Nt,document:ot});return En.mount(),ft.push(()=>En.destroy()),ft}function dt(Ve){const pt=[],ct=ot=>{if(ot&&(ot.__lattice&&pt.push(ot),ot.children))for(const St of ot.children)ct(St)};return ct(Ve),pt}function jt(Ve,pt={}){(!Ve||typeof Ve!="object"||!("appendChild"in Ve))&&V("createGrid needs a host element as its first argument."),pt=I(pt);const ct=Ve.ownerDocument||(typeof document<"u"?document:null);ct||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ot=ct.documentElement&&ct.documentElement.lang,St=!pt.licence&&H(ct.querySelector)?ct.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,At={...pt};if(!pt.locale&&ot&&(At.locale=ot),St&&(At.licence=St),pt.views&&pt.views.local)if(pt.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=pt.views.local===!0?{}:pt.views.local;At.views={...pt.views,storage:j(qt)}}const ft=x(At),Nt=ft.rendererHost();Nt.document=ct,gt(Nt.registry,pt),Nt.cellLayer=a(Nt),Nt.detailHost=new be({grid:ft,document:Ve.ownerDocument||globalThis.document,createGrid:(qt,Wt)=>jt(qt,Wt)});const Dt=new u(Ve,Nt),_t=ft.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),pn=ft.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});ft.on("destroy",()=>{_t(),pn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),ft.attachRenderer(Dt),Dt.mount();const sn=wt(ft,Dt,pt,ct,Nt.registry,Ve),cn=ft.destroy.bind(ft);return ft.destroy=()=>{for(const qt of sn)try{qt()}catch{}Ve.__lattice===ft&&(Ve.__lattice=null),cn()},Ve.__lattice=ft,ft}}),Le("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/columns/datatypes.js"),_=I.BUILTIN_TYPES,X=I.parseNumberText,V=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,z=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),j=w.toIsoDate,g=w.toIsoDateTime,h=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(V)]);function r(s,p){for(const b of s.children)if(b.tagName===p.toUpperCase())return b;return null}function t(s,p){const b=[];for(const A of s.children)A.tagName===p.toUpperCase()&&b.push(A);return b}function n(s,p){const b=x(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function o(s){const p=s.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function d(s,p){return p==="text"?s===""?null:s:p==="boolean"?z(s):p==="number"?X(s):p==="date"||p==="dateString"?j(s):p==="datetime"?g(s):o(s)}function l(s){const p=r(s,"thead"),b=r(p||s,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((O,F)=>{const E=n(O,F),T={id:E,field:E,title:String(O.textContent||"").trim()||E},L=x(O.getAttribute)?O.getAttribute("data-type"):null;L&&(a.has(L)?T.type=L:B(`hydrate.unknownType:${L}`,`data-type "${L}" on column "${E}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const C=x(O.getAttribute)?O.getAttribute("data-format"):null;return C&&(T.format=C),T}),y=r(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(O=>O!==b)).map((O,F)=>{const E=t(O,"td"),L={__row:(x(O.getAttribute)?O.getAttribute("data-id"):null)||`row${F}`};return k.forEach((C,D)=>{L[C.field]=E[D]?C.type?d(String(E[D].textContent||""),C.type):o(String(E[D].textContent||"")):null}),L});return{columns:k,rows:R}}function i(s,p){if(p===void 0)return s;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const k of p)if(k&&typeof k=="object"){const y=k.id??k.field;y!=null&&b.set(y,k)}const A=s.map(k=>{const y=b.get(k.id)??b.get(k.field);return y===void 0?k:{...k,...y}});for(const[k,y]of b)s.some(S=>S.id===k||S.field===k)||A.push({...y});return A}const m="data-lattice-hydrate-config";function c(s,p,b={}){const{columns:A,rows:k}=l(p);return h(s,{rowKey:"__row",...b,columns:i(A,b.columns),rows:b.rows!==void 0?b.rows:k})}function f(s,p={}){const b=s.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),s.removeAttribute("data-lattice-grid"),b.__latticeTable=s;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return s.parentNode.insertBefore(b,s),s.parentNode.removeChild(s),c(b,s,p)}}),Le("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,j){const g=[];return x(w.hasAttribute)&&w.hasAttribute(j)&&g.push(w),x(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${j}]`)),g}function V(w){const j=w.parentNode;if(!j||!j.children)return null;const g=[...j.children],u=g.indexOf(w),h=[g[u+1],g[u-1]];for(const a of h)if(a&&a.tagName==="SCRIPT"&&x(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function H(w){const j=V(w);if(!j)return{};try{return JSON.parse(j.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const j=w||(typeof document<"u"?document:null);if(!j)return[];const g=[];for(const u of W(j,"data-lattice-grid")){if(u.__lattice)continue;const h=H(u);g.push(u.tagName==="TABLE"?X(u,h):I(u,h))}return g}}),Le("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q=K("packages/dom/src/createGrid.js"),x=Q.createGrid,B=K("packages/dom/src/hydrate.js"),I=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),V=W.createLocalViewStorage,H=K("packages/core/src/index.js"),z=H.createHeadlessGrid,w=H.registerModules,j=H.setLicence,g=H.version,u=H.getVersion,h=H.serialiseState,a=H.restoreState,r=H.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return H.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return H.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return H.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return H.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return H.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return H.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return H.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return H.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return H.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return H.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return H.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return H.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return H.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return H.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return H.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return H.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return H.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return H.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return H.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return H.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return H.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return H.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return H.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return H.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return H.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return H.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return H.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return H.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return H.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return H.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return H.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return H.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return H.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return H.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return H.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return H.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return H.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return H.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return H.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return H.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return H.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return H.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return H.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return H.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return H.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return H.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return H.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return H.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return H.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return H.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return H.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return H.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return H.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return H.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return H.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return H.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return H.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return H.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return H.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return H.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return H.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return H.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return H.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return H.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return H.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return H.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return H.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return H.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return H.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return H.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return H.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return H.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return H.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return H.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return H.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return H.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return H.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return H.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return H.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return H.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return H.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return H.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return H.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return H.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return H.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return H.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return H.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return H.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return H.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return H.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return H.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return H.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return H.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return H.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return H.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return H.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return H.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return H.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return H.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return H.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return H.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return H.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return H.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return H.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return H.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return H.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return H.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return H.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return H.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return H.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return H.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return H.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return H.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return H.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return H.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return H.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return H.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return H.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return H.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return H.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return H.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return H.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return H.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return H.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return H.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return H.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return H.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return H.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return H.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return H.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return H.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return H.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return H.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return H.VERSION}});const n=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return n.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const d=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return d.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return d.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return d.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const s=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return s.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const A=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return A.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return A.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return A.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return A.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return A.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return A.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return A.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return A.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return A.sanitiseHtml}});const k=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return k.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return k.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return k.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return k.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const S=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return S.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return S.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return S.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return S.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return S.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const O=Object.freeze({createGrid:x,createHeadlessGrid:z,defaults:r,registerModules:w,setLicence:j,version:g,autoInit:X,hydrateTable:I,serialiseState:h,restoreState:a,createLocalViewStorage:V}),F=O});try{Rn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.88.2";async function he(){return ae}const W="1.88.2",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-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 h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=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.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"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"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=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",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 q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("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 t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var Ln=Rn("packages/dom/src/index.js");typeof module=="object"&&module.exports?module.exports=Ln:typeof define=="function"&&define.amd?define(function(){return Ln}):fr.LatticeGrid=Ln})(typeof globalThis<"u"?globalThis:this);
|
|
57
|
+
`)||(i.preventDefault(),this.fromText(m))})))}openFile(){const l=j(this.#n,"input",{attrs:{type:"file",accept:n}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(x(l.arrayBuffer)){l.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(x(l.text)){l.text().then(m=>this.fromText(m,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:m,rows:c}=await H(l);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(l,i){const{header:m,rows:c,delimiter:f}=X(l);if(!m.length)return;const s=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:s,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&x(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,i){const m=this.#t&&this.#t.announce;x(m)&&m.call(this.#t,l,i)}#f(l,i){return(this.#e&&this.#e.messages?this.#e.messages:I).t(l,i)}#p(){const l=this.#n,i=j(l,"div",{class:r,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=j(l,"div",{class:`${r}__panel`});m.appendChild(j(l,"h2",{class:`${r}__title`,text:this.#f("import.title")})),this.#s=j(l,"div",{class:`${r}__body`}),m.appendChild(this.#s);const c=j(l,"div",{class:`${r}__footer`}),f=j(l,"button",{class:`${r}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),s=j(l,"button",{class:`${r}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(f,"click",()=>this.close())),this.#o.push(u(s,"click",()=>this.#g())),c.appendChild(f),c.appendChild(s),m.appendChild(c),i.appendChild(m),this.#o.push(u(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const A=[...i.querySelectorAll(t)].filter(S=>!S.hidden);if(!A.length)return;const k=A[0],y=A[A.length-1];b.shiftKey&&this.#n.activeElement===k?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),k.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:s}=this.#l;i.appendChild(j(l,"p",{class:`${r}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const S of s)i.appendChild(j(l,"p",{class:`${r}__warning`,text:S}));const p=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),b=j(l,"table",{class:`${r}__map`}),A=j(l,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])A.appendChild(j(l,"th",{text:this.#f(S)}));b.appendChild(A),c.forEach((S,R)=>{const O=j(l,"tr",{});O.appendChild(j(l,"td",{text:S.source}));const F=j(l,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:S.source})}});F.appendChild(j(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const T of p)F.appendChild(j(l,"option",{text:T,attrs:{value:T,selected:T===S.field?!0:null}}));S.field&&!p.includes(S.field)&&F.appendChild(j(l,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const E=j(l,"td",{});E.appendChild(F),O.appendChild(E),O.appendChild(j(l,"td",{class:`${r}__type`,text:S.type})),b.appendChild(O)}),i.appendChild(b);const k=j(l,"div",{class:`${r}__mode`}),y=j(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(j(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(j(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(j(l,"label",{text:this.#f("import.modeLabel")})),k.appendChild(y),i.appendChild(k)}#g(){const{rows:l,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,s=V(l,i);this.#e.import.apply(s,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&x(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Le("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V=_.clear,H=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,h){return(this.messages&&typeof this.messages.t=="function"?this.messages:I).t(u,h)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||I;const h=u||{};if(this.doc=H(h),this.host=h.host||{},this.props=h.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const a=X(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(a,"click",()=>this.toggle())),this.root.appendChild(a),this.toggleButton=a,this.menu=X(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,h,a){const r=X(this.doc,"button",{class:`${z}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${z}__glyph`,text:a,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${z}__label`,text:h})]});return this.off.push(W(r,"click",()=>{const t=this.host[u];x(t)&&t(),this.refresh()})),r}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,h=x(u.canUndo)?u.canUndo():!1,a=x(u.canRedo)?u.canRedo():!1,r=x(u.peek)?u.peek("undo"):null,t=x(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",h,r),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(u,h,a,r){if(!u)return;u.disabled=!a;const t=h==="undo",n=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${z}__label`);o&&(o.textContent=n);const d=r&&r.label?this.t("history.described",{action:n,label:r.label}):n;u.setAttribute("title",a?d:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",a?d:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const h=x(this.host.list)?this.host.list():[];if(!h.length){u.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}h.forEach((a,r)=>{const t=X(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":a.type,"data-undone":a.undone?"true":null},children:[X(this.doc,"span",{class:`${z}__kind`,text:a.type}),X(this.doc,"span",{class:`${z}__text`,text:a.label||a.type})]});this.off.push(W(t,"click",()=>{const n=r+1;for(let o=0;o<n;o++)x(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&x(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const j=w}),Le("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",V="lat-cell--added-column";class H{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const u=this.#e.diff,h=u&&u.enabled;for(const a of g.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key"),t=h?u.statusOf(r):"unchanged";for(const o of Object.values(X))a.classList.remove(o);h&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",h?t:"");const n=h&&t==="changed";for(const o of a.querySelectorAll("[data-col]")){const d=o.getAttribute("data-col");if(o.classList.remove(W,V),o.removeAttribute("data-before"),!n)continue;const l=u.cellStatus(r,d);if(l==="changed"){o.classList.add(W);const i=this.#r(u,r,d);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(V)}}}#r(g,u,h){const a=this.#e,r=a&&a.columns,t=r&&x(r.get)?r.get(h):null,n=a&&a.permissions;if(t&&n&&x(n.isSecret)&&n.isSecret(t))return null;const o=g.before(u,h);if(o==null)return this.#o("diff.empty");if(!t||!x(t.formatValue))return String(o);const d=x(g.beforeRow)?g.beforeRow(u):void 0,i={...(a.rows&&x(a.rows.byKey)?a.rows.byKey(u):null)||{},data:d===void 0?{}:d};try{const m=t.formatValue(o,i,i.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${h}`,`the formatter for column "${h}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(o)}}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:_).t(g,u)}destroy(){for(const u of this.#n)u();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const u of g.querySelectorAll("[data-key]")){for(const h of Object.values(X))u.classList.remove(h);u.removeAttribute("data-diff")}for(const u of g.querySelectorAll("[data-col]"))u.classList.remove(W,V),u.removeAttribute("data-before")}}}function z(j){return!!(j&&j.diff&&(x(j.diff)||typeof j.diff=="object"))}const w=H}),Le("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",I="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#l();if(H){H.sweep();for(const z of V.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const j of z.querySelectorAll("[data-col]")){const g=H.active?H.colourFor(w,j.getAttribute("data-col")):null;g?(j.classList.add(B),j.style.setProperty(I,g)):j.classList.contains(B)&&(j.classList.remove(B),j.style.removeProperty(I))}}this.#s(H)}}#s(V){this.#r!==null&&x(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=V.nextExpiry;if(!Number.isFinite(H)||!x(this.#i.setTimeout))return;const z=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const V=this.#e.highlight;return V&&x(V.model)?V.model():null}destroy(){this.#r!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const H of V.querySelectorAll(`.${B}`))H.classList.remove(B),H.style.removeProperty(I)}}const X=_}),Le("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",I="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#e.find;if(!H||!x(H.stateFor))return;const z=x(H.model)?H.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let j=!1;for(const g of V.querySelectorAll("[data-key]")){const u=g.getAttribute("data-key");for(const h of g.querySelectorAll("[data-col]")){const a=w?H.stateFor(u,h.getAttribute("data-col")):null;a?(j=!0,h.classList.add(B),h.classList.toggle(I,a==="current")):h.classList.contains(B)&&h.classList.remove(B,I)}}this.#o=j}destroy(){for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const H of V.querySelectorAll(`.${B}`))H.classList.remove(B,I);this.#o=!1}}}const X=_}),Le("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,j=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#b=null;#w=null;#O=!1;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document||a.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=a.settings&&typeof a.settings=="object"?a.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(a,r){const t=this.#e;return(t&&t.messages&&H(t.messages.t)?t.messages:W).t(a,r)}mount(){const a=this.#A();if(!a)return;a.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),a.attachDriver({run:()=>this.#P()});const r=this.#t.viewport?.root;if(r&&H(r.addEventListener)&&this.#o.shortcut!==!1){const t=n=>{if(!(n.ctrlKey||n.metaKey)||n.altKey||n.shiftKey||n.key!=="f"&&n.key!=="F")return;const o=n.target;if(this.#s&&o===this.#s){n.preventDefault(),n.stopPropagation(),H(this.#s.select)&&this.#s.select();return}_(o)||(n.preventDefault(),n.stopPropagation(),this.show())};r.addEventListener("keydown",t,!0),this.#g.push(()=>r.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#C())),this.#g.push(this.#e.on("column:visible",()=>this.#C()))}show(a){const r=this.#k();if(!r)return;const t=r.style.display!=="none";r.style.display="",t||this.#y(),this.#A().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#E()),this.#s.focus(),H(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#H();const a=this.#A();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),a&&(a.clear(),a.setOpen(!1));const r=this.#t.viewport?.root;if(!r||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(H(r.querySelector)?r.querySelector('[tabindex="0"]'):null)||r;H(o.focus)&&o.focus()}search(){this.#E()}destroy(){this.#O=!0,this.#H();for(const r of this.#g)r();this.#g=[];const a=this.#A();a&&(a.attachUi(null),a.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const a=this.#t;a&&H(a.invalidate)&&a.invalidate("size")}#A(){const a=this.#e&&this.#e.find;return a&&H(a.model)?a.model():null}#k(){if(this.#i)return this.#i;const a=this.#t.viewport,r=a?.root,t=this.#n;if(!r||!t||!H(r.insertBefore))return null;const n=x(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=x(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=x(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=x(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=x(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=x(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),d=x(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=x(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=x(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=x(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=x(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=x(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,d,l,i])n.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(d,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#E()})),this.#g.push(B(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#E()})),this.#g.push(B(l,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#b!==null&&(this.#$(),this.#E()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return n.addEventListener("keydown",m),this.#g.push(()=>n.removeEventListener("keydown",m)),n.style.display="none",r.insertBefore(n,a.header||r.firstChild),this.#i=n,this.#C(),n}#C(){const a=this.#h;if(!a)return;const r=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(x(r,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,n=t&&H(t.visible)?t.visible():[];let o=!1;for(const d of n){if(!d||d.id===void 0)continue;const l=String(d.id);a.appendChild(x(r,"option",{text:d.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),a.value=this.#m||""}#S(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):j;if(this.#$(),a===0||!H(this.#r.setTimeout)){this.#E();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#E()},a)}#E(){const a=this.#A();if(!a||this.#O)return;const r=this.#s?this.#s.value:"";if(!r){this.#z(),a.clear();return}a.begin(r,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#T()}),this.#P()}#T(){const a=this.#t&&this.#t.window,r=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,r)}#P(){if(this.#w!==null||this.#O)return;const a=()=>{this.#w=null,this.#M()};H(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(a):H(this.#r.setTimeout)?this.#w=this.#r.setTimeout(a,0):a()}#M(){const a=this.#A();!a||this.#O||!a.active||(a.stale&&a.rescan({from:this.#T()}),!a.complete&&(a.step(w)||this.#P()))}#N(){if(!this.#i||this.#O)return;const a=this.#e.find.count(),r=this.#A().active;let t="",n="idle";r&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),n=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),n=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",n);const o=r&&a.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",r?a.complete&&(this.#u.textContent=a.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#$(){this.#b!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#z(){this.#w!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#H(){this.#$(),this.#z()}}const u=g}),Le("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q="lat-cell--redacted",x="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const V=W.active;for(const H of X.querySelectorAll(`.${x}[data-col]`))V&&W.has(H.getAttribute("data-col"))?H.classList.add(Q):H.classList.contains(Q)&&H.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const I=B}),Le("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function I(W,V){let H=W;for(;H;){if(V(H))return H;H=H.parentNode}return null}class _{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const H=I(V,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const z of H.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),j=this.#r(z),g=j?V.errorFor(j,w):null;x(z,g?g.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=_}),Le("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",V="lat-presenting--changing",H="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class j{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(h){this.#e=h.grid,this.#t=h.renderer,this.#n=h.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",a=>this.#a(a))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&x(this.#n.watch)&&this.#r.push(this.#n.watch(a=>{a||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const h=this.#t.viewport?.root;if(h&&x(h.addEventListener)){const a=r=>this.#l(r);h.addEventListener("keydown",a),this.#r.push(()=>h.removeEventListener("keydown",a))}}#l(h){const a=this.#e.presentation;if(!a?.active)return;const r=h.ctrlKey||h.metaKey,t=h.key;if(t==="Escape"&&!this.#n){h.defaultPrevented||(a.stop(),h.preventDefault?.());return}if(r){t==="="||t==="+"?(a.nudge(1),h.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),h.preventDefault?.()):t==="0"&&(a.setScale(1.5),h.preventDefault?.());return}if(!a.views.length||I(h.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),h.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),h.preventDefault?.()):t==="Home"?(a.goTo(0),h.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),h.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),h.preventDefault?.())}#a(h){!h||!h.viewId||(this.#u(),this.#e.views?.apply?.(h.viewId),this.#c(h))}#u(){const h=this.#t.viewport?.root;h?.classList&&(h.classList.remove(V),h.offsetWidth,h.classList.add(V))}#c(h){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const r=a.ownerDocument;if(!r?.createElement)return;if(!this.#i){const o=r.createElement("div");o.className=H,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),a.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(h.viewId),n=t&&t.name?t.name:"";this.#i.textContent=n?`${n} · ${(h.index||0)+1} / ${h.count||0}`:`${(h.index||0)+1} / ${h.count||0}`}#d(){if(this.#o){this.#f();return}const h=!!(this.#n&&this.#n.active());this.#n&&!h&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),r=[];for(const n of w){if(a.has(n)||n==="toolPanel"&&this.#O())continue;const o=this.#y(n);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",r.push(o))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",r.push(t)),this.#o={maximised:h,hidden:r},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const h=this.#o;this.#o=null;const a=this.#t.viewport?.root;if(a?.classList?.remove(W),a?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),a?.classList?.remove(V),this.#p(),h){const r=this.#e.toolPanel;r&&x(r.presentRestore)&&r.presentRestore();for(const t of h.hidden)t.style.display="";this.#n&&!h.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const h=this.#t.viewport?.root;!h||!h.style||(h.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const h=this.#t.viewport?.root;if(!h?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,r=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const n of h.querySelectorAll("[data-key]")){const o=!r||r.has(n.getAttribute("data-key"));for(const d of n.querySelectorAll("[data-col]"))!a||o&&(!t||t.has(d.getAttribute("data-col")))?d.classList.remove(z):d.classList.add(z)}}#m(){this.#g();const h=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(h)||h<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const r=this.#e.presentation;r.active&&r.goTo(r.index>=r.views.length-1?0:r.index+1)},Math.max(1e3,h)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const h=this.#e.element;return!h||!x(h.querySelector)?null:h.querySelector(`.${X.statusBar}`)}#w(h){const a=h.children||[];for(const r of a)if(!r.style||r.style.display!=="none")return!1;return!0}#O(){const h=this.#e.toolPanel;return!!(h&&x(h.presentOnly)&&h.presentOnly())}#y(h){const a=this.#e.element;if(!a||!x(a.querySelector))return null;const r={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[h];return r?a.querySelector(r):null}destroy(){this.#o&&this.#h();for(const h of this.#r)h();this.#r=[]}}const g=j}),Le("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const x=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function I(H,z,w){const j=w.getComputedStyle(H),g=z.style;if(g)for(let u=0;u<j.length;u++){const h=j[u];B.has(h)||g.setProperty(h,j.getPropertyValue(h),j.getPropertyPriority(h))}}function _(H,z,w){if(I(H,z,w),H.tagName==="CANVAS"&&x(H.toDataURL))try{const u=H.toDataURL("image/png"),h=z.style;h&&(h.setProperty("background-image",`url(${u})`),h.setProperty("background-size","100% 100%"),h.setProperty("background-repeat","no-repeat"))}catch{}const j=H.children||[],g=z.children||[];for(let u=0;u<j.length&&u<g.length;u++)_(j[u],g[u],w)}function X(H,z){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,z).origin===z}catch{return!0}}async function W(H,z={}){const w=H.ownerDocument,j=w?.defaultView;if(!j||typeof j.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(g.width)),h=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(z.scale)||2),r=j.location?.origin||"";for(const m of H.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,r))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=H.cloneNode(!0);_(H,t,j),t.style.width=`${u}px`,t.style.height=`${h}px`,t.style.margin="0";const n=new j.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${h}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${n}</div></foreignObject></svg>`,d=new j.Image;await new Promise((m,c)=>{d.onload=()=>m(void 0),d.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=w.createElement("canvas");l.width=Math.round(u*a),l.height=Math.round(h*a);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||j.getComputedStyle(H).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(d,0,0,l.width,l.height),new Promise((m,c)=>{l.toBlob(f=>f?m({blob:f,width:l.width,height:l.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const V=W}),Le("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.uid,I=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),H=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,j="system-ui, -apple-system, sans-serif";function g(f,s){if(!f||typeof f!="object")return null;const p=H[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:B("mark"),A=Array.isArray(f.points)?f.points:[],k=[];for(const S of A){const R=Number(S&&S.x),O=Number(S&&S.y);Number.isFinite(R)&&Number.isFinite(O)&&k.push({x:R,y:O})}const y=typeof f.colour=="string"&&f.colour?f.colour:s;if(p==="text"){const S=typeof f.text=="string"?f.text:"";if(!k.length||!S)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:S,region:u(f.region)},O=Number(f.fontSize);return Number.isFinite(O)&&O>0&&(R.fontSize=O),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:u(f.region)}}function u(f){return f==="start"||f==="end"?f:"centre"}function h(f){const s={id:f.id,type:z[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(s.region=f.region),f.tool==="text"&&(s.text=f.text,f.fontSize!==void 0&&(s.fontSize=f.fontSize),f.background!==void 0&&(s.background=f.background)),s}const a="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function n(f,s){return{id:f,count:s,valueOf(){return this.count}}}const o=10;function d(f,s,p){const b=p.x-s.x,A=p.y-s.y,k=b*b+A*A;let y=k?((f.x-s.x)*b+(f.y-s.y)*A)/k:0;y=Math.max(0,Math.min(1,y));const S=s.x+y*b,R=s.y+y*A;return Math.hypot(f.x-S,f.y-R)}function l(f){const s=f.points;if(!s.length)return null;if(f.tool==="text"){const y=f.fontSize||w,S=(f.text||"").length*y*.6;return{x1:s[0].x,y1:s[0].y,x2:s[0].x+S,y2:s[0].y+y*1.2}}let p=1/0,b=1/0,A=-1/0,k=-1/0;for(const y of s)p=Math.min(p,y.x),b=Math.min(b,y.y),A=Math.max(A,y.x),k=Math.max(k,y.y);return{x1:p,y1:b,x2:A,y2:k}}function i(f,s){const p=l(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const k=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let S=0;S<4;S++)y=Math.min(y,d(s,k[S],k[(S+1)%4]));return y}if(b.length===1)return Math.hypot(s.x-b[0].x,s.y-b[0].y);let A=1/0;for(let k=0;k<b.length-1;k++)A=Math.min(A,d(s,b[k],b[k+1]));return A}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const p=g(s,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#E(),this.redraw(),this.#M(),n(p.id,this.#s.length)):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),n(null,this.#s.length))}list(){return this.#s.map(h)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?(I("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${s}".`),!1):(this.#s.splice(p,1),this.#c===s&&(this.#c=null),this.redraw(),this.#M(),!0)}replaceAll(s){const p=Array.isArray(s)?s:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#E(),this.redraw(),this.#M()}#d(){const s=this.#t.viewport?.root;if(!s||!x(s.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#h(s){if(!this.#s.length){this.#$("a11y.annotate.noMarks");return}s.preventDefault?.();const p=this.#c?this.#s.findIndex(k=>k.id===this.#c):-1,b=s.shiftKey?-1:1,A=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[A].id,this.redraw(),this.#$("a11y.annotate.focusedMark",{at:A+1,of:this.#s.length})}#f(s){if(!this.#c)return;s.preventDefault?.();const p=this.#c;this.remove(p),this.#$("a11y.annotate.erased")}#p(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!x(s.matchMedia))return;let p=null;const b=()=>{const A=s.devicePixelRatio||1;let k;try{k=s.matchMedia(`(resolution: ${A}dppx)`)}catch{return}p=k;const y=()=>{this.redraw(),b()};x(k.addEventListener)?k.addEventListener("change",y,{once:!0}):x(k.addListener)&&k.addListener(y)};b(),this.#a.push(()=>{p=null})}use(s,p={}){const b=!!p.colour&&s===this.#o;p.colour&&(this.#i=String(p.colour));const A=s&&W.includes(s)?s:null;this.#o=A&&A===this.#o&&!b?null:A,this.#o!=="erase"&&(this.#c=null);const k=this.#o?this.#E():this.#n;return k&&(k.style.pointerEvents=this.#o?"auto":"none",k.style.cursor=this.#o?"crosshair":""),this.#M(),this.#o}undo(){const s=this.#s.pop();return s&&this.#c===s.id&&(this.#c=null),this.redraw(),this.#M(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#M())}#m(){const s=this.#s.filter(p=>p.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#M())}redraw(){!this.#n&&this.#s.length&&this.#E();const s=this.#n,p=this.#r;if(!s||!p)return;this.#T();const{left:b,top:A}=this.#S();p.clearRect(0,0,s.width,s.height);const k=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const S=k.filter(R=>u(R.region)===y);if(S.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-A||0);for(const R of S)this.#y(p,R),R.id===this.#c&&this.#k(p,R);p.restore()}}}#g(s,p="centre"){const b=this.#n,A=this.#t.viewport?.bodyViewport;if(!x(b?.getBoundingClientRect)||!x(A?.getBoundingClientRect))return;const k=b.getBoundingClientRect(),y=A.getBoundingClientRect();if(!y.width||!y.height)return;const S=this.#b(p,y);S&&(s.beginPath(),s.rect(S.left-k.left,y.top-k.top,S.width,y.height),s.clip())}#b(s,p){const b=O=>{if(!x(O?.getBoundingClientRect))return null;const F=O.getBoundingClientRect();return F&&F.width>0?{left:F.left,width:F.width}:null},A=b(this.#t.viewport?.bodyStart),k=b(this.#t.viewport?.bodyEnd);if(s==="start")return A;if(s==="end")return k;let y=p.left,S=p.left+p.width;const R=p.left+p.width/2;for(const O of[A,k]){if(!O)continue;const F=O.left+O.width;O.left+O.width/2<R?y=Math.max(y,F):S=Math.min(S,O.left)}return S>y?{left:y,width:S-y}:null}#w(s){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!x(b?.getBoundingClientRect))continue;const A=b.getBoundingClientRect();if(A&&A.width>0&&s>=A.left&&s<A.left+A.width)return p}return"centre"}#O(s){const p=this.#t.viewport?.bodyViewport;if(!x(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:s.clientX>=b.left&&s.clientX<=b.right&&s.clientY>=b.top&&s.clientY<=b.bottom}#y(s,p){const b=p.points;if(!b.length)return;const A=this.#e.presentation?.scale||1;s.lineWidth=(r[p.tool]||3)*A,s.strokeStyle=p.colour,s.fillStyle=p.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=p.tool==="highlight"?.32:1;const k=b[0],y=b[b.length-1];if(p.tool==="text"){const S=(p.fontSize||w)*A;s.font=`${S}px ${j}`,s.textBaseline="top";const R=p.text||"";if(p.background){let O=R.length*S*.6;if(typeof s.measureText=="function"){const F=s.measureText(R);F&&Number.isFinite(F.width)&&(O=F.width)}s.fillStyle=p.background,s.fillRect(k.x-S*.15,k.y-S*.1,O+S*.3,S*1.2)}s.fillStyle=p.colour,s.fillText(R,k.x,k.y),s.globalAlpha=1;return}if(p.tool==="rect")s.strokeRect(k.x,k.y,y.x-k.x,y.y-k.y);else if(p.tool==="arrow")s.beginPath(),s.moveTo(k.x,k.y),s.lineTo(y.x,y.y),s.stroke(),this.#A(s,k,y,s.lineWidth);else{s.beginPath(),s.moveTo(k.x,k.y);for(let S=1;S<b.length;S++)s.lineTo(b[S].x,b[S].y);s.stroke()}s.globalAlpha=1}#A(s,p,b,A){const k=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,A*3);s.beginPath(),s.moveTo(b.x,b.y),s.lineTo(b.x-y*Math.cos(k-Math.PI/7),b.y-y*Math.sin(k-Math.PI/7)),s.lineTo(b.x-y*Math.cos(k+Math.PI/7),b.y-y*Math.sin(k+Math.PI/7)),s.closePath(),s.fill()}#k(s,p){const b=l(p);if(!b||!x(s.strokeRect))return;const A=6;s.save(),s.setLineDash?.([4,3]),s.strokeStyle="#1a73e8",s.lineWidth=2,s.globalAlpha=1,s.strokeRect(b.x1-A,b.y1-A,b.x2-b.x1+A*2,b.y2-b.y1+A*2),s.restore()}#C(s,p){const b=this.#e.presentation?.scale||1,A=o*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(u(y.region)===p&&i(y,s)<=A)return y}return null}#S(){const s=x(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(s?.left||0,p),top:s?.top||0}}#E(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,p=s?.ownerDocument;if(!s||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=a,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",s.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#T(),this.#P(b),b}#T(){const s=this.#n,p=this.#t.viewport?.root;if(!s||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),k=s.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*k)),S=Math.max(1,Math.round(b.height*k));s.width===y&&s.height===S||(s.width=y,s.height=S,s.style&&(s.style.width=`${Math.max(1,b.width)}px`,s.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(k,0,0,k,0,0))}#P(s){const p=(S,R="centre")=>{const O=s.getBoundingClientRect(),{left:F,top:E}=this.#S();return{x:S.clientX-O.left+(R==="centre"?F:0),y:S.clientY-O.top+E}},b=S=>{if(!this.#o||!this.#O(S))return;const R=this.#w(S.clientX);if(this.#o==="erase"){const O=this.#C(p(S,R),R);O&&(this.remove(O.id),this.#$("a11y.annotate.erased")),S.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[p(S,R)],region:R},s.setPointerCapture?.(S.pointerId),S.preventDefault?.()},A=S=>{if(!this.#l)return;const R=p(S,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},k=S=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(S.pointerId),this.redraw(),this.#M())},y=S=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let O=!1;S.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=S.deltaY,O=!0),S.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=S.deltaX,O=!0),O&&S.preventDefault?.()};s.addEventListener("pointerdown",b),s.addEventListener("pointermove",A),s.addEventListener("pointerup",k),s.addEventListener("pointercancel",k),s.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",b),s.removeEventListener("pointermove",A),s.removeEventListener("pointerup",k),s.removeEventListener("pointercancel",k),s.removeEventListener("wheel",y)})}#M(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#N(s,p){const b=this.#e.messages;return b&&x(b.t)?b.t(s,p):s}#$(s,p){this.#t.announce?.(this.#N(s,p),{repeat:!0})}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Le("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(z){if(!Number.isFinite(z)||z<1e3)return"now";const w=Math.round(z/1e3);if(w<60)return`${w}s ago`;const j=Math.round(w/60);return j<60?`${j}m ago`:`${Math.round(j/60)}h ago`}function W(z,w){return Number.isFinite(z)?new Date(z).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class V{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,j=w.depth,g=w.position;this.#r.max=String(Math.max(1,j)),this.#r.value=String(Math.max(0,j-g)),this.#r.disabled=j===0;const u=w.at(),h=w.live;this.#o&&(this.#o.textContent=h?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",h?"true":"false")),this.#i&&(this.#i.textContent=j===0?this.#l("timeline.recording"):W(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",h?"true":"false")}#l(w,j){const g=this.#e;return(g&&g.messages?g.messages:I).t(w,j)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,j=w?.ownerDocument;if(!w||!j?.createElement)return;const g=j.createElement("div");g.className=_;const u=j.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const h=j.createElement("input");h.className=`${_}__range`,h.type="range",h.min="0",h.step="1",h.setAttribute("aria-label",this.#l("timeline.scrub"));const a=j.createElement("span");a.className=`${_}__clock`;const r=j.createElement("button");r.className=`${_}__live`,r.type="button",r.textContent=this.#l("timeline.goLive"),r.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(u),g.appendChild(h),g.appendChild(a),g.appendChild(r),w.appendChild(g),this.#n=g,this.#r=h,this.#o=u,this.#i=a;const t=()=>{const d=this.#e.timeline.depth;this.#e.timeline.seek(d-Number(h.value))};h.addEventListener("input",t);const n=()=>this.#e.timeline.toLive();r.addEventListener("click",n);const o=d=>d.stopPropagation();h.addEventListener("keydown",o),this.#s.push(()=>{h.removeEventListener("input",t),r.removeEventListener("click",n),h.removeEventListener("keydown",o)})}#u(){this.#n&&(x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const H=V}),Le("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",V="lat-cell--commented",H="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const h=[];for(const a of u.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key");if(r){h.push(r);for(const t of a.querySelectorAll("[data-col]")){const n=t.getAttribute("data-col"),o=g.at(r,n),d=!!(o&&o.count);t.classList.toggle(V,d),t.classList.toggle(H,d&&o.unresolved>0),this.#i(t,o,n)}}}(h.length!==this.#r.length||h.some((a,r)=>a!==this.#r[r]))&&(this.#r=h,g.request(h))}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:I).t(g,u)}#i(g,u,h){if(!u||!u.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=u.count,r=u.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",r>0?this.#o("comments.someUnresolved",{comments:t,unresolved:r}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!x(g.addEventListener))return;const u=a=>{const r=this.#e.comments;if(!r||!r.enabled)return;const t=a.target&&x(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,a))return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.stopPropagation(),a.preventDefault(),r.open(o,t.getAttribute("data-col")))},h=a=>{const r=this.#e.comments;if(!r||!r.enabled||!a.altKey||a.key!=="m"&&a.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&x(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.preventDefault(),a.stopPropagation(),r.open(o,t.getAttribute("data-col")))};g.addEventListener("click",u,!0),g.addEventListener("keydown",h,!0),this.#n.push(()=>{g.removeEventListener("click",u,!0),g.removeEventListener("keydown",h,!0)})}#l(g,u){if(!x(g.getBoundingClientRect))return!1;const h=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,h.height*.6));return(X(g)?u.clientX<=h.left+a:u.clientX>=h.right-a)&&u.clientY<=h.top+a}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=z}),Le("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,h=>this.#l(u,h)));this.#a(),this.paint()}}#l(g,u){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=u&&u.peer;a&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,u=g?.ownerDocument;if(!g||!u?.createElement)return;const h=this.#e.get("presence")||{},a=u.createElement("span");if(a.className=`${H}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,h.roster===!1)return;const r=u.createElement("div");r.className=H,h.roster&&h.roster.side==="start"&&r.setAttribute("data-side","start"),r.style.pointerEvents="auto",g.appendChild(r),this.#n=r}paint(){const g=this.#e.presence,u=this.#t.viewport?.root;if(!g||!g.enabled||!u?.querySelectorAll)return;this.#d(u);const h=g.peers(),a=[...h].sort((r,t)=>r.at-t.at);for(const r of a)for(const t of r.ranges||[])for(const n of t.rowIds||[])for(const o of t.columns||[])this.#c(u,n,o,r,"range");for(const r of a)r.cursor&&this.#c(u,r.cursor.rowId,r.cursor.colId,r,"cursor");for(const r of a)r.editing&&this.#c(u,r.editing.rowId,r.editing.colId,r,"edit");this.#h(),this.#u(h)}#u(g){if(this.#s!==null)return;const u=g.filter(r=>r.cursorFresh);if(!u.length)return;const a=Math.max(...u.map(r=>r.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,u,h,a,r){const t=g.querySelector(`[data-key="${X(u)}"]`),n=t&&t.querySelector(`[data-col="${X(h)}"]`);n&&(n.setAttribute("data-presence",r),n.style.setProperty("--lat-peer",a.colour),n.setAttribute("data-peer-name",a.name),n.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?n.setAttribute("data-peer-idle","true"):n.removeAttribute("data-peer-idle"),r==="cursor"&&a.cursorFresh&&n.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${h}`))}#d(g){if(this.#o.size){for(const u of g.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of u){const r=g.createElement("button");r.className=`${H}__peer`,r.type="button",r.style.setProperty("--lat-peer",a.colour),r.toggleAttribute("data-idle",!!a.idle),r.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),r.setAttribute("aria-label",this.#f(t,{name:a.name}));const n=g.createElement("span");n.className=`${H}__dot`,n.setAttribute("aria-hidden","true"),n.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),r.appendChild(n);const o=g.createElement("span");o.className=`${H}__name`,o.textContent=a.name,r.appendChild(o),r.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(r)}const h=u.filter(a=>a.hidden).length;if(h){const a=g.createElement("span");a.className=`${H}__hidden`,a.textContent=this.#f("presence.hidden",{count:h}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const u=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(g,u){const h=this.#e;return(h&&h.messages?h.messages:I).t(g,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=z}),Le("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function j(a,r){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((r-a)/1e3));if(t<60)return"just now";const n=Math.round(t/60);if(n<60)return`${n}m ago`;const o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function g(a,r,t,n){r.textContent="";const o=String(t??"");if(!n){r.textContent=o;return}const d=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=d.exec(o);for(;i;){i.index>l&&r.appendChild(a.createTextNode(o.slice(l,i.index)));const m=i[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),r.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),r.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),s=m.slice(c+2,-1);if(z.test(s)){const p=a.createElement("a");p.href=s,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",r.appendChild(p)}else r.appendChild(a.createTextNode(f))}l=i.index+m.length,i=d.exec(o)}l<o.length&&r.appendChild(a.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",r=>this.#a(r))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(r){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(r.rowId,r.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&x(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const r=this.#s;this.#s=null,r&&x(r.focus)&&r.focus()}#c(){const r=this.#e.comments.openKey;if(!r)return;const{rowId:t}=V(r);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(r){if(!this.#r)return;const n=this.#r.ownerDocument.createElement("p");n.className=`${H}__note`,n.setAttribute("role","status"),n.textContent=r,this.#r.appendChild(n)}#h(r,t){const n=this.#t.viewport?.root;if(!n||!n.querySelector)return null;const o=n.querySelector(`[data-key="${X(r)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#f(r,t){const n=this.#e;return(n&&n.messages?n.messages:I).t(r,t)}#p(r){const t=r.createElement("div");t.className=H,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const n=r.createElement("header");n.className=`${H}__head`;const o=r.createElement("div");o.className=`${H}__title`,n.appendChild(o);const d=r.createElement("button");d.className=`${H}__resolve`,d.type="button",n.appendChild(d);const l=r.createElement("button");l.className=`${H}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",n.appendChild(l);const i=r.createElement("div");i.className=`${H}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=r.createElement("form");m.className=`${H}__composer`;const c=r.createElement("textarea");c.className=`${H}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=r.createElement("button");f.className=`${H}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(n),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=d;const s=k=>{k.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#b()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},A=k=>{if(k.stopPropagation(),k.key==="Escape"){k.preventDefault(),this.#e.comments.close();return}if(k.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(F=>F.offsetParent!==null||F===c);if(!y.length)return;const S=y[0],R=y[y.length-1],O=t.ownerDocument.activeElement;k.shiftKey&&O===S?(k.preventDefault(),R.focus()):!k.shiftKey&&O===R&&(k.preventDefault(),S.focus())};m.addEventListener("submit",s),l.addEventListener("click",p),d.addEventListener("click",b),t.addEventListener("keydown",A),this.#l.push(()=>{m.removeEventListener("submit",s),l.removeEventListener("click",p),d.removeEventListener("click",b),t.removeEventListener("keydown",A)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const r=this.#e.comments;if(!this.#n||!r.openKey)return;const t=this.#n.ownerDocument,n=this.#e.get("comments")||{},o=Date.now(),d=r.openKey,{rowId:l,field:i}=V(d),m=this.#e.columns.get(i),c=this.#e.rows.byKey(l),f=x(n.rowLabel)&&c?n.rowLabel(c):l;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#b()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",r.loading){this.#d(this.#f("comments.loading"));return}const s=r.thread||[];if(!s.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of s)this.#r.appendChild(this.#O(t,b,o,p,n))}#O(r,t,n,o,d){const l=r.createElement("article");l.className=`${H}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=r.createElement("div");i.className=`${H}__meta`;const m=r.createElement("span");m.className=`${H}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=r.createElement("time");c.className=`${H}__time`;const f=j(t.at,n);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),l.appendChild(i);const s=r.createElement("div");if(s.className=`${H}__body`,g(r,s,t.body,!!d.markdown),l.appendChild(s),t.value!==void 0&&!Object.is(t.value,o)){const A=r.createElement("p");A.className=`${H}__moved`,A.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(A)}const p=t.can||{},b=A=>p[A]!==!1;if(b("edit")||b("delete")){const A=r.createElement("div");if(A.className=`${H}__actions`,b("delete")){const k=r.createElement("button");k.type="button",k.className=`${H}__action`,k.textContent=this.#f("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),A.appendChild(k)}l.appendChild(A)}return l}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:n,field:o}=V(t),d=this.#h(n,o)||this.#i,l=this.#t.viewport?.root;if(!d||!l||!x(d.getBoundingClientRect))return;const i=d.getBoundingClientRect(),m=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let s=i.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const r of this.#l)r();this.#l=[],this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const h=u}),Le("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V="lat-watermark",H="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class j{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(h){this.#e=h.grid,this.#t=h.document,this.#n=h.element,this.#i=h.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),x(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const h=this.#e.licence&&this.#e.licence.ready;h&&x(h.then)&&h.then(()=>this.refresh(),()=>this.refresh())}refresh(){const h=this.#d();h&&!this.#r?(this.#h(),this.#u()):!h&&this.#r&&(this.#f(),this.#c())}#a(){const h=this.#i;if(!h||!x(h.matchMedia))return!1;try{return!!h.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),x(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%z.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const h=this.#e.licence;return!!(h&&x(h.watermark)&&h.watermark())}#h(){const h=this.grid&&this.grid.messages?this.grid.messages:I,a=X(this.#t,"a",{class:`${V}__link`,text:h.t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}}),r=X(this.#t,"span",{class:`${V}__free`,text:h.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${V} ${V}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,r]}),this.#o.push(W(this.#r,"pointerdown",t=>{x(t.stopPropagation)&&t.stopPropagation()})),this.#n&&x(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const h of this.#o)h();this.#o=[],this.#f()}}const g=j}),Le("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,B=Q.isFunction,I=K("packages/dom/src/editors/common.js"),_=I.el,X=I.on,V=K("packages/dom/src/themeof.js").themeOf,H="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},w="lat-maximised-host",j="lat-maximise-placeholder";class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(a){this.#e=a.element,this.#t=a.document,this.#n=B(a.onChange)?a.onChange:null,this.#r=B(a.captureScroll)?a.captureScroll:null,this.#o=B(a.restoreScroll)?a.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const a=this.#e.parentNode;if(!a||!this.#t.body)return x("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:j}),this.#i.style.visibility="hidden";const r=this.#e.offsetWidth,t=this.#e.offsetHeight;r&&(this.#i.style.width=`${r}px`),t&&(this.#i.style.height=`${t}px`);const n=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(a):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),a.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[d,l]of Object.entries(z))this.#a[d]=this.#e.style[d]||"",this.#e.style[d]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(w),n&&this.#o&&this.#o(n),this.#s=X(this.#t,"keydown",d=>this.#h(d)),this.#f(),!0}exit(){if(!this.active())return!1;const a=this.#r?this.#r():null,r=this.#i,t=r.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,r)),B(r.remove)&&r.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[n,o]of Object.entries(this.#a))this.#e.style[n]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(w),a&&this.#o&&this.#o(a),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(a){const r=this.#t.activeElement,t=r&&r!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(r)?r:null;a(),t&&B(t.focus)&&t.focus()}#h(a){!a||a.key!=="Escape"||a.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const a of this.#l)a(this.active())}watch(a){return B(a)?(this.#l.add(a),()=>this.#l.delete(a)):()=>{}}destroy(){this.exit()}}const u=g}),Le("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,B=Q.el,I=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,j=z.promptText,g=K("packages/core/src/ai/intent.js"),u=g.applyPlan,h=g.buildPrompt,a=g.planIntent,r="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#O=!1;#y=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||W,this.#e=x(l),this.#t=l.grid||null,this.#n=H(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:H(l.onPlan)?l.onPlan:null,onApply:H(l.onApply)?l.onApply:null,onError:H(l.onError)?l.onError:null},this.#s=B(this.#e,"div",{class:r,attrs:{"data-state":"idle",role:"search"}}),this.#A(l)}element(){return this.#s}refresh(){this.#O||!this.#s||this.#b!=="busy"&&this.#E()}destroy(){this.#O=!0,this.#w++;for(const l of this.#y)l();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#O||this.#b==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#P("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#w;this.#k("busy"),this.#T("Thinking…");let c;try{const f=w(this.#t,this.#r),s=j(f);if(c=await this.#n({prompt:i,schema:f,schemaText:s,message:h(i,s),context:this.#o}),this.#O||m!==this.#w)return null;const p=a(c,f);return this.#C(p),p}catch(f){return this.#O||m!==this.#w||(this.#i.onError&&this.#i.onError(f),this.#P(f instanceof Error?f.message:String(f))),null}}apply(){const l=this.#g;if(this.#O||!l||!l.ok)return null;const i=this.#t?.ai,m=H(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(m,l),this.#E(),this.#l&&(this.#l.value=""),m.failed.length?this.#P(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#T(`Applied: ${l.describe()}`),m}discard(){this.#O||(this.#E(),this.#T("Discarded."))}#A(l){const i=this.#e,m=B(i,"div",{class:`${r}__row`});this.#l=B(i,"input",{class:`${r}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(I(this.#l,"keydown",f=>{const s=f&&f.key;s==="Enter"?(H(f.preventDefault)&&f.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(H(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(i,"button",{class:`${r}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(I(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(i,"div",{class:`${r}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${r}__summary`}),this.#d=B(i,"ul",{class:`${r}__notes`});const c=B(i,"div",{class:`${r}__buttons`});this.#h=B(i,"button",{class:`${r}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=B(i,"button",{class:`${r}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(I(this.#h,"click",()=>{this.apply()})),this.#y.push(I(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${r}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${r}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(l){if(this.#b=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";n(this.#l,i),n(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#C(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#P(`I could not turn that into a change: ${m}`);return}this.#g=l,this.#T(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#k("preview")}#S(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const m of l.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${r}__note`,text:m.reason}));l.length>6&&i.appendChild(B(this.#e,"li",{class:`${r}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#T(l){this.#p&&(this.#p.textContent=l)}#P(l){this.#g=null,this.#T(""),this.#m&&(this.#m.textContent=l),this.#k("error")}}function n(d,l){d&&(d.disabled=l,l?d.setAttribute("disabled",""):d.removeAttribute("disabled"))}function o(d,l){d&&(d.hidden=l,l?d.setAttribute("hidden",""):d.removeAttribute("hidden"))}}),Le("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.isObject,I=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,V=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,j=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",h=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),a=Object.freeze({direction:"flat",change:null,percent:null});function r(s,p){if(!Number.isFinite(s)||!Number.isFinite(p))return a;const b=s-p,A=b>0?"up":b<0?"down":"flat",k=p===0?null:b/Math.abs(p)*100;return{direction:A,change:b,percent:k}}function t(s,p){return s==="flat"||p==="neither"?"flat":s===p?"good":"bad"}function n(s,p,b=null){if(x(p)){const O=p(s,b);return O==="good"||O==="warn"||O==="bad"?O:null}if(!B(p))return null;const A=typeof s=="number"&&Number.isFinite(s)?s:null;if(A===null)return null;const k=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,S=String(p.direction||"up")==="down",R=O=>S?A<=O:A>=O;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function o(s){return!(x(s.value)||s.value!==void 0&&!B(s.value))}function d(s){return!s||!s.rows||!x(s.rows.totalCount)?!0:s.rows.totalCount()>0}function l(s){const p=B(s)?s:{},b=p.grid||null,A=c(p.container,b);if(!A)return I("stat.container","createStat needs a `container`: an element or a selector."),f();const k=A.ownerDocument||(typeof document>"u"?null:document);if(!k)return I("stat.document","createStat needs a document; it draws DOM."),f();const y=k.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const S=k.createElement("div");S.className=g.title;const R=k.createElement("div");R.className=g.value;const O=k.createElement("div");O.className=g.interval;const F=k.createElement("div");F.className=g.delta;const E=k.createElement("div");E.className=g.footer;const T=k.createElement("div");if(T.className=g.note,T.hidden=!0,p.icon!=null&&p.icon!==""){const ee=k.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),j(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(S),ne.appendChild(R),ne.appendChild(T),ne.appendChild(O),ne.appendChild(F),ne.appendChild(E),y.appendChild(ne)}else y.appendChild(S),y.appendChild(R),y.appendChild(T),y.appendChild(O),y.appendChild(F),y.appendChild(E);A.appendChild(y);let C=null;const D=[];let $=!1;function P(){if(x(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const ee=B(p.value)?p.value:p,ne=ee.of,ie=ee.fn||"sum",se=ee.show;return b?ie==="count"?N().length:ne?se?G(String(ne),String(ie),String(se)):v()==="filtered"&&b.statistics&&x(b.statistics.reduce)?b.statistics.reduce(String(ne),String(ie)):X(N().map(he=>m(he,String(ne))),String(ie)):null:null}function v(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const ee=v();if(ee==="all"){const ie=[];return x(b.rows.forEachAll)&&b.rows.forEachAll(se=>{se.group||ie.push(i(se))}),ie}if(ee==="selected")return(b.selection&&x(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const ne=[];return x(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||ne.push(i(ie))}),ne}function G(ee,ne,ie){if(ne!=="min"&&ne!=="max")return I(`stat.show.${ne}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ne}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,he=null;for(const ce of N()){const te=Number(m(ce,ee));Number.isFinite(te)&&(se===null||(ne==="max"?te>se:te<se))&&(se=te,he=ce)}return he===null?null:m(he,ie)}function q(ee){if(x(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const ne=B(p.value)?p.value:p,ie=ne.show||ne.of;if((ne.show?!0:h.has(String(ne.fn||"sum")))&&b&&ie&&x(b.columns?.get)){const he=b.columns.get(String(ie));if(he&&x(he.formatValue))return he.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Z(ee){return ee?(b&&b.messages||z).t(`stat.tone.${ee}`):""}function J(){if($)return;const ee=P(),ne=o(p)&&!!b&&!d(b),ie=ne?null:ee,se=x(p.baseline)?p.baseline(b):p.baseline;C=ie,S.textContent=p.title??"",S.hidden=!p.title,R.textContent=q(ie),T.hidden=!ne,ne&&(T.textContent=b.messages.t("stat.noData"));const he=ne||se===void 0||se===null?a:r(typeof ie=="number"?ie:null,Number(se)),ce=t(he.direction,p.goodWhen||"up");if(F.hidden=he.change===null,he.change!==null){const de=he.direction==="up"?"↑":he.direction==="down"?"↓":"→",we=he.percent===null?q(Math.abs(he.change)):`${Math.abs(he.percent).toFixed(1)}%`;F.textContent=`${de} ${we}`,F.setAttribute("data-tone",ce),F.setAttribute("data-direction",he.direction)}const te=x(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);O.hidden=!oe,oe&&(O.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&O.setAttribute("title",`${Math.round(te.confidence*100)}%`));const fe=ne?u:p.bands?n(ie,p.bands,b):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),E.textContent=x(p.footer)?String(p.footer(ie,b)):p.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?T.textContent:"",oe?O.textContent:"",he.change===null?"":F.textContent,he.change===null?"":Z(ce),E.textContent].filter(Boolean).join(", "))}if(b&&x(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=ie=>{ee==="model:changed"&&!V(ie)||J()};b.on(ee,ne),D.push(()=>x(b.off)&&b.off(ee,ne))}return J(),{element:()=>y,value:()=>C,refresh:J,destroy(){$=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(s){return B(s)&&"data"in s?s.data:s}function m(s,p){if(!B(s))return;if(!p.includes("."))return s[p];let b=s;for(const A of p.split(".")){if(!B(b))return;b=b[A]}return b}function c(s,p){if(s&&typeof s=="object")return s;if(typeof s!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(s):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Le("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isObject,I=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:H,kpis:z}){this.#e=V,this.#t=H,this.#n=Array.isArray(z)?z.filter(x):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${_.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const z of this.#n){const w=I({...z,grid:this.#e,container:H});this.#o.push(w)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Le("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const x=K("packages/core/src/index.js").createHeadlessGrid,I=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),V=W.fail,H=W.isFunction,z=W.warnOnce,j=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,r=K("packages/dom/src/cell/icons.js"),t=r.icon,n=r.iconNames,d=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,s=m.Pagination,p=m.GroupByZone,A=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,F=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,C=K("packages/dom/src/alignedgrids.js").AlignedGrids,$=K("packages/dom/src/columntagbar.js").ColumnTagBar,v=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Z=q.ToolPanelDock,J=q.panelHost,ne=K("packages/dom/src/celledit.js").CellEditController,se=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Te=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,be=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Oe=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,st=K("packages/dom/src/validationpaint.js").ValidationPainter,yt=K("packages/dom/src/presentation.js").PresentationController,Ct=K("packages/dom/src/capture.js").captureElement,Et=K("packages/dom/src/annotate.js").AnnotationLayer,It=K("packages/dom/src/timelinebar.js").TimelineBar,nt=K("packages/dom/src/commentpaint.js").CommentPainter,ve=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,ke=K("packages/dom/src/maximise.js").Maximiser,je=K("packages/dom/src/promptbar.js").PromptBar,ze=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(Ve,pt,ct){const ot=pt==="redo"?"toolbar.redo":"toolbar.undo";return!ct||!ct.label?Ve(ot):Ve(pt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:ct.label})}const De=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Se=2e3;function xe(Ve,pt,ct,ot){const St=pt.annotate===!0?Be(Ve,ot):[];if(pt.actions===!1)return[];if(pt.actions===void 0&&pt.side!=="left")return St;const At=Array.isArray(pt.actions)?pt.actions:De,ft=(Dt,_t)=>Ve.messages.t(Dt,_t),Nt={undo:{name:"undo",title:()=>_e(ft,"undo",Ve.history.peek("undo")),icon:"undo",run:()=>Ve.history.undo(),enabled:()=>Ve.history.canUndo()},redo:{name:"redo",title:()=>_e(ft,"redo",Ve.history.peek("redo")),icon:"redo",run:()=>Ve.history.redo(),enabled:()=>Ve.history.canRedo()},export:{name:"export",title:()=>ft("toolbar.exportCsv"),icon:"download",run:()=>Ve.export.csv({download:!0,fileName:pt.exportName})},excel:{name:"excel",title:()=>ft("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ve.export.excel({download:!0,fileName:pt.exportName})},clipboard:{name:"clipboard",title:()=>ft("toolbar.clipboard"),icon:"copy",run:()=>Ve.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>ft("toolbar.print"),icon:"print",run:()=>Ve.export.print()},pause:{name:"pause",title:()=>{if(!Ve.updates.paused)return ft("toolbar.pause");const Dt=Ve.updates.stats().pending;return Dt?ft("toolbar.applyHeld",{count:Dt}):ft("toolbar.resume")},icon:()=>Ve.updates.paused?"play":"pause",run:()=>Ve.updates.paused?Ve.updates.resume():Ve.updates.pause()},restore:{name:"restore",title:()=>ft("toolbar.restoreView"),icon:"restore",run:()=>Ve.state.reset(),enabled:()=>Ve.state.modified()},maximise:{name:"maximise",title:()=>ft(ct&&ct.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>ct&&ct.active()?"minimise":"maximise",run:()=>ct.toggle()}};return ct||delete Nt.maximise,At.map(Dt=>Dt==="-"?{name:"-",separator:!0}:typeof Dt=="string"?Nt[Dt]:!Dt||typeof Dt!="object"||!Dt.name?null:{...Dt,run:H(Dt.run)?()=>Dt.run({grid:Ve,keys:Ve.selection&&H(Ve.selection.keys)?Ve.selection.keys():[],cells:Ve.selection&&H(Ve.selection.cells)?Ve.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Be(Ve,pt){const ct={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ot=(At,ft)=>Ve.messages.t(At,ft),St=["pen","arrow","rect","highlight","erase"].map(At=>({name:At,title:()=>ot(`toolbar.annotate.${At}`),icon:ct[At],run:()=>Ve.annotate?.use(At),active:()=>Ve.annotate?.tool===At,annotation:!0}));return St.push(Je(Ve,ot,pt)),St}function Je(Ve,pt,ct){return{name:"clearAll",title:()=>pt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ve.annotate?.count||0)>0,annotation:!0,run:()=>Qe(Ve,pt,ct)}}function Qe(Ve,pt,ct){const ot=Ve.toolPanel;if(!ot)return;const St=ft=>ct?.announce?.(pt(ft),{repeat:!0});ot.removeAction("clearAll");const At=()=>{ot.removeAction("clearAllConfirm"),ot.removeAction("clearAllKeep"),ot.addAction(Je(Ve,pt,ct))};ot.addAction({name:"clearAllConfirm",title:()=>pt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ve.annotate?.clear(),At(),St("a11y.annotate.cleared")}}),ot.addAction({name:"clearAllKeep",title:()=>pt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>At()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function it(Ve){let pt=null,ct=null;return Ve.on("source:error",ot=>{const St=ot&&ot.error;ct=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(Ve.messages?Ve.messages.t("overlay.error"):"Something went wrong")}),Ve.on("rows:changed",()=>{ct=null}),{loadError:()=>ct,rowCount:()=>{if(H(Ve.rows.matchCount))return Ve.rows.matchCount();const ot=Ve.pagination&&H(Ve.pagination.get)?Ve.pagination.get():null;return ot&&Number.isFinite(ot.total)?ot.total:Ve.rows.count()},totalRowCount:()=>H(Ve.rows.totalCount)?Ve.rows.totalCount():Ve.rows.count(),selectedAcrossSource:()=>{pt||(pt=H(Ve.rendererHost)?Ve.rendererHost():{});const ot=H(pt.selectionSummary)?pt.selectionSummary():null;return ot&&ot.predicate?{count:ot.count}:null},selectedCount:()=>{const ot=Ve.selection&&Ve.selection.keys?Ve.selection.keys():null;return ot?ot.length:0},rangeValues:()=>{const ot=Ve.selection;return!ot||!H(ot.cells)?[]:ot.cells().map(({key:St,colId:At})=>Ve.rows.value(St,At))},hiddenUnresolved:()=>H(Ve.comments&&Ve.comments.hiddenUnresolved)?Ve.comments.hiddenUnresolved():0,progress:()=>H(Ve.source&&Ve.source.progress)?Ve.source.progress():null,updateStats:()=>Ve.updates?Ve.updates.stats():null}}function gt(Ve,pt){for(const[ct,ot]of Object.entries(d||{}))Ve.register("editor",ct,ot);for(const[ct,ot]of Object.entries(i||{}))Ve.register("filter",ct,ot);for(const[ct,ot]of Object.entries(pt.components||{}))Ve.register("component",ct,ot);for(const[ct,ot]of Object.entries(pt.pipes||{}))Ve.register("pipe",ct,ot);for(const[ct,ot]of Object.entries(pt.totalFns||{}))Ve.register("totalFn",ct,ot)}function wt(Ve,pt,ct,ot,St,At){const ft=[],Nt=pt.viewport;let Dt=null;if(ct.maximise!==!1&&(Dt=new ke({element:At,document:ot,onChange:()=>pt.invalidate("all"),captureScroll:()=>pt.scrollState(),restoreScroll:lt=>pt.restoreScroll(lt)}),Ve.maximise=Dt,ft.push(()=>Dt.destroy())),ct.statusBar){const lt=typeof ct.statusBar=="object"?ct.statusBar:{},vt=new c;vt.init({document:ot,host:it(Ve),panels:lt.panels,registry:lt.registry,locale:Ve.get("locale"),messages:Ve.messages}),Nt.statusBar.appendChild(vt.element());const Rt=()=>{const on=Nt.statusBar.offsetHeight||Nt.statusBar.getBoundingClientRect?.().height||0;Nt.root.style.setProperty("--lattice-status-height",`${Math.ceil(on)}px`)},Ht=()=>{vt.refresh(),Rt()},Gt=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(on=>Ve.on(on,Ht));Ht(),Rt(),ft.push(()=>{for(const on of Gt)on();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const _t=oe(ct.selection);if(_t.ranges){const lt=new ce({grid:Ve,renderer:pt,document:ot});lt.mount(),Ve.ranges=lt,ft.push(()=>lt.destroy())}if(ct.import){const lt=new de({grid:Ve,renderer:pt,document:ot,settings:typeof ct.import=="object"?ct.import:{}});Ve.importer=lt,ft.push(()=>lt.destroy())}if(ct.historyBar){const lt=typeof ct.historyBar=="object"?ct.historyBar.element:null,vt=new Te;vt.init({document:ot,host:{undo:()=>Ve.history.undo(),redo:()=>Ve.history.redo(),canUndo:()=>Ve.history.canUndo(),canRedo:()=>Ve.history.canRedo(),peek:Ht=>Ve.history.peek(Ht),list:()=>Ve.history.list()},props:typeof ct.historyBar=="object"?ct.historyBar:{}}),(lt||Nt.root).appendChild(vt.element());const Rt=[Ve.on("history:changed",()=>vt.refresh())];Ve.historyBar=vt,ft.push(()=>{for(const Ht of Rt)Ht();vt.destroy()})}if(ct.diff){const lt=new Ce({grid:Ve,renderer:pt});lt.mount(),Ve.diffPainter=lt,ft.push(()=>lt.destroy())}if(ct.ai&&H(ct.ai.ask)){const lt=new je;lt.init({document:ot,grid:Ve,ask:ct.ai.ask,schemaOptions:ct.ai.schemaOptions,context:ct.ai.context,placeholder:ct.ai.placeholder});const vt=ct.ai.element||Nt.root;vt===Nt.root?vt.insertBefore(lt.element(),vt.firstChild):vt.appendChild(lt.element()),Ve.promptBar=lt,ft.push(()=>lt.destroy())}if(ct.groupPanel){const lt=typeof ct.groupPanel=="object"?ct.groupPanel:{},vt=new p;vt.init({document:ot,grid:Ve,host:J(Ve,ot,(Rt,Ht)=>pt.announce?.(Rt,Ht)),props:{header:Nt.header,hint:lt.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),Ve.groupPanel=vt;for(const Rt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ve.on)&&ft.push(Ve.on(Rt,()=>vt.refresh()));ft.push(()=>vt.destroy())}if(ct.kpis){const lt=new ze({grid:Ve,document:ot,kpis:ct.kpis});lt.active&&(lt.mount(),Nt.root.insertBefore(lt.element(),Nt.header),Ve.kpiStrip=lt,ft.push(()=>lt.destroy()))}if(ct.toolPanel){const lt=typeof ct.toolPanel=="object"?ct.toolPanel:{},vt=new Z({grid:Ve,document:ot,root:Nt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:xe(Ve,lt,Dt,pt),announce:(Rt,Ht)=>pt.announce?.(Rt,Ht)});vt.mount(),Ve.toolPanel=vt,ft.push(()=>vt.destroy()),lt.annotate===void 0&&(ft.push(Ve.on("presentation:started",()=>{for(const Rt of Be(Ve,pt))vt.addAction(Rt)})),ft.push(Ve.on("presentation:ended",()=>{for(const Rt of at)vt.removeAction(Rt)})))}if(!!ct.pagination&&(()=>{const lt=typeof ct.pagination=="object"?ct.pagination:{};return Ve.pagination.set({pageSize:Number(lt.pageSize)||100}),Ve.pagination.get().pageSize>0})()){const lt=typeof ct.pagination=="object"?ct.pagination:{},vt=new s;vt.init({document:ot,pageSize:lt.pageSize,pageSizes:lt.pageSizes,page:lt.page,total:lt.total,locale:Ve.get("locale"),messages:Ve.messages,onChange:({page:Gt,pageSize:on})=>Ve.pagination.set({page:Gt,pageSize:on})});const Rt=()=>{const Gt=Ve.pagination.get();vt.total=Gt.total,vt.counting=Gt.counting===!0,vt.hasMore=Gt.total==null&&Gt.pageCount>Gt.page+1,vt.page=Gt.page,vt.paint()};Ve.pagination.set({pageSize:vt.pageSize}),Rt();const Ht=["rows:changed","filter:changed","model:changed"].map(Gt=>Ve.on(Gt,Rt));Nt.statusBar.appendChild(vt.element()),ft.push(()=>{for(const Gt of Ht)Gt();vt.destroy?.()})}if(ct.edit!==!1)if(ct.editBar){const lt=new se({grid:Ve,document:ot,root:Nt.root});lt.mount(),Ve.editBar=lt,ft.push(()=>lt.destroy())}else{const lt=new ne({grid:Ve,document:ot,renderer:pt,registry:St,cellLayer:pt.cellLayer});lt.mount(),ft.push(()=>lt.destroy())}const cn=new y({grid:Ve,document:ot,layer:Nt.overlays,registry:St});cn.mount(),ft.push(()=>cn.destroy());const qt=new R({grid:Ve,document:ot,host:Nt.root,cellMenu:ct.contextMenu!==!1,headerMenu:ct.columnMenu!==!1,items:H(ct.contextMenu)?ct.contextMenu:void 0,headerItems:H(ct.columnMenu)?ct.columnMenu:void 0});if(qt.mount(),ft.push(()=>qt.destroy()),Array.isArray(ct.alignedGrids)&&ct.alignedGrids.length){const lt=new C;lt.add(Ve);for(const vt of ct.alignedGrids)vt&&vt!==Ve&<.add(vt);ft.push(()=>lt.destroy())}const Wt=new G({grid:Ve,renderer:pt,document:ot,registry:St});Wt.active&&(Wt.mount(),ft.push(()=>Wt.destroy())),Object.defineProperty(Ve,"form",{configurable:!0,value:Object.freeze({open(lt){return Wt.active?Wt.openRow(lt):!1},openNew(lt){return Wt.active?Wt.openNew(lt):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){Wt.active&&Wt.close()},save(){return Wt.active?Wt.save():!1},isOpen(){return Wt.active?Wt.open:!1}})}),ft.push(()=>{delete Ve.form}),Object.defineProperty(Ve,"icons",{configurable:!0,value:Object.freeze({get(lt){const vt=t(lt);return vt?{viewBox:vt.viewBox,paths:vt.paths.slice(),paint:vt.paint==="stroke"?"stroke":"fill"}:null},names(){return n()}})}),ft.push(()=>{delete Ve.icons});const Mt=new $({grid:Ve,renderer:pt,document:ot});Mt.active&&(Mt.mount(),ft.push(()=>Mt.destroy()));const xt=new v({grid:Ve,renderer:pt,document:ot});xt.active&&(xt.mount(),ft.push(()=>xt.destroy()));const Bt=new T({grid:Ve,renderer:pt,document:ot});if(Bt.active){Bt.mount(),Bt.paint();const lt=Ve.on("render:done",()=>Bt.paint());ft.push(()=>{lt(),Bt.destroy()})}if(ct.shortcuts!==!1){const lt=new F({grid:Ve,renderer:pt});lt.mount(),ft.push(()=>lt.destroy())}const Kt=new Ne({grid:Ve,renderer:pt,window:ot.defaultView||void 0});Kt.mount(),ft.push(()=>Kt.destroy());const Qt=new He({grid:Ve,renderer:pt,window:ot.defaultView||void 0});if(Qt.mount(),ft.push(()=>Qt.destroy()),ct.find!==!1){const lt=new Oe({grid:Ve,renderer:pt,document:ot,settings:ct.find});lt.mount(),ft.push(()=>lt.destroy())}const Yt=new Ze({grid:Ve,renderer:pt});Yt.mount(),ft.push(()=>Yt.destroy());const Jt=new st({grid:Ve,renderer:pt});Jt.mount(),ft.push(()=>Jt.destroy());const nn=new yt({grid:Ve,renderer:pt,maximiser:Dt});nn.mount(),ft.push(()=>nn.destroy());const en=new It({grid:Ve,renderer:pt});en.mount(),ft.push(()=>en.destroy()),ct.environment||Ve.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let un=null;for(const[lt,vt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ft.push(Ve.on(lt,()=>{un=vt}));ft.push(Ve.on("render:done",lt=>{Ve.diagnostics.render(un||lt.cause,lt.phases),un=null}));const an=ot.defaultView;if(an&&H(an.requestAnimationFrame)){let lt=an.requestAnimationFrame(function vt(Rt){Ve.diagnostics.frame(Rt),lt=an.requestAnimationFrame(vt)});ft.push(()=>{H(an.cancelAnimationFrame)&&an.cancelAnimationFrame(lt)})}const gn=new ve({grid:Ve,renderer:pt});if(gn.mount(),ft.push(()=>gn.destroy()),ft.push(Ve.on("presence:lockRefused",lt=>gn.announceRefusal(lt.peer))),Ve.presence&&Ve.presence.enabled){for(const Rt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ft.push(Ve.on(Rt,()=>Ve.presence.publish()));let lt="";ft.push(Ve.on("render:done",()=>{const Rt=pt.focusState&&pt.focusState(),Ht=Rt?`${Rt.rowKey}${Rt.colId}`:"";Ht!==lt&&(lt=Ht,Ve.presence.publish())}));const vt=At.ownerDocument;if(vt&&H(vt.addEventListener)){const Rt=()=>Ve.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Rt),Rt(),ft.push(()=>vt.removeEventListener("visibilitychange",Rt))}}const yn=new nt({grid:Ve,renderer:pt});yn.mount(),ft.push(()=>yn.destroy());const bn=new We({grid:Ve,renderer:pt});bn.mount(),ft.push(()=>bn.destroy()),ft.push(Ve.on("facet:computed",()=>pt.refreshHeader?.())),_t&&_t.headerCheckbox===!0&&ft.push(Ve.on("selection:changed",()=>pt.refreshHeader?.())),ft.push(Ve.on("facet:expanded",()=>pt.invalidate("columns"))),ft.push(Ve.on("model:changed",()=>pt.invalidate("rows")));const Zt=(lt,vt)=>pt.announce?.(lt,vt),dn=Ve.messages,Vt=(lt,vt)=>dn.t(lt,vt),mn=lt=>Vt("count.rows",{count:lt});ft.push(Ve.on("sort:changed",()=>{const lt=Ve.sort.get();if(!lt.length){Zt(Vt("a11y.sort.cleared"));return}const vt=lt.map(Rt=>{const Ht=Ve.columns.get(Rt.col);return Vt("a11y.sort.column",{column:Ht&&Ht.title||Rt.col,direction:Vt(Rt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Vt("a11y.sort.by",{columns:dn.list(vt)}))})),ft.push(Ve.on("filter:changed",()=>{const lt=Ve.rows.matchCount?Ve.rows.matchCount():Ve.rows.count();if(lt===null)return;const vt=Ve.rows.totalCount?Ve.rows.totalCount():lt;Zt(lt===vt?Vt("a11y.filter.cleared",{rows:mn(vt)}):Vt("a11y.filter.applied",{shown:mn(lt),total:mn(vt)}))})),ft.push(Ve.on("selection:changed",()=>{const lt=Ve.selection.keys().length;Zt(lt===0?Vt("a11y.selection.cleared"):Vt("a11y.selection.count",{count:lt}))})),ft.push(Ve.on("group:toggled",lt=>{const vt=Ve.rows.byKey?Ve.rows.byKey(lt.key):null,Rt=(vt&&(vt.groupLabel??vt.groupValue))??lt.key;Zt(Vt(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Rt,rows:mn(Ve.rows.count())}))})),ft.push(Ve.on("column:grouped",lt=>{const vt=Array.isArray(lt.columns)?lt.columns:[];if(!vt.length){Zt(Vt("a11y.group.cleared"));return}const Rt=vt.map(Ht=>{const Gt=Ve.columns.get(Ht);return Gt&&Gt.title||Ht});Zt(Vt("a11y.group.by",{columns:dn.list(Rt)}))})),ft.push(Ve.on("page:changed",lt=>{const vt=Number(lt.size)||0,Rt=Number(lt.total)||0,Ht=vt>0?Math.max(1,Math.ceil(Rt/vt)):1;Zt(Vt("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Ht}))}));let rn={added:0,removed:0},Xt=null;const Fn=()=>{Xt=null;const lt=[];rn.added&<.push(Vt("count.rowsAdded",{count:rn.added})),rn.removed&<.push(Vt("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},lt.length&&Zt(dn.list(lt))};ft.push(Ve.on("rows:changed",lt=>{if(!lt||typeof lt.added!="number")return;const vt=Number(lt.added)||0,Rt=Number(lt.removed)||0;!vt&&!Rt||(rn.added+=vt,rn.removed+=Rt,Xt||(Xt=setTimeout(Fn,Se)))})),ft.push(()=>{Xt&&clearTimeout(Xt)}),ft.push(Ve.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),rn={added:0,removed:0},Zt(Vt("a11y.updates.paused"),{repeat:!0})})),ft.push(Ve.on("rows:resumed",()=>Zt(Vt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},fn=null;const Pn=()=>{fn=null;const{count:lt,first:vt}=hn;if(hn={count:0,first:null},!lt||!vt)return;const Rt=Ve.columns.get(vt.colId),Ht=Rt&&Rt.title||vt.colId,Gt=vt.reason?Vt("a11y.edit.reason",{reason:vt.reason}):"";if(lt===1){const on=vt.restored===void 0||vt.restored===null||vt.restored===""?Vt("value.empty"):String(vt.restored);Zt(Vt("a11y.edit.refusedOne",{column:Ht,value:on,reason:Gt}),{repeat:!0});return}Zt(Vt("a11y.edit.refusedMany",{count:lt,reason:Gt}),{repeat:!0})};ft.push(Ve.on("cell:reverted",lt=>{!lt||!lt.applied||(hn.count+=1,hn.first||(hn.first=lt),fn||(fn=setTimeout(Pn,150)))})),ft.push(()=>{fn&&clearTimeout(fn)}),ft.push(Ve.on("history:applied",lt=>{const vt=!!(lt&<.direction==="redo"),Rt=lt&<.step&<.step.label;Zt(Rt?Vt(vt?"a11y.history.redo":"a11y.history.undo",{label:Rt}):Vt(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Et({grid:Ve,renderer:pt,seed:ct.state&&Array.isArray(ct.state.annotations)?ct.state.annotations:null});wn.mount(),ft.push(()=>wn.destroy()),Ve.annotate=wn,Ve.capture=async(lt={})=>{const{blob:vt,width:Rt,height:Ht}=await Ct(pt.viewport.root,lt);return(lt.download===!0||lt.download!==!1&<.fileName)&&X(vt,lt.fileName||`${Ve.get("exportName")||"grid"}.png`),Ve.emit("presentation:captured",{width:Rt,height:Ht,bytes:vt.size,mimeType:vt.type,fileName:lt.fileName||null},"api"),vt};const Cn=new qe({grid:Ve,document:ot,element:Nt.overlays,window:ot.defaultView||void 0});Cn.mount(),ft.push(()=>Cn.destroy());const xn=new f({grid:Ve,document:ot,element:Nt.overlays});xn.mount?.(),ft.push(()=>xn.destroy?.());const En=new A({grid:Ve,host:Ve.rendererHost(),viewport:Nt,document:ot});return En.mount(),ft.push(()=>En.destroy()),ft}function dt(Ve){const pt=[],ct=ot=>{if(ot&&(ot.__lattice&&pt.push(ot),ot.children))for(const St of ot.children)ct(St)};return ct(Ve),pt}function jt(Ve,pt={}){(!Ve||typeof Ve!="object"||!("appendChild"in Ve))&&V("createGrid needs a host element as its first argument."),pt=I(pt);const ct=Ve.ownerDocument||(typeof document<"u"?document:null);ct||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ot=ct.documentElement&&ct.documentElement.lang,St=!pt.licence&&H(ct.querySelector)?ct.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,At={...pt};if(!pt.locale&&ot&&(At.locale=ot),St&&(At.licence=St),pt.views&&pt.views.local)if(pt.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=pt.views.local===!0?{}:pt.views.local;At.views={...pt.views,storage:j(qt)}}const ft=x(At),Nt=ft.rendererHost();Nt.document=ct,gt(Nt.registry,pt),Nt.cellLayer=a(Nt),Nt.detailHost=new be({grid:ft,document:Ve.ownerDocument||globalThis.document,createGrid:(qt,Wt)=>jt(qt,Wt)});const Dt=new u(Ve,Nt),_t=ft.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),pn=ft.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});ft.on("destroy",()=>{_t(),pn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),ft.attachRenderer(Dt),Dt.mount();const sn=wt(ft,Dt,pt,ct,Nt.registry,Ve),cn=ft.destroy.bind(ft);return ft.destroy=()=>{for(const qt of sn)try{qt()}catch{}Ve.__lattice===ft&&(Ve.__lattice=null),cn()},Ve.__lattice=ft,ft}}),Le("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,B=Q.warnOnce,I=K("packages/core/src/columns/datatypes.js"),_=I.BUILTIN_TYPES,X=I.parseNumberText,V=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,z=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),j=w.toIsoDate,g=w.toIsoDateTime,h=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(V)]);function r(s,p){for(const b of s.children)if(b.tagName===p.toUpperCase())return b;return null}function t(s,p){const b=[];for(const A of s.children)A.tagName===p.toUpperCase()&&b.push(A);return b}function n(s,p){const b=x(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function o(s){const p=s.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function d(s,p){return p==="text"?s===""?null:s:p==="boolean"?z(s):p==="number"?X(s):p==="date"||p==="dateString"?j(s):p==="datetime"?g(s):o(s)}function l(s){const p=r(s,"thead"),b=r(p||s,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((O,F)=>{const E=n(O,F),T={id:E,field:E,title:String(O.textContent||"").trim()||E},L=x(O.getAttribute)?O.getAttribute("data-type"):null;L&&(a.has(L)?T.type=L:B(`hydrate.unknownType:${L}`,`data-type "${L}" on column "${E}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const C=x(O.getAttribute)?O.getAttribute("data-format"):null;return C&&(T.format=C),T}),y=r(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(O=>O!==b)).map((O,F)=>{const E=t(O,"td"),L={__row:(x(O.getAttribute)?O.getAttribute("data-id"):null)||`row${F}`};return k.forEach((C,D)=>{L[C.field]=E[D]?C.type?d(String(E[D].textContent||""),C.type):o(String(E[D].textContent||"")):null}),L});return{columns:k,rows:R}}function i(s,p){if(p===void 0)return s;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const k of p)if(k&&typeof k=="object"){const y=k.id??k.field;y!=null&&b.set(y,k)}const A=s.map(k=>{const y=b.get(k.id)??b.get(k.field);return y===void 0?k:{...k,...y}});for(const[k,y]of b)s.some(S=>S.id===k||S.field===k)||A.push({...y});return A}const m="data-lattice-hydrate-config";function c(s,p,b={}){const{columns:A,rows:k}=l(p);return h(s,{rowKey:"__row",...b,columns:i(A,b.columns),rows:b.rows!==void 0?b.rows:k})}function f(s,p={}){const b=s.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),s.removeAttribute("data-lattice-grid"),b.__latticeTable=s;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return s.parentNode.insertBefore(b,s),s.parentNode.removeChild(s),c(b,s,p)}}),Le("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const x=K("packages/core/src/internal/util.js").isFunction,I=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,j){const g=[];return x(w.hasAttribute)&&w.hasAttribute(j)&&g.push(w),x(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${j}]`)),g}function V(w){const j=w.parentNode;if(!j||!j.children)return null;const g=[...j.children],u=g.indexOf(w),h=[g[u+1],g[u-1]];for(const a of h)if(a&&a.tagName==="SCRIPT"&&x(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function H(w){const j=V(w);if(!j)return{};try{return JSON.parse(j.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const j=w||(typeof document<"u"?document:null);if(!j)return[];const g=[];for(const u of W(j,"data-lattice-grid")){if(u.__lattice)continue;const h=H(u);g.push(u.tagName==="TABLE"?X(u,h):I(u,h))}return g}}),Le("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q=K("packages/dom/src/createGrid.js"),x=Q.createGrid,B=K("packages/dom/src/hydrate.js"),I=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),V=W.createLocalViewStorage,H=K("packages/core/src/index.js"),z=H.createHeadlessGrid,w=H.registerModules,j=H.setLicence,g=H.version,u=H.getVersion,h=H.serialiseState,a=H.restoreState,r=H.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return H.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return H.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return H.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return H.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return H.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return H.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return H.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return H.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return H.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return H.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return H.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return H.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return H.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return H.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return H.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return H.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return H.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return H.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return H.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return H.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return H.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return H.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return H.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return H.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return H.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return H.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return H.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return H.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return H.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return H.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return H.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return H.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return H.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return H.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return H.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return H.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return H.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return H.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return H.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return H.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return H.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return H.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return H.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return H.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return H.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return H.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return H.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return H.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return H.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return H.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return H.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return H.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return H.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return H.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return H.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return H.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return H.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return H.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return H.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return H.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return H.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return H.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return H.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return H.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return H.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return H.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return H.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return H.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return H.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return H.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return H.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return H.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return H.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return H.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return H.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return H.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return H.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return H.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return H.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return H.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return H.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return H.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return H.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return H.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return H.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return H.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return H.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return H.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return H.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return H.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return H.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return H.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return H.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return H.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return H.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return H.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return H.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return H.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return H.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return H.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return H.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return H.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return H.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return H.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return H.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return H.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return H.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return H.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return H.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return H.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return H.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return H.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return H.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return H.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return H.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return H.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return H.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return H.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return H.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return H.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return H.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return H.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return H.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return H.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return H.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return H.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return H.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return H.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return H.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return H.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return H.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return H.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return H.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return H.VERSION}});const n=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return n.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const d=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return d.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return d.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return d.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const s=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return s.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const A=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return A.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return A.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return A.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return A.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return A.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return A.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return A.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return A.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return A.sanitiseHtml}});const k=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return k.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return k.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return k.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return k.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const S=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return S.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return S.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return S.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return S.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return S.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const O=Object.freeze({createGrid:x,createHeadlessGrid:z,defaults:r,registerModules:w,setLicence:j,version:g,autoInit:X,hydrateTable:I,serialiseState:h,restoreState:a,createLocalViewStorage:V}),F=O});try{Rn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.88.3";async function he(){return ae}const W="1.88.3",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-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 h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#t=0;#e=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.#t}add(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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.#e}get size(){return this.#t.length}add(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"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"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=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",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 q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("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 t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var Ln=Rn("packages/dom/src/index.js");typeof module=="object"&&module.exports?module.exports=Ln:typeof define=="function"&&define.amd?define(function(){return Ln}):fr.LatticeGrid=Ln})(typeof globalThis<"u"?globalThis:this);
|
|
58
58
|
|
|
59
59
|
//# sourceMappingURL=lattice-grid.min.js.map
|