@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.88.
|
|
2
|
+
* Lattice Grid 1.88.3, webcomponent module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
(function(_n){"use strict";var qn=Object.create(null),Zn=Object.create(null);function Le(e,K){qn[e]=K}function Ln(e){var K=Zn[e];if(K)return K;var Q=Object.create(null);Zn[e]=Q;var F=qn[e];if(!F)throw new Error("[lattice] missing module: "+e);return F(Q,Ln),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 l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return o}}),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 j}}),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 I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return C}}),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 F(){return Q}const B="1.88.2",$=new Set,_=2e3;function X(oe){if($.add(oe),$.size>_){const le=$.values().next().value;le!==void 0&&$.delete(le)}}const W=[],H=500;function U(oe,le,ae){W.push({key:oe,level:le,message:ae.map(se=>typeof se=="string"?se:z(se)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(oe){if(oe instanceof Error)return oe.message;try{return JSON.stringify(oe)}catch{return String(oe)}}function w(){return W.map(oe=>({...oe}))}function v(oe){if(oe.length===0||typeof oe[0]!="string")return oe;const le=oe[0].replace(/^\[lattice\]\s*/,"");return le===oe[0]?oe:[le,...oe.slice(1)]}function g(oe,...le){if($.has(oe))return;X(oe);const ae=v(le);U(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if($.has(oe))return;X(oe);const ae=v(le);U(oe,"info",ae),console.info("[lattice]",...ae)}function d(){$.clear(),W.length=0}function a(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function n(oe,le){oe||a(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function i(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function o(oe){return typeof oe!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(oe))?!0:!!(oe.prototype&&Object.getOwnPropertyNames(oe.prototype).length>1)}const m=new Map;function c(oe){let le=m.get(oe);if(le)return le;if(!oe.includes("."))le=ae=>ae?.[oe];else{const ae=oe.split("."),se=ae.length;le=ee=>{let ie=ee;for(let ce=0;ce<se;ce++){if(ie==null)return;ie=ie[ae[ce]]}return ie}}return m.set(oe,le),le}const h=new Map;function s(oe){let le=h.get(oe);if(le)return le;if(!oe.includes("."))le=(ae,se)=>{ae!=null&&(ae[oe]=se)};else{const ae=oe.split("."),se=ae.length-1;le=(ee,ie)=>{let ce=ee;for(let he=0;he<se;he++){if(ce==null)return;const ge=ae[he];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return c(le)(oe)}function b(oe,le,ae){s(le)(oe,ae)}function A(oe){return oe?(oe.includes(".")?oe.slice(oe.lastIndexOf(".")+1):oe).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(/^./,ae=>ae.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>k[ae]):le}function S(oe){return String(oe).replace(/\w\S*/g,le=>le[0].toUpperCase()+le.slice(1).toLowerCase())}function R(oe,le,ae){if(oe!==void 0)return oe===!0?{enabled:!0,...ae}:oe===!1?{enabled:!1}:r(oe)?oe:{[le]:oe,enabled:!0}}function j(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(oe,le){if(!r(oe))return r(le)?{...le}:le;if(!r(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(x.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=r(ee)&&r(ae[se])?E(ae[se],ee):ee)}return ae}function T(oe,le){if(!r(oe)||!r(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class L{#e;#t=new Map;#n;constructor(le=256,ae=null){this.#e=le,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(le){this.#e=le,this.#r()}has(le){return this.#t.has(le)}get(le){const ae=this.#t;if(!ae.has(le))return;const se=ae.get(le);return ae.delete(le),ae.set(le,se),se}peek(le){return this.#t.get(le)}set(le,ae){const se=this.#t;return se.has(le)&&se.delete(le),se.set(le,ae),this.#r(),ae}delete(le){const ae=this.#t.get(le);return this.#t.delete(le)&&this.#n&&this.#n(ae,le),ae}clear(){if(this.#n)for(const[le,ae]of this.#t)this.#n(ae,le);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const le=this.#t;for(;le.size>this.#e;){const ae=le.keys().next().value,se=le.get(ae);le.delete(ae),this.#n&&this.#n(se,ae)}}}const P=new Map;function D(oe,le){const ae=`${oe||""}|${le?JSON.stringify(le):""}`;let se=P.get(ae);return se||(se=new Intl.Collator(oe||void 0,{numeric:!0,sensitivity:"variant",...le}),P.set(ae,se)),se}function I(oe,le){if(oe===le)return 0;if(oe==null)return 1;if(le==null)return-1;if(typeof oe=="number"&&typeof le=="number")return Number.isNaN(oe)?Number.isNaN(le)?0:1:Number.isNaN(le)||oe<le?-1:oe>le?1:0;const ae=String(oe),se=String(le);return ae<se?-1:ae>se?1:0}function C(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function N(oe){return O?requestAnimationFrame(oe):setTimeout(()=>oe(C()),16)}function G(oe){oe!=null&&(O?cancelAnimationFrame(oe):clearTimeout(oe))}function q(oe){let le=null,ae=null;const se=()=>{le=null;const ie=ae;ae=null,oe(...ie||[])},ee=(...ie)=>{ae=ie,le===null&&(le=N(se))};return ee.cancel=()=>{G(le),le=null,ae=null},ee.flush=()=>{le!==null&&(G(le),se())},ee}function Z(oe,le){let ae=null,se=null;const ee=()=>{if(ae=null,se===null)return;const he=se;se=null,oe(...he),ie()},ie=()=>{ae=setTimeout(ee,le),typeof ae?.unref=="function"&&ae.unref()},ce=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return ce.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},ce.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},ce.pending=()=>ae!==null||se!==null,ce}function J(oe,le=50){return typeof requestIdleCallback=="function"?requestIdleCallback(oe,{timeout:le}):setTimeout(()=>oe({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function ne(oe="l"){return`${oe}${(++te).toString(36)}`}}),Le("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return $}}),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 U}}),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 v}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),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"),F=Q.isFunction,B=Q.warnOnce,$=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,j){const x=Number(R),E=Number(j);if(R!==null&&R!==""&&j!==null&&j!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const L=String(R??"").toLowerCase(),P=String(j??"").toLowerCase();return L<P?-1:L>P?1:0}function H(R){return R==null||R===""}function U(R,j){if(!j||typeof j!="object")return!1;const{op:x}=j,E=j.value,T=j.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){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,j,x){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,P]=E(R),[D,I,C]=E(j),O=Math.max(0,Math.min(1,x)),N=(G,q)=>Math.round(G+(q-G)*O);return`#${[N(T,D),N(L,I),N(P,C)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const j=[];for(const D of R||[]){if(D==null||D==="")continue;const I=D instanceof Date?D.getTime():Number(D);Number.isFinite(I)&&j.push(I)}if(!j.length)return null;j.sort((D,I)=>D-I);let x=0,E=0,T=0;for(const D of j){x++;const I=D-E;E+=I/x,T+=I*(D-E)}const L=v(j,.25),P=v(j,.75);return{n:j.length,min:j[0],max:j[j.length-1],mean:E,stddev:j.length>1?Math.sqrt(T/(j.length-1)):0,median:v(j,.5),q1:L,q3:P,iqr:P-L,sorted:j}}function v(R,j){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,j)),E=Math.floor(x),T=Math.ceil(x);return E===T?R[E]:R[E]+(x-E)*(R[T]-R[E])}function g(R){for(const j of Array.isArray(R)?R:[])if(!(!j||typeof j!="object")&&(j.when&&_.includes(j.when.op)||j.scale&&j.scale.from||j.dataBar&&!(Number.isFinite(Number(j.dataBar.min))&&Number.isFinite(Number(j.dataBar.max)))||j.iconSet&&!Array.isArray(j.iconSet.thresholds)))return!0;return!1}function l(R,j){const x=Number(R.value),E=T=>v(j.sorted,T);switch(R.op){case"topPercent":{const T=d(x,10);return{op:"gte",value:E(1-T)}}case"bottomPercent":{const T=d(x,10);return{op:"lte",value:E(T)}}case"topN":{const T=Math.max(1,Math.floor(x)||1),L=Math.max(0,j.sorted.length-T);return{op:"gte",value:j.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(x)||1),L=Math.min(j.sorted.length-1,T-1);return{op:"lte",value:j.sorted[L]}}case"aboveMean":return{op:"gt",value:j.mean};case"belowMean":return{op:"lt",value:j.mean};case"aboveMedian":return{op:"gt",value:j.median};case"belowMedian":return{op:"lt",value:j.median};case"zAbove":return j.stddev?{op:"gte",value:j.mean+(Number.isFinite(x)?x:2)*j.stddev}:null;case"zBelow":return j.stddev?{op:"lte",value:j.mean-(Number.isFinite(x)?x:2)*j.stddev}:null;case"outlier":{const T=(Number.isFinite(x)&&x>0?x:1.5)*j.iqr;return j.iqr?{op:"outside",value:j.q1-T,value2:j.q3+T}:null}default:return null}}function d(R,j){const x=Number.isFinite(R)?R:j,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function a(R,j){if(R.from==="minmax")return{...R,min:j.min,max:j.max};if(R.from==="quantile")return{...R,min:v(j.sorted,d(Number(R.low),5)),max:v(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:j.mean-x*j.stddev,max:j.mean+x*j.stddev}}return R}function n(R,j){const x=Array.isArray(R)?R:[];return!j||!j.n?x.map(E=>E&&g([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:a(E.scale,j)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,j)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,j)};if(!E.when||!_.includes(E.when.op))return E;const T=l(E.when,j);return T?{...E,when:T}:{...E,enabled:!1}})}function t(R,j){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,E=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&E!==void 0)return{...R,min:x,max:E};if(R.from==="quantile")return{...R,min:x??v(j.sorted,d(Number(R.low),5)),max:E??v(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??j.mean-T*j.stddev,max:E??j.mean+T*j.stddev}}return{...R,min:x??j.min,max:E??j.max}}function r(R,j){if(Array.isArray(R.thresholds))return R;const x=i(R),E=[];for(let T=1;T<x;T++)E.push(v(j.sorted,T/x));return{...R,thresholds:E}}function i(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 j=s[R.set];return j?j.length:3}function f(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(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 o(R,j){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${j==="up"?"8,2 14,13 2,13":j==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,j){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${j*16} 16">`;for(let T=0;T<j;T++){const L=T<R?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${T*16},0)" d="${x}" fill="${L}"/>`}return`${E}</svg>`}const c=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:h,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("<")?f(String(E)):String(E));const j=R.set||"arrows";if(j==="ratings"){const E=i(R),T=[];for(let L=1;L<=E;L++)T.push(f(m(L,E)));return T}const x=s[j];return x?x.map(f):(B(`iconSet:${j}`,`unknown icon set '${j}'; falling back to arrows.`),c.map(f))}function A(R){const j=Number(R.min),E=Number(R.max)-j,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",P=R.direction==="rtl"?"left":"right",D=C=>Math.max(0,Math.min(1,(C-j)/E))*100,I=E?Math.max(0,Math.min(100,(0-j)/E*100)):0;return C=>{if(H(C))return null;const O=Number(C);if(!Number.isFinite(O)||!E)return null;const N=D(O),G=Math.min(N,I),q=Math.max(N,I),Z=O>=0?T:L;return{backgroundImage:`linear-gradient(to ${P}, transparent ${G}%, ${Z} ${G}%, ${Z} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const j=b(R),x=R.reverse?[...j].reverse():j,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*i(R):T;return P=>{if(H(P))return null;const D=Number(P);if(!Number.isFinite(D))return null;let I=0;for(const O of E)D>=O&&I++;const C=x[Math.min(I,x.length-1)];return C?{backgroundImage:C,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const j=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),E=Number(R.max),T=E-x,L=j.length-1,P=[];for(let I=0;I<=L;I++)P.push(L?I/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(j.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${j.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(x,E)&&D<Math.max(x,E)){const I=L/2,C=Math.max(0,Math.min(1,(D-x)/T));for(let O=0;O<=L;O++)P[O]=O<=I?I?O/I*C:C:C+(O-I)/(L-I)*(1-C)}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 I=>{const C=Number(I);if(!Number.isFinite(C)||!T)return null;const O=Math.max(0,Math.min(1,(C-x)/T));let N=0;for(;N<L-1&&O>P[N+1];)N++;const G=P[N+1]-P[N],q=G>0?(O-P[N])/G:0;return{background:z(j[N],j[N+1],Math.max(0,Math.min(1,q)))}}}function S(R,j=null){const x=g(R)?n(R,j):R,E=(Array.isArray(x)?x:[]).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 P=L?L.value:void 0;let D=null;for(const I of T){if(!I.enabled)continue;if(I.scale){const O=I.scale(P);O&&(D={...D||{},...O});continue}if(!U(P,I.when))continue;const C=F(I.style)?I.style(L):I.style;if(C&&(D={...D||{},...C}),I.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 U}}),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 n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",F="str",B="ref",$="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(i,f){super(i),this.name="FormulaError",this.at=f}}function z(r){const i=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
|
|
6
|
+
(function(_n){"use strict";var qn=Object.create(null),Zn=Object.create(null);function Le(e,K){qn[e]=K}function Ln(e){var K=Zn[e];if(K)return K;var Q=Object.create(null);Zn[e]=Q;var F=qn[e];if(!F)throw new Error("[lattice] missing module: "+e);return F(Q,Ln),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 l}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return o}}),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 j}}),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 I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return C}}),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 F(){return Q}const B="1.88.3",$=new Set,_=2e3;function X(oe){if($.add(oe),$.size>_){const le=$.values().next().value;le!==void 0&&$.delete(le)}}const W=[],H=500;function U(oe,le,ae){W.push({key:oe,level:le,message:ae.map(se=>typeof se=="string"?se:z(se)).join(" "),at:Date.now()}),W.length>H&&W.shift()}function z(oe){if(oe instanceof Error)return oe.message;try{return JSON.stringify(oe)}catch{return String(oe)}}function w(){return W.map(oe=>({...oe}))}function v(oe){if(oe.length===0||typeof oe[0]!="string")return oe;const le=oe[0].replace(/^\[lattice\]\s*/,"");return le===oe[0]?oe:[le,...oe.slice(1)]}function g(oe,...le){if($.has(oe))return;X(oe);const ae=v(le);U(oe,"warn",ae),console.warn("[lattice]",...ae)}function l(oe,...le){if($.has(oe))return;X(oe);const ae=v(le);U(oe,"info",ae),console.info("[lattice]",...ae)}function d(){$.clear(),W.length=0}function a(oe,le){const ae=new Error(`[lattice] ${oe}`);throw le!==void 0&&(ae.cause=le),ae}function n(oe,le){oe||a(le)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(oe){return oe!==null&&typeof oe=="object"&&!Array.isArray(oe)}function i(oe){return typeof oe=="function"}function f(oe){return oe==null}function u(oe){return oe==null||oe===""}function o(oe){return typeof oe!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(oe))?!0:!!(oe.prototype&&Object.getOwnPropertyNames(oe.prototype).length>1)}const m=new Map;function c(oe){let le=m.get(oe);if(le)return le;if(!oe.includes("."))le=ae=>ae?.[oe];else{const ae=oe.split("."),se=ae.length;le=ee=>{let ie=ee;for(let ce=0;ce<se;ce++){if(ie==null)return;ie=ie[ae[ce]]}return ie}}return m.set(oe,le),le}const h=new Map;function s(oe){let le=h.get(oe);if(le)return le;if(!oe.includes("."))le=(ae,se)=>{ae!=null&&(ae[oe]=se)};else{const ae=oe.split("."),se=ae.length-1;le=(ee,ie)=>{let ce=ee;for(let he=0;he<se;he++){if(ce==null)return;const ge=ae[he];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[ae[se]]=ie)}}return h.set(oe,le),le}function p(oe,le){return c(le)(oe)}function b(oe,le,ae){s(le)(oe,ae)}function A(oe){return oe?(oe.includes(".")?oe.slice(oe.lastIndexOf(".")+1):oe).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(/^./,ae=>ae.toUpperCase()):""}const k={"&":"&","<":"<",">":">",'"':""","'":"'"};function y(oe){const le=oe==null?"":String(oe);return/[&<>"']/.test(le)?le.replace(/[&<>"']/g,ae=>k[ae]):le}function S(oe){return String(oe).replace(/\w\S*/g,le=>le[0].toUpperCase()+le.slice(1).toLowerCase())}function R(oe,le,ae){if(oe!==void 0)return oe===!0?{enabled:!0,...ae}:oe===!1?{enabled:!1}:r(oe)?oe:{[le]:oe,enabled:!0}}function j(oe){return oe==null?[]:Array.isArray(oe)?oe:[oe]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(oe,le){if(!r(oe))return r(le)?{...le}:le;if(!r(le))return le===void 0?oe:le;const ae={...oe};for(const se of Object.keys(le)){if(x.has(se))continue;const ee=le[se];ee!==void 0&&(ae[se]=r(ee)&&r(ae[se])?E(ae[se],ee):ee)}return ae}function T(oe,le){if(!r(oe)||!r(le)||oe===le)return le;const ae=Object.create(Object.getPrototypeOf(oe));return Object.assign(ae,oe,le),ae}class L{#e;#t=new Map;#n;constructor(le=256,ae=null){this.#e=le,this.#n=ae}get size(){return this.#t.size}get max(){return this.#e}set max(le){this.#e=le,this.#r()}has(le){return this.#t.has(le)}get(le){const ae=this.#t;if(!ae.has(le))return;const se=ae.get(le);return ae.delete(le),ae.set(le,se),se}peek(le){return this.#t.get(le)}set(le,ae){const se=this.#t;return se.has(le)&&se.delete(le),se.set(le,ae),this.#r(),ae}delete(le){const ae=this.#t.get(le);return this.#t.delete(le)&&this.#n&&this.#n(ae,le),ae}clear(){if(this.#n)for(const[le,ae]of this.#t)this.#n(ae,le);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const le=this.#t;for(;le.size>this.#e;){const ae=le.keys().next().value,se=le.get(ae);le.delete(ae),this.#n&&this.#n(se,ae)}}}const P=new Map;function D(oe,le){const ae=`${oe||""}|${le?JSON.stringify(le):""}`;let se=P.get(ae);return se||(se=new Intl.Collator(oe||void 0,{numeric:!0,sensitivity:"variant",...le}),P.set(ae,se)),se}function I(oe,le){if(oe===le)return 0;if(oe==null)return 1;if(le==null)return-1;if(typeof oe=="number"&&typeof le=="number")return Number.isNaN(oe)?Number.isNaN(le)?0:1:Number.isNaN(le)||oe<le?-1:oe>le?1:0;const ae=String(oe),se=String(le);return ae<se?-1:ae>se?1:0}function C(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function N(oe){return O?requestAnimationFrame(oe):setTimeout(()=>oe(C()),16)}function G(oe){oe!=null&&(O?cancelAnimationFrame(oe):clearTimeout(oe))}function q(oe){let le=null,ae=null;const se=()=>{le=null;const ie=ae;ae=null,oe(...ie||[])},ee=(...ie)=>{ae=ie,le===null&&(le=N(se))};return ee.cancel=()=>{G(le),le=null,ae=null},ee.flush=()=>{le!==null&&(G(le),se())},ee}function Z(oe,le){let ae=null,se=null;const ee=()=>{if(ae=null,se===null)return;const he=se;se=null,oe(...he),ie()},ie=()=>{ae=setTimeout(ee,le),typeof ae?.unref=="function"&&ae.unref()},ce=(...he)=>{ae===null?(oe(...he),ie()):(se=he,clearTimeout(ae),ie())};return ce.flush=()=>{if(ae!==null&&clearTimeout(ae),ae=null,se===null)return;const he=se;se=null,oe(...he)},ce.cancel=()=>{ae!==null&&clearTimeout(ae),ae=null,se=null},ce.pending=()=>ae!==null||se!==null,ce}function J(oe,le=50){return typeof requestIdleCallback=="function"?requestIdleCallback(oe,{timeout:le}):setTimeout(()=>oe({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function ne(oe="l"){return`${oe}${(++te).toString(36)}`}}),Le("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return $}}),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 U}}),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 v}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),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"),F=Q.isFunction,B=Q.warnOnce,$=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,j){const x=Number(R),E=Number(j);if(R!==null&&R!==""&&j!==null&&j!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const L=String(R??"").toLowerCase(),P=String(j??"").toLowerCase();return L<P?-1:L>P?1:0}function H(R){return R==null||R===""}function U(R,j){if(!j||typeof j!="object")return!1;const{op:x}=j,E=j.value,T=j.value2;switch(x){case"blank":return H(R);case"notBlank":return!H(R);case"true":return R===!0;case"false":return R===!1;default:break}if(H(R))return!1;switch(x){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,j,x){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,P]=E(R),[D,I,C]=E(j),O=Math.max(0,Math.min(1,x)),N=(G,q)=>Math.round(G+(q-G)*O);return`#${[N(T,D),N(L,I),N(P,C)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const j=[];for(const D of R||[]){if(D==null||D==="")continue;const I=D instanceof Date?D.getTime():Number(D);Number.isFinite(I)&&j.push(I)}if(!j.length)return null;j.sort((D,I)=>D-I);let x=0,E=0,T=0;for(const D of j){x++;const I=D-E;E+=I/x,T+=I*(D-E)}const L=v(j,.25),P=v(j,.75);return{n:j.length,min:j[0],max:j[j.length-1],mean:E,stddev:j.length>1?Math.sqrt(T/(j.length-1)):0,median:v(j,.5),q1:L,q3:P,iqr:P-L,sorted:j}}function v(R,j){if(!R.length)return 0;const x=(R.length-1)*Math.max(0,Math.min(1,j)),E=Math.floor(x),T=Math.ceil(x);return E===T?R[E]:R[E]+(x-E)*(R[T]-R[E])}function g(R){for(const j of Array.isArray(R)?R:[])if(!(!j||typeof j!="object")&&(j.when&&_.includes(j.when.op)||j.scale&&j.scale.from||j.dataBar&&!(Number.isFinite(Number(j.dataBar.min))&&Number.isFinite(Number(j.dataBar.max)))||j.iconSet&&!Array.isArray(j.iconSet.thresholds)))return!0;return!1}function l(R,j){const x=Number(R.value),E=T=>v(j.sorted,T);switch(R.op){case"topPercent":{const T=d(x,10);return{op:"gte",value:E(1-T)}}case"bottomPercent":{const T=d(x,10);return{op:"lte",value:E(T)}}case"topN":{const T=Math.max(1,Math.floor(x)||1),L=Math.max(0,j.sorted.length-T);return{op:"gte",value:j.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(x)||1),L=Math.min(j.sorted.length-1,T-1);return{op:"lte",value:j.sorted[L]}}case"aboveMean":return{op:"gt",value:j.mean};case"belowMean":return{op:"lt",value:j.mean};case"aboveMedian":return{op:"gt",value:j.median};case"belowMedian":return{op:"lt",value:j.median};case"zAbove":return j.stddev?{op:"gte",value:j.mean+(Number.isFinite(x)?x:2)*j.stddev}:null;case"zBelow":return j.stddev?{op:"lte",value:j.mean-(Number.isFinite(x)?x:2)*j.stddev}:null;case"outlier":{const T=(Number.isFinite(x)&&x>0?x:1.5)*j.iqr;return j.iqr?{op:"outside",value:j.q1-T,value2:j.q3+T}:null}default:return null}}function d(R,j){const x=Number.isFinite(R)?R:j,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function a(R,j){if(R.from==="minmax")return{...R,min:j.min,max:j.max};if(R.from==="quantile")return{...R,min:v(j.sorted,d(Number(R.low),5)),max:v(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const x=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:j.mean-x*j.stddev,max:j.mean+x*j.stddev}}return R}function n(R,j){const x=Array.isArray(R)?R:[];return!j||!j.n?x.map(E=>E&&g([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:a(E.scale,j)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,j)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,j)};if(!E.when||!_.includes(E.when.op))return E;const T=l(E.when,j);return T?{...E,when:T}:{...E,enabled:!1}})}function t(R,j){const x=Number.isFinite(Number(R.min))?Number(R.min):void 0,E=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(x!==void 0&&E!==void 0)return{...R,min:x,max:E};if(R.from==="quantile")return{...R,min:x??v(j.sorted,d(Number(R.low),5)),max:E??v(j.sorted,d(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:x??j.mean-T*j.stddev,max:E??j.mean+T*j.stddev}}return{...R,min:x??j.min,max:E??j.max}}function r(R,j){if(Array.isArray(R.thresholds))return R;const x=i(R),E=[];for(let T=1;T<x;T++)E.push(v(j.sorted,T/x));return{...R,thresholds:E}}function i(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 j=s[R.set];return j?j.length:3}function f(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function u(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 o(R,j){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${j==="up"?"8,2 14,13 2,13":j==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,j){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${j*16} 16">`;for(let T=0;T<j;T++){const L=T<R?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${T*16},0)" d="${x}" fill="${L}"/>`}return`${E}</svg>`}const c=Object.freeze([o("#c0392b","down"),o("#e0a800","right"),o("#2e7d32","up")]),h=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:h,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("<")?f(String(E)):String(E));const j=R.set||"arrows";if(j==="ratings"){const E=i(R),T=[];for(let L=1;L<=E;L++)T.push(f(m(L,E)));return T}const x=s[j];return x?x.map(f):(B(`iconSet:${j}`,`unknown icon set '${j}'; falling back to arrows.`),c.map(f))}function A(R){const j=Number(R.min),E=Number(R.max)-j,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",P=R.direction==="rtl"?"left":"right",D=C=>Math.max(0,Math.min(1,(C-j)/E))*100,I=E?Math.max(0,Math.min(100,(0-j)/E*100)):0;return C=>{if(H(C))return null;const O=Number(C);if(!Number.isFinite(O)||!E)return null;const N=D(O),G=Math.min(N,I),q=Math.max(N,I),Z=O>=0?T:L;return{backgroundImage:`linear-gradient(to ${P}, transparent ${G}%, ${Z} ${G}%, ${Z} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(R){const j=b(R),x=R.reverse?[...j].reverse():j,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*i(R):T;return P=>{if(H(P))return null;const D=Number(P);if(!Number.isFinite(D))return null;let I=0;for(const O of E)D>=O&&I++;const C=x[Math.min(I,x.length-1)];return C?{backgroundImage:C,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const j=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],x=Number(R.min),E=Number(R.max),T=E-x,L=j.length-1,P=[];for(let I=0;I<=L;I++)P.push(L?I/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(j.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${j.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(x,E)&&D<Math.max(x,E)){const I=L/2,C=Math.max(0,Math.min(1,(D-x)/T));for(let O=0;O<=L;O++)P[O]=O<=I?I?O/I*C:C:C+(O-I)/(L-I)*(1-C)}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 I=>{const C=Number(I);if(!Number.isFinite(C)||!T)return null;const O=Math.max(0,Math.min(1,(C-x)/T));let N=0;for(;N<L-1&&O>P[N+1];)N++;const G=P[N+1]-P[N],q=G>0?(O-P[N])/G:0;return{background:z(j[N],j[N+1],Math.max(0,Math.min(1,q)))}}}function S(R,j=null){const x=g(R)?n(R,j):R,E=(Array.isArray(x)?x:[]).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 P=L?L.value:void 0;let D=null;for(const I of T){if(!I.enabled)continue;if(I.scale){const O=I.scale(P);O&&(D={...D||{},...O});continue}if(!U(P,I.when))continue;const C=F(I.style)?I.style(L):I.style;if(C&&(D={...D||{},...C}),I.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 U}}),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 n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",F="str",B="ref",$="name",_="op",X="end",W=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(i,f){super(i),this.name="FormulaError",this.at=f}}function z(r){const i=[];let f=0;for(;f<r.length;){const u=r[f];if(u===" "||u===" "||u===`
|
|
7
7
|
`||u==="\r"){f++;continue}if(u>="0"&&u<="9"){f=v(r,f,i);continue}if(u==="."&&r[f+1]>="0"&&r[f+1]<="9"){f=v(r,f,i);continue}if(u==='"'||u==="'"){f=g(r,f,i);continue}if(u==="["){const m=r.indexOf("]",f+1);if(m<0)throw new U("a [column reference] was opened and never closed",f);i.push({kind:B,value:r.slice(f+1,m).trim(),at:f}),f=m+1;continue}if(w(u)){f=l(r,f,i);continue}const o=r.slice(f,f+2);if(W.includes(o)){i.push({kind:_,value:o==="!="?"<>":o,at:f}),f+=2;continue}if(H.includes(u)){i.push({kind:_,value:u,at:f}),f++;continue}throw new U(`unexpected character ${JSON.stringify(u)}`,f)}return i.push({kind:X,value:null,at:r.length}),i}function w(r){return/[A-Za-z_À-]/.test(r)}function v(r,i,f){let u=i,o=!1;for(;u<r.length;){const m=r[u];if(m>="0"&&m<="9"){u++;continue}if(m==="."&&!o){o=!0,u++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(r[u+1]||"")){for(u+=2;u<r.length&&r[u]>="0"&&r[u]<="9";)u++;break}break}return f.push({kind:Q,value:Number(r.slice(i,u)),at:i}),u}function g(r,i,f){const u=r[i];let o=i+1,m="";for(;o<r.length;){if(r[o]===u){if(r[o+1]===u){m+=u,o+=2;continue}return f.push({kind:F,value:m,at:i}),o+1}m+=r[o],o++}throw new U("a string was opened and never closed",i)}function l(r,i,f){let u=i;for(;u<r.length&&/[A-Za-z0-9_.À-]/.test(r[u]);)u++;const o=r.slice(i,u);let m=u;for(;m<r.length&&r[m]===" ";)m++;return f.push({kind:r[m]==="("?$:B,value:o,at:i}),u}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(r){const i=String(r??"").replace(/^\s*=/,"");if(!i.trim())throw new U("the formula is empty");const f=z(i);let u=0;const o=()=>f[u],m=()=>f[u++],c=y=>{const S=o();if(S.kind!==_||S.value!==y)throw new U(`expected ${JSON.stringify(y)}`,S.at);u++},h=y=>{let S=s();for(;;){const R=o();if(R.kind!==_)break;const j=d[R.value];if(!j||j<y)break;u++;const x=h(R.value==="^"?j:j+1);S={kind:"bin",op:R.value,left:S,right:x}}return S},s=()=>{const y=o();return y.kind===_&&(y.value==="-"||y.value==="+")?(u++,{kind:"unary",op:y.value,arg:s()}):p()},p=()=>{let y=b();for(;o().kind===_&&o().value==="%";)u++,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===F)return{kind:"str",value:y.value};if(y.kind===B)return{kind:"ref",name:y.value};if(y.kind===$){c("(");const S=[];if(!(o().kind===_&&o().value===")"))for(;;){if(S.push(h(1)),o().kind===_&&o().value===","){u++;continue}break}return c(")"),{kind:"call",name:String(y.value).toUpperCase(),args:S}}if(y.kind===_&&y.value==="("){const S=h(1);return c(")"),S}throw y.kind===X?new U("the formula ends unexpectedly",y.at):new U(`unexpected ${JSON.stringify(y.value)}`,y.at)},A=h(1),k=o();if(k.kind!==X)throw new U(`unexpected ${JSON.stringify(k.value)}: is an operator missing?`,k.at);return A}function n(r){const i=new Set,f=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){i.add(String(u.name));return}if(u.kind==="bin"){f(u.left),f(u.right);return}if(u.kind==="unary"){f(u.arg);return}if(u.kind==="call")for(const o of u.args)f(o)}};return f(r),[...i]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.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 v}});const F=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 l=typeof g=="number"?g:Number(String(g).replace(/[,\s]/g,""));if(!Number.isFinite(l))throw new F(`${JSON.stringify(g)} is not a number`);return l}function $(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 l=String(g).trim().toLowerCase();return l==="false"||l==="no"||l==="0"?!1:l!==""}function X(g){const l=[];for(const d of g){if(Array.isArray(d)){for(const a of d)a!=null&&a!==""&&l.push(B(a));continue}d==null||d===""||l.push(B(d))}return l}function W(g,l){const d=10**l,a=g*d;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/d}function H(g,l){if(!g.length)return 0;const d=g.slice().sort((r,i)=>r-i),a=(d.length-1)*Math.min(1,Math.max(0,l)),n=Math.floor(a),t=Math.ceil(a);return n===t?d[n]:d[n]+(a-n)*(d[t]-d[n])}function U(g,l){let d=0,a=0,n=0;for(const r of g){d++;const i=r-a;a+=i/d,n+=i*(r-a)}const t=l?d-1:d;return t>0?Math.sqrt(n/t):0}const z={SUM:g=>X(g).reduce((l,d)=>l+d,0),AVERAGE:g=>{const l=X(g);return l.length?l.reduce((d,a)=>d+a,0)/l.length:0},MIN:g=>{const l=X(g);return l.length?Math.min(...l):0},MAX:g=>{const l=X(g);return l.length?Math.max(...l):0},COUNT:g=>X(g).length,PRODUCT:g=>X(g).reduce((l,d)=>l*d,1),ROUND:g=>W(B(g[0]),g.length>1?B(g[1]):0),ROUNDDOWN:g=>{const l=10**(g.length>1?B(g[1]):0),d=B(g[0])*l;return(d<0?Math.ceil(d):Math.floor(d))/l},ROUNDUP:g=>{const l=10**(g.length>1?B(g[1]):0),d=B(g[0])*l;return(d<0?Math.floor(d):Math.ceil(d))/l},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 l=B(g[1]);if(l===0)throw new F("MOD by zero");return(B(g[0])%l+l)%l},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(l=>l!=null&&l!=="")??null,CONCAT:g=>g.map($).join(""),LEN:g=>$(g[0]).length,UPPER:g=>$(g[0]).toUpperCase(),LOWER:g=>$(g[0]).toLowerCase(),TRIM:g=>$(g[0]).trim(),LEFT:g=>$(g[0]).slice(0,g.length>1?B(g[1]):1),RIGHT:g=>{const l=g.length>1?B(g[1]):1;return l<=0?"":$(g[0]).slice(-l)},MEDIAN:g=>H(X(g),.5),PERCENTILE:g=>{const l=B(g[g.length-1]);return H(X(g.slice(0,-1)),l>1?l/100:l)},QUARTILE1:g=>H(X(g),.25),QUARTILE3:g=>H(X(g),.75),STDEV:g=>U(X(g),!0),STDEVP:g=>U(X(g),!1),VAR:g=>{const l=U(X(g),!0);return l*l},VARP:g=>{const l=U(X(g),!1);return l*l},COUNTDISTINCT:g=>{const l=new Set;for(const d of g){const a=Array.isArray(d)?d:[d];for(const n of a)n!=null&&n!==""&&l.add(n)}return l.size},IQR:g=>{const l=X(g);return H(l,.75)-H(l,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function w(g,l){const d=Number(g),a=Number(l);if(g!==null&&g!==""&&l!==null&&l!==""&&Number.isFinite(d)&&Number.isFinite(a))return d<a?-1:d>a?1:0;const t=$(g).toLowerCase(),r=$(l).toLowerCase();return t<r?-1:t>r?1:0}function v(g,l={}){const d=typeof l.lookup=="function"?l.lookup:null,a=l.functions?{...z,...l.functions}:z,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new F(`there is no column called ${JSON.stringify(t.name)} here`);const r=d(String(t.name));if(r===void 0)throw new F(`there is no column called ${JSON.stringify(t.name)}`);return r}case"unary":{if(t.op==="%")return B(n(t.arg))/100;const r=B(n(t.arg));return t.op==="-"?-r:r}case"bin":{const r=t.op;if(r==="=")return w(n(t.left),n(t.right))===0;if(r==="<>")return w(n(t.left),n(t.right))!==0;if(r==="<")return w(n(t.left),n(t.right))<0;if(r==="<=")return w(n(t.left),n(t.right))<=0;if(r===">")return w(n(t.left),n(t.right))>0;if(r===">=")return w(n(t.left),n(t.right))>=0;const i=B(n(t.left)),f=B(n(t.right));if(r==="+")return i+f;if(r==="-")return i-f;if(r==="*")return i*f;if(r==="^")return i**f;if(r==="/"){if(f===0)throw new F("division by zero");return i/f}throw new F(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=a[t.name];if(typeof r!="function")throw new F(`there is no function called ${t.name}`);return r(t.args.map(n),l)}default:throw new F("the formula could not be read")}};return n(g)}}),Le("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return $}}),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 H}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),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"),F=Q.parseFormula,B=Q.referencesOf,$=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),H=W.evaluateAst,U=W.FUNCTIONS;function z(v){const{grid:g,row:l,data:d}=v||{},a=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),n=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,r=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,i=new Set;for(const f of n)r(f)||(i.add(a(f.id)),f.field&&i.add(a(f.field)),f.title&&i.add(a(f.title)));return f=>{const u=a(f);if(i.has(u))throw new _(`"${f}" cannot be read`);for(const o of n)if(a(o.id)===u||o.field&&a(o.field)===u||o.title&&a(o.title)===u)return l&&g.rows&&typeof g.rows.value=="function"?g.rows.value(l.key,o.id):d?d[o.field||o.id]:void 0;if(d&&typeof d=="object"){for(const o of Object.keys(d))if(a(o)===u){if(!r(o))throw new _(`"${f}" cannot be read`);return d[o]}}}}function w(v,g={}){try{const l=F(v);return{ok:!0,value:H(l,{lookup:z(g),functions:g.formulaFunctions}),references:B(l)}}catch(l){return{ok:!1,error:l instanceof _?l.message:"the formula could not be read",at:l instanceof _?l.at:void 0}}}}),Le("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const Q=K("packages/core/src/internal/util.js"),F=Q.isObject,B=Q.merge,$=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(l=>W(l,w));return w.delete(z),g}if(!F(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(w.has(z))throw new X;w.add(z);const v={};for(const[g,l]of Object.entries(z))v[g]=W(l,w);return w.delete(z),v}function H(z){if(z===void 0)return W(_??{});if(z===null)return _=null,{};if(!F(z))return $("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 $("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 U(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"]),F=new Set(Q);function B($){return $==="*"||F.has($)}}),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 l}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.uid,$=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function H(d,a){!$||X(a)||F(`bus.unknown:${a}`,`${d}('${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 U=new Set(["api","user","init","ai"]),z=new WeakMap;function w(d){let a=z.get(d);return a||(a=B("h"),z.set(d,a)),a}function v(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(d){if(!d||typeof d!="object")return{};const a={};for(const[n,t]of Object.entries(d))n!=="grid"&&(t==null?a[n]=String(t):Array.isArray(t)?a[n]=`[${t.length}]`:typeof t=="object"?a[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?a[n]="[function]":a[n]=String(t).slice(0,60));return a}class l{#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,n){if(typeof n!="function")return F(`bus.handler:${a}`,`on('${a}') needs a function; ignored.`),()=>{};H("on",a);let t=this.#e.get(a);return t||(t=[],this.#e.set(a,t)),t.push(n),()=>this.off(a,n)}once(a,n){if(typeof n!="function")return F(`bus.handler:${a}`,`once('${a}') needs a function; ignored.`),()=>{};H("once",a);const t=r=>{this.off(a,n),n(r)};return this.#o.set(n,t),this.on(a,t)}off(a,n){if(n===void 0){this.#e.delete(a);return}const t=this.#e.get(a);if(!t)return;const r=this.#o.get(n),i=r&&t.includes(r)?r:n,f=t.indexOf(i);f>=0&&t.splice(f,1),r&&i===r&&this.#o.delete(n),t.length===0&&this.#e.delete(a)}count(a){const n=this.#e.get(a),t=a===W?null:this.#e.get(W);return(n?n.length:0)+(t?t.length:0)}#a(a,n,t,r,i){this.#n.push({type:a,origin:n,listeners:(r?r.length:0)+(i?i.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(a,n){this.#t=!!a,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),a||(this.#n=[])}eventLog(){return this.#n.map(a=>({...a}))}clearEventLog(){this.#n=[]}counts(){const a={};for(const[n,t]of this.#e)a[n]=t.length;return a}emit(a,n,t){const r=t??(n&&n.origin),i=U.has(r)?r:"api",f={...n||null,type:a,origin:i,grid:this.#i};if(this.#s)return f;const u=this.#e.get(a),o=a===W?void 0:this.#e.get(W);if(this.#t&&this.#a(a,i,n,u,o),!u&&!o)return f;const m=this.#t?v():0;this.#l++;try{u&&this.#u(u.slice(),f,a),o&&this.#u(o.slice(),f,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=v()-m)}return f}emitBefore(a,n,t){const r=t??(n&&n.origin),i=U.has(r)?r:"user";let f=!1,u=null;const o=b=>{f=!0,b!=null&&u===null&&(u=String(b))},m={...n||null,type:a,origin:i,grid:this.#i,get defaultPrevented(){return f},get reason(){return u},preventDefault(b){o(b)}};if(this.#s)return!0;const c=this.#e.get(a);this.#t&&this.#a(a,i,n,c,void 0);const h=c?c.slice():[];if(h.length===0)return!0;const s=()=>(f&&u===null&&(u="prevented"),f&&n&&typeof n=="object"&&(n.reason=u),!f),p=[];for(const b of h)try{const A=b(m);A&&typeof A.then=="function"?p.push(A):A===!1&&o("prevented")}catch(A){o("error"),F(`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"?(o("error"),F(`bus.beforeReject:${a}`,`a '${a}' before-handler rejected; the action was cancelled.`,A.reason)):A.value===!1&&o("prevented");return s()})}#u(a,n,t){for(let r=0;r<a.length;r++)try{a[r](n)}catch(i){F(`bus.throw:${t}:${w(a[r])}`,`a '${t}' handler threw; other handlers were unaffected.`,i)}}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 U}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return l}}),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 h}}),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 j}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return x}});const F=K("packages/core/src/internal/util.js").warnOnce,B=K("packages/core/src/registry/free-tier-notice.js"),$=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",H=64,U="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 v(E){if(typeof E!="string")return null;let T="";for(let O=0;O<E.length;O++){const N=E.charCodeAt(O);if(N!==61){if(N>127||w[N]<0)return null;T+=E[O]}}const L=T.length;if(L%4===1)return null;const P=new Uint8Array(Math.floor(L*3/4));let D=0,I=0,C=0;for(let O=0;O<L;O++)D=D<<6|w[T.charCodeAt(O)],I+=6,I>=8&&(I-=8,P[C++]=D>>I&255);return C===P.length?P:P.subarray(0,C)}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 P=E.length-L;if(P===1){const D=E[L]<<16;T+=z[D>>18&63]+z[D>>12&63]}else if(P===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 l(E){const T=new Uint8Array(E.length);for(let L=0;L<E.length;L++)T[L]=E.charCodeAt(L)&127;return T}function d(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(),P=L.split(".");if(P.length!==3)return T;const[D,I,C]=P;if(D!==W)return{...T,reason:"prefix"};const O=v(I),N=v(C);if(!O||!N)return T;let G;try{G=JSON.parse(d(O))}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:l(I),signature:N,raw:L}}function n(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 r=null,i=null,f=null;function u(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function o(E){if(r&&i===E)return r;const T=u();if(!T)return null;const L=v(E);if(!L)return null;try{const P=await T.importKey("raw",L,{name:"Ed25519"},!1,["verify"]);return r=P,i=E,P}catch{return null}}async function m(){return f!==null||(f=await o(U)!==null),f}async function c(E,T={}){const L=T.warn!==!1,P=T.product||_,D=T.publicKey||U,I=T.now??Date.now(),C=T.host??s(),O=h(C)?"":` ${$}`,N=a(E);if(!N.ok){const te=N.reason==="missing"?"missing":"malformed";return L&&F(`licence.${te}`,te==="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.${O}`:`licence key could not be read. The grid will render with a watermark.${O}`),{valid:!1,reason:te,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!==P)return L&&F("licence.product",`licence key is for '${N.product}', not '${P}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(n(N.expires,I))return L&&F("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&&C&&!h(C)&&!p(C,q))return L&&F("licence.domain",`licence key is not valid for ${C}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Z=await o(D);if(!Z){const te=!!N.signature&&N.signature.length===H;return L&&F("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),te?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let J=!1;try{J=await u().verify({name:"Ed25519"},Z,N.signature,N.message)}catch{J=!1}return J?{valid:!0,...G}:(L&&F("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function h(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(P=>{const D=b(P);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const I=D.slice(2);return L===I||L.endsWith(`.${I}`)}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:!n(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 P of this.#i)P(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:!h(this.#r)}setHost(T){this.#r=T}state(){return this.#t.valid?"licensed":h(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const k=new A;function y(E){return k.set(E)}function S(){return k.info()}function R(){return k.watermark()}function j(){return k.state()}function x(){return k}}),Le("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.isFunction,$=Q.DEV,_=K("packages/core/src/registry/licence.js"),X=_.LicenceHolder,W=_.sharedLicence,H=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["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(i={}){for(const f of H)this.#t.set(f,new Map);this.#o=i.holder||W(),this.#s=i.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),i.licence&&this.setLicence(i.licence)}registerModules(i,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const u=Array.isArray(i)?i:[i],o=[];for(const m of u){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){F("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(m.name)){$&&this.#c(this.#e.get(m.name),m);continue}if(!B(m.install)){F(`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(h){F(`registry.module.throw:${m.name}`,`module '${m.name}' threw during install; it was not registered.`,h);continue}this.#e.set(m.name,m);for(const h of w(m))this.#n.add(h);o.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:l(m)})}return o}unregisterModule(i){const f=this.#e.get(i);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(u){F(`registry.module.uninstall:${i}`,`module '${i}' threw during uninstall.`,u)}return this.#e.delete(i),this.#u(),this.#d({reason:"unmodule",name:i,capabilities:this.capabilities(),regions:l(f)}),!0}modules(){return[...this.#e.values()]}has(i){return this.#e.has(i)}#u(){this.#n.clear();for(const i of this.#e.values())for(const f of w(i))this.#n.add(f)}#c(i,f){!i||i===f||v(i,f)||F(`registry.module.reconfigure:${f.name}`,`module '${f.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(i){return this.#n.has(i)}onChange(i){return B(i)?(this.#r.add(i),this.#a.set(i,this.#s),()=>{this.#r.delete(i),this.#a.delete(i)}):()=>{}}#d(i){for(const f of[...this.#r])try{f(i)}catch(u){F("registry.onChange.throw","a registry change handler threw.",u)}}register(i,f,u){const o=this.#t.get(i);if(!o){F(`registry.kind:${i}`,`unknown registry kind '${i}'; expected one of ${H.join(", ")}.`);return}if(!f||typeof f!="string"){F(`registry.name:${i}`,`register('${i}', ...) needs a name.`);return}o.has(f)&&o.get(f)!==u&&F(`registry.replace:${i}:${f}`,`'${f}' was already registered as a ${i} and has been replaced.`),o.set(f,u),this.#d({reason:"register",name:f,kind:i,capabilities:this.capabilities(),regions:d(i)})}registerAll(i,f){if(f)for(const u of Object.keys(f))this.register(i,u,f[u])}get(i,f){const u=this.#t.get(i);return u?u.get(f):void 0}names(i){const f=this.#t.get(i);return f?[...f.keys()]:[]}#f(i,f){const u=this.#t.get(i).get(f);return u!==void 0?u:this.#t.get("component").get(f)}renderer(i){return this.#f("renderer",i)}editor(i){return this.#f("editor",i)}filter(i){return this.#f("filter",i)}dataType(i){return this.get("dataType",i)}totalFn(i){return this.get("totalFn",i)}pipe(i){return this.get("pipe",i)}setLicence(i){return this.#o.set(i)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(i){i!=null&&(this.#l.add(i),this.#s=i)}detach(i){if(i!=null){this.#l.delete(i);for(const[f,u]of[...this.#a])u===i&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===i){const f=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=f}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(i){if(i!=null){this.detach(i);return}for(const f of[...this.#e.keys()])this.unregisterModule(f);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function w(r){const i=r.capabilities,f=Array.isArray(i)?i.filter(u=>typeof u=="string"):[];return[r.name,...f]}function v(r,i){return r.install!==i.install||r.uninstall!==i.uninstall||(r.version||"")!==(i.version||"")?!1:g(w(r),w(i))&&g(l(r),l(i))}function g(r,i){const f=new Set(r),u=new Set(i);if(f.size!==u.size)return!1;for(const o of f)if(!u.has(o))return!1;return!0}function l(r){const i=r.regions;return!Array.isArray(i)||i.length===0?["all"]:i.filter(f=>U.includes(f))}function d(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const a=new z;function n(){return a}function t(r,i={}){return a.registerModules(r,i)}}),Le("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const F=K("packages/core/src/internal/util.js").isNil;function B($,_){const X=$||{},W=X.locale||_||void 0,H=X.style||"decimal",U=typeof X.scale=="number"?X.scale:1,z=X.nullDisplay??"",w=X.zeroDisplay,v=X.prefix||"",g=X.suffix||"",l=X.negative||"minus",d=X.signed===!0,a={style:H,notation:X.notation||"standard"};H==="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 n=new Intl.NumberFormat(W,a),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,r=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let i=",",f=".";if(t||r)for(const s of n.formatToParts(12345.6))s.type==="group"?i=s.value:s.type==="decimal"&&(f=s.value);const u=s=>{let p=s;return t&&(p=p.split(i).join("")),r&&(p=p.split(f).join("")),t&&(p=p.split("").join(t)),r&&(p=p.split("").join(r)),p},o=!!(t||r),m=v!==""&&H==="currency",c=s=>{let p;if(m){const b=n.formatToParts(s);let A=!1;p="";for(const k of b)p+=k.value,!A&&k.type==="currency"&&(p+=v,A=!0);A||(p=v+p)}else p=v+n.format(s);return o&&(p=u(p)),p+g},h=s=>{if(F(s)||s==="")return z;const p=typeof s=="number"?s:Number(s);if(Number.isNaN(p))return z;const b=U===1?p:p*U;return b===0&&w!==void 0?w:b<0?l==="parentheses"?`(${c(-b)})`:l==="suffix"?`${c(-b)}-`:c(b):d&&b>0?`+${c(b)}`:c(b)};return h.negativeClass=X.negativeClass||null,h.spec=X,h}}),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 v}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),F=Q.isNil,B=Q.warnOnce,$=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const r=[];let i=0,f="";const u=()=>{f&&(r.push({token:null,text:f}),f="")};for(;i<t.length;){const o=t[i];if(o==="'"){if(t[i+1]==="'"){f+="'",i+=2;continue}const c=t.indexOf("'",i+1);if(c===-1){f+=t.slice(i+1),i=t.length;continue}f+=t.slice(i+1,c),i=c+1;continue}const m=$.find(c=>t.startsWith(c,i));if(m){u(),r.push({token:m,text:m}),i+=m.length;continue}/[A-Za-z]/.test(o)&&B(`date.pattern.token:${o}`,`the date pattern "${t}" contains '${o}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${$.join(" ")}.`),f+=o,i+=1}return u(),r}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if(F(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 r=X.exec(t.trim());if(r){const[,f,u,o,m="0",c="0",h="0"]=r;return new Date(+f,+u-1,+o,+m,+c,+h)}const i=new Date(t);return Number.isNaN(i.getTime())?null:i}return null}function H(t,r){return String(t).padStart(r,"0")}function U(t){if(!t)return f=>({year:f.getFullYear(),month:f.getMonth()+1,day:f.getDate(),hour:f.getHours(),minute:f.getMinutes(),second:f.getSeconds(),ms:f.getMilliseconds(),weekday:f.getDay()});const r=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"}),i={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return f=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:f.getMilliseconds(),weekday:0};for(const o of r.formatToParts(f))switch(o.type){case"year":u.year=Number(o.value);break;case"month":u.month=Number(o.value);break;case"day":u.day=Number(o.value);break;case"hour":u.hour=Number(o.value)%24;break;case"minute":u.minute=Number(o.value);break;case"second":u.second=Number(o.value);break;case"weekday":u.weekday=i[o.value]??0;break;default:break}return u}}function z(t,r,i){const f=_(t),u=U(i),o=new Set(f.filter(p=>p.token).map(p=>p.token)),m=o.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:i}):null,c=o.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:i}):null,h=o.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:i}):null,s=o.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:i}):null;return p=>{const b=u(p);let A="";for(const k of f){if(!k.token){A+=k.text;continue}switch(k.token){case"yyyy":A+=H(b.year,4);break;case"yy":A+=H(b.year%100,2);break;case"MMMM":A+=c.format(p);break;case"MMM":A+=m.format(p);break;case"MM":A+=H(b.month,2);break;case"M":A+=String(b.month);break;case"dd":A+=H(b.day,2);break;case"d":A+=String(b.day);break;case"EEEE":A+=s.format(p);break;case"EEE":A+=h.format(p);break;case"HH":A+=H(b.hour,2);break;case"H":A+=String(b.hour);break;case"hh":A+=H(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+=H(b.minute,2);break;case"m":A+=String(b.minute);break;case"ss":A+=H(b.second,2);break;case"s":A+=String(b.second);break;case"SSS":A+=H(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 v(t,r){const i=t||{},f=i.locale||r||void 0,u=i.nullDisplay??"",o=i.timeZone;let m;if(i.pattern)m=z(i.pattern,f,o);else if(i.dateStyle||i.timeStyle){const b={timeZone:o};i.dateStyle&&(b.dateStyle=i.dateStyle),i.timeStyle&&(b.timeStyle=i.timeStyle);const A=new Intl.DateTimeFormat(f,b);m=k=>A.format(k)}else{const b=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:o});m=A=>b.format(A)}const c=i.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,s=(typeof i.relative=="object"&&i.relative?i.relative.threshold??7:7)*24*36e5,p=(b,A)=>{const k=W(b);if(!k)return u;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,j]of w)if(Math.abs(S)>=j||R==="second")return c.format(Math.round(S/j),R)}}return m(k)};return p.spec=i,p}function g(t){if(F(t)||t==="")return null;if(typeof t=="string"){const f=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(f)return f[1];const u=W(t);return u?g(u):null}const r=W(t);if(!r)return null;const i=f=>String(f).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`}function l(t,r){if(F(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(d.test(f)){const m=W(f);return m?a(m,r):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(u){const[,m,c,h,s]=u;return`${m}T${c}:${h}${s&&s!=="00"?`:${s}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const o=W(f);return o?l(o):null}const i=W(t);return i?a(i,r):null}const d=/(?:Z|[+-]\d{2}:?\d{2})$/i;function a(t,r){const i=m=>String(m).padStart(2,"0");if(r)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:r,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,h=Number(m.second);return`${m.year}-${m.month}-${m.day}T${c}:${m.minute}`+(h?`:${m.second}`:"")}catch{}const f=`${t.getFullYear()}-${i(t.getMonth()+1)}-${i(t.getDate())}`,u=t.getSeconds(),o=`${i(t.getHours())}:${i(t.getMinutes())}${u?`:${i(u)}`:""}`;return`${f}T${o}`}function n(t,r){const i=F(t)||t===""?null:String(t),f=F(r)||r===""?null:String(r);return i===null?f===null?0:1:f===null||i<f?-1:i>f?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 F=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},$={true:"◉",false:"◯",null:""};function _(W){if(F(W)||W==="")return null;if(typeof W=="boolean")return W;if(typeof W=="number")return W!==0;const H=String(W).trim().toLowerCase();return H==="true"||H==="yes"||H==="y"||H==="1"?!0:H==="false"||H==="no"||H==="n"||H==="0"?!1:null}function X(W,H){const U=W||{},z=U.display||"text",w=U.trueLabel??"Yes",v=U.falseLabel??"No",g=U.nullLabel??"";let l=w,d=v;const a=g;z==="checkbox"?(l=B.true,d=B.false):z==="switch"?(l=$.true,d=$.false):z==="icon"&&(l=U.trueIcon??w,d=U.falseIcon??v);const n=t=>{const r=_(t);return r===null?a:r?l:d};return n.display=z,n.labels={true:w,false:v,null:g},n.locale=H,n.spec=U,n}}),Le("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),F=Q.isNil,B=Q.titleCase;function $(_,X){const W=_||{},H=W.locale||X||void 0,U=W.nullDisplay??"",z=W.emptyDisplay??"",w=W.transform||"none",v=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=v?v.chars:0,l=v?v.ellipsis??"…":"",d=n=>{switch(w){case"upper":return H?n.toLocaleUpperCase(H):n.toUpperCase();case"lower":return H?n.toLocaleLowerCase(H):n.toLowerCase();case"title":return B(n);default:return n}},a=n=>{if(F(n))return U;let t=typeof n=="string"?n:String(n);return t===""?z:(w!=="none"&&(t=d(t)),g>0&&t.length>g&&(t=t.slice(0,g)+l),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 $}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),F="\0";function B(H){const U=[];let z="",w=!1;for(let v=0;v<H.length;v++){const g=H[v];if(g==="\\"){z+=g+(H[v+1]??""),v+=1;continue}if(g==='"'){w=!w,z+=g;continue}if(g===";"&&!w){U.push(z),z="";continue}z+=g}return U.push(z),U}function $(H){let U="",z="",w="",v=1,g=!1,l=!1;const d=m=>{l?z+=m:U+=m};for(let m=0;m<H.length;m++){const c=H[m];if(c==="\\"){d(H[m+1]??""),m+=1;continue}if(c==='"'){const h=H.indexOf('"',m+1);d(h===-1?H.slice(m+1):H.slice(m+1,h)),m=h===-1?H.length:h;continue}if(c==="%"){v*=100,d("%");continue}if(c==="@"){g=!0,d("\0");continue}if(Q.has(c)){w+=c,l=!0;continue}d(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 n=!1,t="";for(let m=0;m<w.length;m++){const c=w[m];if(c===","){m>a?v/=1e3:n=!0;continue}t+=c}const r=t.indexOf("."),i=r===-1?t:t.slice(0,r),f=r===-1?"":t.slice(r+1);let u=0;for(const m of i)m==="0"&&(u+=1);let o=0;for(const m of f)m==="0"&&(o+=1);return{prefix:U,suffix:z,minInt:u,minDec:o,maxDec:f.length,grouping:n,scale:v,hasNumber:a!==-1,isText:g}}function _(H,U){const z=new Intl.NumberFormat(U,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:w,suffix:v,scale:g,hasNumber:l}=H;return d=>{if(!l)return w+v;const a=g===1?d:d*g;return w+z.format(a)+v}}function X(H,U){const w=B(String(H)).map($),v=w.map(t=>_(t,U)),g=0,l=w.length>1?1:-1,d=w.length>2?2:-1,a=w.length>3?3:-1,n=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const r=Number(t);if(Number.isNaN(r))return a===-1?String(t):(w[a].prefix+w[a].suffix).split("\0").join(String(t));t=r}return t===0&&d!==-1?v[d](0):t<0&&l!==-1?v[l](-t):v[g](t)};return n.spec={mask:H},{format:n,ooxml:W(String(H))}}function W(H){return H.trim()}}),Le("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return $}}),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"],F=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function $(H){return typeof H!="string"||H===""||X(H)?!1:F.test(H)}function _(H){return typeof H!="string"||H===""||X(H)?!1:B.test(H)}function X(H){const U=H.indexOf(":"),z=U===-1?H:H.slice(0,U);return Q.includes(z)?z:null}function W(H){const U=X(H);if(!U)return null;const z=H.indexOf(":"),w=z===-1?"":H.slice(z+1),v=w===""?[]:w.split(":");switch(U){case"currency":{const g={type:"number",style:"currency",currency:v[0]||"USD"};return v[1]!==void 0&&v[1]!==""&&(g.decimals=Number(v[1])),g}case"number":{const g={type:"number",style:"decimal"};return v[0]!==void 0&&v[0]!==""&&(g.decimals=Number(v[0])),g}case"percent":{const g={type:"number",style:"percent"};return v[0]!==void 0&&v[0]!==""&&(g.decimals=Number(v[0])),g}case"date":return{type:"date",pattern:w||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=w.split("/"),l={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(l.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(l.falseLabel=g[1]),g[2]!==void 0&&(l.nullLabel=g[2]),l}case"text":{const g={type:"text"};return v[0]&&(g.transform=v[0]),v[1]!==void 0&&v[1]!==""&&(g.truncate=Number(v[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"),F=Q.isFunction,B=Q.isObject,$=Q.warnOnce,_=K("packages/core/src/format/number.js"),X=_.compileNumber,W=K("packages/core/src/format/date.js"),H=W.compileDate,U=W.scanPattern,z=K("packages/core/src/format/boolean.js"),w=z.compileBoolean,v=K("packages/core/src/format/text.js"),g=v.compileText,l=K("packages/core/src/format/mask.js"),d=l.compileMask,a=K("packages/core/src/format/shorthand.js"),n=a.parseShorthand,t=a.looksLikeMask,r=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 v.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return l.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return l.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return l.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 i=new Set(["decimal","currency","percent","unit"]),f=new Set(["type","locale"]),u={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"])},o=new Set(["number","date","boolean","text"]);function m(R,j){const x=R.type;if(x===void 0||o.has(x)||!i.has(String(x)))return;const E=j?`"${j}"`:"with no id";$(`format:unknown-style-key:${j||""}:${x}`,`column ${E} has format: { type: "${x}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${x}" instead?`)}function c(R,j,x){const E=u[j],T=x?`"${x}"`:"with no id";for(const L of R){if(f.has(L)||E.has(L))continue;const P=Object.keys(u).find(D=>D!==j&&u[D].has(L));P?$(`format:inapplicable:${x||""}:${L}`,`column ${T} has format key "${L}", which applies to a ${P} column, not the ${j} column it was applied to; it is ignored.`):$(`format:unknown:${x||""}:${L}`,`column ${T} has an unrecognised format key "${L}" for its ${j} format; it is ignored.`)}}function h(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const j=i.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||j||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,j){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 x=j&&j.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function p(R,j=null,x=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 I=(C,O)=>String(R({...O||{},value:C,locale:x})??"");return I.ooxml=j&&j.excel||"General",I}if(typeof R=="string"){if(t(R)){const{format:C,ooxml:O}=d(R,x);return C.ooxml=O,C}const I=n(R)||(r(R)?{type:"date",pattern:R}:null);return I?p(I,j,x,E,T):($(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!B(R))return $("format:shape","format must be a spec object or a string; ignoring",R),null;if(j&&F(j.format)&&!h(R)||j&&F(j.format)&&Array.isArray(j.formatPatterns)&&R.type===void 0)return null;const P=s(R,j);P==="date"&&E&&R.timeZone===void 0&&(R={...R,timeZone:E}),m(R,T),c(L||Object.keys(R),P,T);let D;switch(P){case"number":D=X(R,x);break;case"date":D=H(R,x);break;case"boolean":D=w(R,x);break;default:D=g(R,x);break}return D.ooxml=A(R,P,x,j),D.kind=P,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,j,x=void 0,E=null){if(j==="date"){if(R.pattern){let I="";for(const C of U(R.pattern))I+=C.token?b[C.token]??C.text:C.text;return I}return E&&E.excel||"yyyy-mm-dd"}if(j==="boolean")return"General";if(j==="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 P=`${R.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,D="";return R.style==="currency"&&(D+=k(S(R.currency||"USD",x))),R.prefix&&(D+=k(R.prefix)),P=D+P,R.style==="percent"&&(P=`${P}%`),R.suffix&&(P+=k(R.suffix)),R.negative==="parentheses"?`${P};(${P})`:R.negative==="suffix"?`${P};${P}-`:P}function k(R){return`"${String(R).split('"').join("")}"`}const y=new Map;function S(R,j){const x=`${R}|${j||""}`;let E=y.get(x);if(E!==void 0)return E;E=R;try{const L=new Intl.NumberFormat(j,{style:"currency",currency:R}).formatToParts(0).find(P=>P.type==="currency");L&&(E=L.value)}catch{}return y.set(x,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 v}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return d}}),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 j}}),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 I}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return be}}),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 Ve}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const Q=K("packages/core/src/internal/util.js"),F=Q.isNil,B=Q.isFunction,$=K("packages/core/src/format/date.js"),_=$.toDate,X=$.compilePattern,W=$.compileDate,H=$.toIsoDateTime,U=$.compareIso,z=864e5,w=Object.freeze({}),v=1e3,g=60*v,l=60*g,d=24*l,a=7*d,n=new WeakMap;function t(je,Ge){const Ze=je&&je.locale||"",rt=je&&je.column;if(!rt)return Ze?{locale:Ze}:w;const st=n.get(rt);if(st&&st.locale===Ze)return st.bag;const ft=rt.typeOptions||rt[Ge]||(r(rt.format)?rt.format:null),yt={...ft||w,locale:ft&&ft.locale||Ze||void 0};return n.set(rt,{locale:Ze,bag:yt}),yt}function r(je){return je!==null&&typeof je=="object"&&!Array.isArray(je)&&!(je instanceof Date)}function i(je,Ge){const Ze=je===null||Number.isNaN(je)?null:je,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 f=/^(\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,u=/^(\d{3,6})$/;function o(je,Ge,Ze,rt){return!(je>=0&&je<=23)||!(Ge>=0&&Ge<=59)||!(Ze>=0&&Ze<=59)||!(rt>=0&&rt<=999)?null:je*l+Ge*g+Ze*v+rt}function m(je){if(F(je))return null;const Ge=String(je).trim();if(Ge==="")return null;const Ze=u.exec(Ge);if(Ze){const Tt=Ze[1];if(Tt.length===5)return null;const Et=Tt.length===3?1:2;return o(Number(Tt.slice(0,Et)),Number(Tt.slice(Et,Et+2)),Number(Tt.slice(Et+2,Et+4)||0),0)}const rt=f.exec(Ge);if(!rt)return null;let st=Number(rt[1]);const ft=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 o(st,ft,yt,Ot)}function c(je){return F(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?(je%d+d)%d:null:je instanceof Date?Number.isNaN(je.getTime())?null:je.getHours()*l+je.getMinutes()*g+je.getSeconds()*v+je.getMilliseconds():m(je)}const h=new Map;function s(je){const Ge=je.pattern||"",Ze=je.timeStyle||(je.seconds?"medium":"short"),rt=`${je.locale||""}|${Ge}|${Ze}`;let st=h.get(rt);if(st)return st;if(Ge)st=X(Ge,je.locale||void 0,"UTC");else{const ft=new Intl.DateTimeFormat(je.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});st=yt=>ft.format(yt)}return h.set(rt,st),st}function p(je,Ge){const Ze=Ge||w;if(je==null||typeof je!="number"||!Number.isFinite(je))return Ze.nullDisplay??"";const rt=(je%d+d)%d;return s(Ze)(new Date(rt))}function b(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je=="number"?Number.isFinite(je)&&je>=0&&je<d:typeof je!="string"||!je.includes(":")?!1:m(je)!==null}function A(je){const Ge=c(je);return Ge==null?"":p(Ge,{pattern:Ge%v===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const k=new Map;function y(je){const Ge=je||"";let Ze=k.get(Ge);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),k.set(Ge,Ze)),Ze}function S(je,Ge){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const rt of y(Ge).formatToParts(new Date(je)))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(je,Ge){const Ze=S(je,Ge);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(je/1e3)*1e3}function j(je,Ge){const Ze=je.hour||0,rt=je.minute||0,st=je.second||0,ft=je.ms||0;if(!Ge)return new Date(je.year,je.month-1,je.day,Ze,rt,st,ft).getTime();const yt=Date.UTC(je.year,je.month-1,je.day,Ze,rt,st,ft);let Ot=yt-R(yt,Ge);return Ot=yt-R(Ot,Ge),Ot}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function T(je,Ge){if(F(je))return null;const Ze=String(je).trim();if(Ze==="")return null;const rt=Ge&&Ge.timeZone||void 0;if(!x.test(Ze)){const st=E.exec(Ze);if(st){const ft=(st[4]||"").trim(),yt=ft===""?0:m(ft);if(yt===null)return null;const Ot=j({year:Number(st[1]),month:Number(st[2]),day:Number(st[3]),hour:Math.floor(yt/l),minute:Math.floor(yt/g)%60,second:Math.floor(yt/v)%60,ms:yt%v},rt);return Number.isNaN(Ot)?null:new Date(Ot)}}return _(Ze)}function L(je){if(typeof je=="number")return Number.isFinite(je)?je:null;const Ge=_(je);return Ge?Ge.getTime():null}const P=new Map;function D(je){const Ge=[je.locale||"",je.pattern||"",je.dateStyle||"",je.timeStyle||"",je.timeZone||"",je.seconds?"1":""].join("|");let Ze=P.get(Ge);if(Ze)return Ze;const rt=je.pattern?{type:"date",pattern:je.pattern,timeZone:je.timeZone}:{type:"date",dateStyle:je.dateStyle||"medium",timeStyle:je.timeStyle||(je.seconds?"medium":"short"),timeZone:je.timeZone};return Ze=W(rt,je.locale||void 0),P.set(Ge,Ze),Ze}function I(je,Ge){const Ze=Ge||w,rt=L(je);return rt==null?Ze.nullDisplay??"":D(Ze)(rt)}function C(je){return je instanceof Date?!Number.isNaN(je.getTime()):typeof je!="string"||!E.test(je.trim())?!1:T(je)!==null}const O=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:l,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:v,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),N=new Map;for(const je of O)for(const Ge of je.names)N.set(Ge,je);const G=Object.freeze(O.filter(je=>je.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 te(je){const Ge=je&&je.defaultUnit?N.get(String(je.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:g}function ne(je){return(je&&je.defaultUnit?N.get(String(je.defaultUnit).toLowerCase()):null)||N.get("m")}function oe(je,Ge){if(F(je))return null;let Ze=String(je).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])*l+Number(st[2])*g+(Ct?Number(st[3])*v:0)+(st[4]?Number(st[4].padEnd(3,"0")):0);return rt*Tt}if(Z.test(Ze))return Math.round(rt*Number(Ze)*te(Ge||w));let ft=Ze,yt=0,Ot=0;for(;ft!=="";){const Ct=q.exec(ft);if(!Ct)return null;const Tt=N.get(Ct[2]);if(!Tt)return null;yt+=Number(Ct[1])*Tt.ms,ft=ft.slice(Ct[0].length),Ot++}return Ot===0?null:Math.round(rt*yt)}function le(je){return F(je)||je===""?null:typeof je=="number"?Number.isFinite(je)?je:null:oe(je)}const ae=new Map;function se(je,Ge,Ze){const rt=`${Ze||""}|${Ge.intl}`;let st=ae.get(rt);if(st===void 0){try{st=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{st=null}ae.set(rt,st)}return st?st.format(je):`${je} ${je===1?Ge.long[0]:Ge.long[1]}`}function ee(je,Ge){return String(je).padStart(Ge,"0")}function ie(je,Ge){const Ze=Ge||w;if(je==null||typeof je!="number"||!Number.isFinite(je))return Ze.nullDisplay??"";const rt=Ze.style||"short",st=je<0;let ft=Math.round(Math.abs(je));const yt=st?"-":"";if(ft===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(rt==="clock"){const Et=Math.floor(ft/l),zt=Math.floor(ft/g)%60,It=Math.floor(ft/v)%60;return`${yt}${ee(Et,2)}:${ee(zt,2)}:${ee(It,2)}`}if(ft===0){const Et=ne(Ze);return rt==="long"?se(0,Et,Ze.locale):`0${Et.key}`}const Ot=Ze.weeks===!0?O: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(ft/Et.ms);zt!==0&&(ft-=zt*Et.ms,Tt.push(rt==="long"?se(zt,Et,Ze.locale):`${zt}${Et.key}`))}return yt+Tt.join(" ")}function ce(je){if(typeof je!="string")return!1;const Ge=je.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:oe(Ge)!==null}const he=Date.UTC(1899,11,30),ge=new Map;function Ee(je,Ge){const Ze=je||"";let rt=ge.get(Ze);rt||(rt=new Intl.DateTimeFormat("en-GB",{timeZone:je||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ge.set(Ze,rt));const st=typeof Ge=="number"?Ge:Date.now();for(const ft of rt.formatToParts(new Date(st)))if(ft.type==="timeZoneName")return ft.value;return""}function ye(je){if(je)return je;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ae(je,Ge){const Ze=ye(je),rt=Ee(je,Ge);return rt?`${Ze} (${rt})`:Ze}function pe(je,Ge){if(je&&je.timeZone)return je.timeZone;const Ze=Ge&&Ge.grid;return(Ze&&B(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function we(je,Ge){const Ze=Ge||w,rt=L(je);if(rt==null)return Ze.nullDisplay??"";const st=D(Ze)(rt);if(!Ze.showOrigin)return st;const ft=Ze.originZone;return ft?ft===(Ze.timeZone||ye(Ze.timeZone))?st:`${st} (${Ae(ft,rt)})`:`${st} (no origin recorded)`}function be(je,Ge,Ze,rt){if(Ge==="instant"||!Ge)return je;const st=S(je,Ze);if(Ge==="month")return j({year:st.year,month:st.month,day:1},Ze);if(Ge==="week"){const ft=rt>=1&&rt<=7?rt:1,Ot=((new Date(Date.UTC(st.year,st.month-1,st.day)).getUTCDay()+6)%7+1-ft+7)%7,Ct=new Date(Date.UTC(st.year,st.month-1,st.day-Ot));return j({year:Ct.getUTCFullYear(),month:Ct.getUTCMonth()+1,day:Ct.getUTCDate()},Ze)}return j({year:st.year,month:st.month,day:st.day},Ze)}function Ne(je,Ge){const Ze=je&&je.group,rt=Ze&&Ze.granularity||"day";if(rt==="instant")return null;const st=Ze&&Ze.weekStart;return ft=>typeof ft=="number"?be(ft,rt,Ge,st):ft}const $e={time:{base:"number",storage:"float64",matches:b,format:je=>p(c(je.value),t(je,"time")),parse:je=>m(je.text),compare:(je,Ge)=>i(c(je),c(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=c(je);return Ge===null?null:Ge/z},toStorage:je=>c(je),toClipboard:A,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:C,format:je=>I(je.value,t(je,"datetime")),parse:je=>H(T(je.text,t(je,"datetime"))??je.text),compare:U,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(je,Ge)=>H(je,Ge&&Ge.timeZone),toClipboard:je=>F(je)?"":String(je),fromClipboard:je=>H(je)},duration:{base:"number",storage:"float64",matches:ce,format:je=>ie(le(je.value),t(je,"duration")),parse:je=>oe(je.text,t(je,"duration")),compare:(je,Ge)=>i(le(je),le(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:je=>{const Ge=le(je);return Ge===null?null:Ge/z},toStorage:je=>le(je),toClipboard:je=>ie(le(je),{style:"short",maxUnits:-1}),fromClipboard:je=>oe(je)},timestamp:{base:"number",storage:"float64",format:je=>{const Ge=t(je,"timestamp");return we(je.value,{...Ge,timeZone:pe(Ge,je)})},parse:je=>{const Ge=t(je,"timestamp"),Ze=T(je.text,{timeZone:pe(Ge,je)});return Ze?Ze.getTime():null},compare:(je,Ge)=>i(L(je),L(Ge)),groupProjector:(je,Ge)=>Ne(je,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(je,Ge)=>{const Ze=L(je);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)-he)/z},toStorage:je=>L(je),toClipboard:je=>{const Ge=L(je);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:je=>L(je)}},Ve=["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 H}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return o}}),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 h}}),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 j}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),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"),F=Q.isNil,B=Q.Lru,$=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(L){if(F(L))return null;if(typeof L=="string")return W(L);const P=Number(L);return Number.isFinite(P)?P<0?P<-2147483648?null:P>>>0:P>$?null:Math.trunc(P)>>>0:null}function W(L){if(F(L))return null;const P=String(L).trim();if(P==="")return null;const D=_.exec(P);if(!D)return null;let I=0;for(let C=1;C<=4;C++){const O=D[C];if(O.length>1&&O.charCodeAt(0)===48)return null;const N=Number(O);if(N>255)return null;I=I*256+N}return I}function H(L){const P=X(L);return P===null?"":`${P>>>24&255}.${P>>>16&255}.${P>>>8&255}.${P&255}`}function U(L){return typeof L=="string"&&W(L)!==null}function z(L,P){const D=X(L),I=X(P);return D===null?I===null?0:1:I===null||D<I?-1:D>I?1:0}const w=64,v=$*w+32,g=/^(?:0|[1-9]\d?)$/;function l(L,P){return L*w+P}function d(L){if(F(L))return null;if(typeof L=="string"){const I=a(L);return I===null?null:d(I)}if(typeof L=="object"){const I=X(L.address),C=Number(L.prefix);return I===null||!Number.isInteger(C)||C<0||C>32?null:{address:I,prefix:C}}const P=Number(L);if(!Number.isInteger(P)||P<0||P>v)return null;const D=P%w;return D>32?null:{address:(P-D)/w,prefix:D}}function a(L){if(F(L))return null;const P=String(L).trim();if(P==="")return null;const D=P.indexOf("/");if(D<0)return null;const I=W(P.slice(0,D));if(I===null)return null;const C=P.slice(D+1).trim();if(!g.test(C))return null;const O=Number(C);return O>32?null:l(I,O)}function n(L){const P=d(L);return P?`${H(P.address)}/${P.prefix}`:""}function t(L){return typeof L=="string"&&a(L)!==null}function r(L,P){const D=d(L),I=d(P);return D?I?D.address!==I.address?D.address<I.address?-1:1:D.prefix-I.prefix:-1:I?1:0}function i(L){return L===0?0:4294967295<<32-L>>>0}function f(L){const P=d(L);return P?(P.address&i(P.prefix))>>>0:null}function u(L){const P=d(L);return P?(P.address&i(P.prefix)|~i(P.prefix)>>>0)>>>0:null}function o(L){const P=d(L);return P?2**(32-P.prefix):null}function m(L){const P=d(L);return P?P.prefix===32?1:P.prefix===31?2:2**(32-P.prefix)-2:null}function c(L,P){const D=d(L);if(!D)return!1;const I=X(P);if(I===null)return!1;const C=i(D.prefix);return(I&C)>>>0===(D.address&C)>>>0}function h(L,P){const D=f(L),I=f(P);return D===null||I===null?!1:D<=u(P)&&I<=u(L)}const s=/^[0-9a-fA-F]{1,4}$/,p=new B(512);function b(L){if(F(L))return null;let P=String(L).trim();if(P==="")return null;const D=P.indexOf("%");if(D>=0&&(P=P.slice(0,D)),P==="")return null;if(P.indexOf(".")>=0){const q=P.lastIndexOf(":");if(q<0)return null;const Z=W(P.slice(q+1));if(Z===null)return null;P=`${P.slice(0,q+1)}${(Z>>>16&65535).toString(16)}:${(Z&65535).toString(16)}`}const I=P.split("::");if(I.length>2)return null;const C=A(I[0]);if(C===null)return null;if(I.length===1)return C.length===8?C:null;const O=A(I[1]);if(O===null)return null;const N=8-C.length-O.length;if(N<1)return null;const G=C.slice();for(let q=0;q<N;q++)G.push(0);for(const q of O)G.push(q);return G}function A(L){if(L==="")return[];const P=[];for(const D of L.split(":")){if(!s.test(D))return null;P.push(parseInt(D,16))}return P}function k(L){if(typeof L!="string")return b(L);if(p.has(L))return p.get(L);const P=b(L);return p.set(L,P),P}function y(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${H((L[6]<<16|L[7])>>>0)}`;let P=-1,D=0,I=-1,C=0;for(let G=0;G<8;G++)L[G]===0?(I<0?(I=G,C=1):C++,C>D&&(D=C,P=I)):(I=-1,C=0);if(D<2)return L.map(G=>G.toString(16)).join(":");const O=L.slice(0,P).map(G=>G.toString(16)).join(":"),N=L.slice(P+D).map(G=>G.toString(16)).join(":");return`${O}::${N}`}function S(L){const P=b(L);return P===null?null:y(P)}function R(L){return S(L)??""}function j(L){return typeof L=="string"&&L.indexOf(":")>=0&&b(L)!==null}function x(L,P){const D=k(L),I=k(P);if(!D)return I?1:0;if(!I)return-1;for(let C=0;C<8;C++)if(D[C]!==I[C])return D[C]<I[C]?-1:1;return 0}const E=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:L=>W(L.text),compare:z,format:L=>H(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>X(L),toClipboard:L=>H(L),fromClipboard:L=>W(L)},cidr:{base:"number",storage:"float64",matches:t,parse:L=>a(L.text),compare:r,format:L=>n(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const P=d(L);return P===null?null:l(P.address,P.prefix)},toClipboard:L=>n(L),fromClipboard:L=>a(L)},ipv6:{base:"text",storage:"dictionary",matches:j,parse:L=>S(L.text),compare:x,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 $}});const F=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":F,"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"}),$=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 v}});const F=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,$=new Map,_=new Map;function X(g){const l=g||"";if($.has(l))return $.get(l);let d=null;try{d=new Intl.PluralRules(g||void 0)}catch{d=null}return $.set(l,d),d}function W(g,l,d="conjunction"){const a=Array.isArray(g)?g.filter(r=>r!=null&&r!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const n=`${l||""}|${d}`;let t=_.get(n);if(t===void 0){try{t=new Intl.ListFormat(l||void 0,{style:"long",type:d})}catch{t=null}_.set(n,t)}return t?t.format(a.map(String)):a.map(String).join(", ")}function H(g,l){return g==null?"":typeof g=="number"?Number.isFinite(g)?g.toLocaleString(l||void 0,{maximumFractionDigits:20}):"":String(g)}function U(g,l,d){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const a=l&&typeof l.count=="number"?l.count:null;if(a===null)return g.other??"";const n=X(d),t=n?n.select(a):a===1?"one":"other";return g[t]??g.other??""}function z(g,l={},d){const a=U(g,l,d);return a?a.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(l,t)?H(l[t],d):n):""}function w(g,l,d="en-GB"){return typeof g=="string"&&g?g:typeof l=="string"&&l?l:d}function v(g,l){const d=g?g[l]:void 0;return d==null||F(d)?l:d}}),Le("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/i18n/catalogue.js"),F=Q.EN_GB,B=Q.MESSAGE_KEYS,$=K("packages/core/src/i18n/format.js"),_=$.formatMessage,X=$.formatList,W=$.lookup,H=$.resolveLocale,U=K("packages/core/src/internal/util.js"),z=U.isFunction,w=U.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 $.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return $.resolveLocale}});const v="en-GB";class g{#e=v;#t=F;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,v);const r=t.messages;if(!r||typeof r!="object"){this.#t=F;return}const i=Object.keys(r).filter(f=>!(f in F));i.length&&w(`i18n:unknown:${i[0]}`,`message keys not in the catalogue and so ignored: ${i.slice(0,5).join(", ")}${i.length>5?`, and ${i.length-5} more`:""}`),this.#t={...F,...r}}get locale(){return this.#e}t(t,r){return _(W(this.#t,t),r||{},this.#e)}list(t,r){return X(t,this.#e,r)}number(t,r){const i=Number(t);return Number.isFinite(i)?i.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const l=new g;function d(n){return n instanceof g?n:new g(n||{})}function a(n){const t=n&&typeof n=="object"?n:{},r=B.filter(f=>{const u=t[f];return u==null||u===""||z(u)}),i=Object.keys(t).filter(f=>!(f in F));return{missing:r,unknown:i}}}),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 d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),F=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(n,t){const r=t||{},i=r.emptyDisplay??X.emptyDisplay;if(F(n)||n==="")return i;const u=[...typeof r.char=="string"&&r.char!==""?r.char:X.char][0]||X.char,o=r.fixedLength??X.fixedLength,m=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):X.length,c=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let h=0;if(c!==null){const s=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):X.lastVisible,p=[...c];if(h=s>0&&s<p.length?s:0,h>0){const b=p.slice(p.length-h).join(""),A=Math.max(1,(o?m:p.length)-h);return u.repeat(A)+b}return u.repeat(o?m:Math.max(1,p.length))}return u.repeat(m)}const H=48;function U(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function z(n,t){if(F(n))return"";const r=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):H;if(typeof n=="string")return n.length>r?`${n.slice(0,r-1)}…`:n;if(typeof n!="object")return String(n);const i=U(n);if(i!==null&&i.length<=r)return i;if(Array.isArray(n)){const u=n.length;return`[${_.t("count.items",{count:u})}]`}const f=Object.keys(n).length;return`{${_.t("count.keys",{count:f})}}`}function w(n,t){if(n==null)return"null";const r=typeof n;if(r==="number"||r==="boolean"||r==="bigint")return String(n);if(r==="string")return JSON.stringify(n);if(r!=="object")return JSON.stringify(String(n));const i=t||new WeakSet;return i.has(n)?'"[circular]"':(i.add(n),n instanceof Date?JSON.stringify(n.toISOString()):Array.isArray(n)?`[${n.map(o=>w(o,i)).join(",")}]`:`{${Object.keys(n).sort().map(o=>`${JSON.stringify(o)}:${w(n[o],i)}`).join(",")}}`)}function v(n,t){if(F(n))return F(t)?0:1;if(F(t))return-1;const r=w(n),i=w(t);return r<i?-1:r>i?1:0}function g(n){if(F(n))return null;const t=String(n);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function l(n){const t=n&&n.cell&&n.cell.props;return B(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:n=>z(n&&n.value,l(n&&n.column)),parse:n=>g(n&&n.text),compare:v,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if(F(n))return"";if(typeof n=="string")return n;try{const t=JSON.stringify(n,null,2);return t===void 0?String(n):t}catch{return String(n)}},fromClipboard:n=>g(n)},secret:{base:"text",storage:"object",format:n=>W(n&&n.value,l(n&&n.column)),parse:n=>{const t=n&&n.text;return F(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=F(n)||n==="",i=F(t)||t==="";return r===i?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>W(n),fromClipboard:n=>F(n)||String(n)===""?null:String(n)}}),a=d}),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 v}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),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 I}});const Q=K("packages/core/src/internal/util.js"),F=Q.isNil,B=Q.warnOnce;function $(C,O,N,G){return Object.freeze({symbol:C,factor:O,aliases:Object.freeze(N||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(C,O,N,G){return $(C,O,N,G)}const X=Object.freeze({data:Object.freeze([$("B",1,["byte","bytes"]),$("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),$("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),$("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),$("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),$("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),$("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),$("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),$("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),$("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([$("bps",1,["bit","bits","bit/s","b/s"]),$("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),$("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),$("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),$("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([$("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),$("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),$("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),$("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),$("in",.0254,["inch","inches"],{auto:!1}),$("ft",.3048,["foot","feet"],{auto:!1}),$("yd",.9144,["yard","yards"],{auto:!1}),$("m",1,["metre","metres","meter","meters"]),$("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),$("mi",1609.344,["mile","miles"],{auto:!1}),$("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([$("mg",.001,["milligram","milligrams"]),$("g",1,["gram","grams"]),$("oz",28.349523125,["ounce","ounces"],{auto:!1}),$("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),$("kg",1e3,["kilogram","kilograms"]),$("st",6350.29318,["stone"],{auto:!1}),$("t",1e6,["tonne","tonnes","ton"],{auto:!1}),$("ton (US)",907184.74,["ton","shortton"],{auto:!1}),$("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([$("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),$("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),$("ms",.001,["msec","msecs","millisecond","milliseconds"]),$("s",1,["sec","secs","second","seconds"]),$("m",60,["min","mins","minute","minutes"]),$("h",3600,["hr","hrs","hour","hours"]),$("d",86400,["day","days"])]),speed:Object.freeze([$("mm/s",.001,["millimetre/s","millimeter/s"]),$("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),$("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),$("mph",.44704,["mile/h","miles/h"],{auto:!1}),$("kn",1852/3600,["knot","knots"],{auto:!1}),$("m/s",1,["metre/s","meter/s","mps"]),$("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([$("mm/s²",.001,["mm/s2"]),$("ft/s²",.3048,["ft/s2"],{auto:!1}),$("m/s²",1,["m/s2","metre/s2","meter/s2"]),$("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([$("mm²",1e-6,["mm2"]),$("cm²",1e-4,["cm2"]),$("in²",64516e-8,["in2","sqin"],{auto:!1}),$("ft²",.09290304,["ft2","sqft"],{auto:!1}),$("yd²",.83612736,["yd2","sqyd"],{auto:!1}),$("m²",1,["m2","sqm"]),$("ha",1e4,["hectare","hectares"],{auto:!1}),$("ac",4046.8564224,["acre","acres"],{auto:!1}),$("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([$("µL",1e-6,["ul","microlitre","microliter"]),$("mL",.001,["millilitre","milliliter"]),$("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),$("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),$("L",1,["litre","litres","liter","liters"]),$("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),$("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),$("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),$("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([$("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),$("J",1,["joule","joules"]),$("cal",4.184,["calorie","calories"],{auto:!1}),$("kJ",1e3,["kilojoule","kilojoules"]),$("BTU",1055.05585262,["btu"],{auto:!1}),$("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),$("MJ",1e6,["megajoule","megajoules"]),$("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),$("GJ",1e9,["gigajoule","gigajoules"]),$("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([$("mW",.001,["milliwatt","milliwatts"]),$("W",1,["watt","watts"]),$("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),$("kW",1e3,["kilowatt","kilowatts"]),$("hp",745.6998715822702,["horsepower"],{auto:!1}),$("MW",1e6,["megawatt","megawatts"]),$("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([$("mN",.001,["millinewton","millinewtons"]),$("N",1,["newton","newtons"]),$("lbf",4.4482216152605,["poundforce"],{auto:!1}),$("kgf",9.80665,["kilogramforce"],{auto:!1}),$("kN",1e3,["kilonewton","kilonewtons"]),$("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([$("Pa",1,["pascal","pascals"]),$("mbar",100,["millibar"],{auto:!1}),$("inH₂O",249.0889,["inh2o"],{auto:!1}),$("mmHg",133.322387415,["torr"],{auto:!1}),$("kPa",1e3,["kilopascal","kilopascals"]),$("inHg",3386.388640341,["inhg"],{auto:!1}),$("psi",6894.757293168361,["lbf/in2"],{auto:!1}),$("bar",1e5,[],{auto:!1}),$("atm",101325,["atmosphere","atmospheres"],{auto:!1}),$("MPa",1e6,["megapascal","megapascals"]),$("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([$("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),$("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),$("kN·m",1e3,["knm","kn.m"],{auto:!1}),$("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([$("kg/m³",1,["kg/m3"]),$("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),$("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),$("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([$("L/min",1/6e4,["lpm","l/min"],{auto:!1}),$("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),$("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),$("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),$("cfm",.0004719474432,["ft3/min"],{auto:!1}),$("L/s",.001,["lps","l/s"],{auto:!1}),$("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([$("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),$("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),$("mrad",.001,["milliradian","milliradians"],{auto:!1}),$("mil",Math.PI/3200,["nato-mil"],{auto:!1}),$("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),$("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),$("rad",1,["radian","radians"]),$("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([$("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),$("rad/s",1,["radps","radians/s"]),$("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),$("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([$("ppt",1e-12,["partspertrillion"],{auto:!1}),$("ppb",1e-9,["partsperbillion"]),$("ppm",1e-6,["partspermillion"]),$("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),$("‰",.001,["permille","permil"],{auto:!1}),$("%",.01,["pct","percent"]),$("×",1,["x","ratio","times"])]),molarity:Object.freeze([$("pM",1e-12,["picomolar","picomolarity"]),$("nM",1e-9,["nanomolar","nanomolarity"]),$("µM",1e-6,["um-molar","micromolar","micromolarity"]),$("mM",.001,["millimolar","millimolarity"]),$("M",1,["molar","mol/l","mol/L","molarity"]),$("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([$("mg/s",1e-6,["milligrams/s"]),$("g/s",.001,["grams/s"]),$("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),$("kg/s",1,["kilograms/s","kgps"]),$("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),$("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),$("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([$("µPa·s",1e-6,["upas","micropascalsecond"]),$("cP",.001,["centipoise"],{auto:!1}),$("mPa·s",.001,["mpas","millipascalsecond"]),$("P",.1,["poise"],{auto:!1}),$("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([$("cSt",1e-6,["centistokes","centistoke"]),$("mm²/s",1e-6,["mm2/s"],{auto:!1}),$("St",1e-4,["stokes","stoke"],{auto:!1}),$("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([$("mW/(m·K)",.001,["mw/mk"]),$("W/(m·K)",1,["w/mk","wmk"]),$("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),$("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([$("J/(kg·K)",1,["j/kgk","jkgk"]),$("kJ/(kg·K)",1e3,["kj/kgk"]),$("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([$("nSv/h",1e-9,["nsvh"]),$("µSv/h",1e-6,["usv/h","usvh"]),$("mSv/h",.001,["msvh"]),$("Sv/h",1,["svh"]),$("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),W=Symbol("ambiguous"),H=new Map,U=new Map;function z(C,O){const N=String(C||"").trim();if(!N)throw new Error("[lattice] a unit system needs a name");if(X[N]||U.has(N))throw new Error(`[lattice] unit system "${N}" already exists`);const G=[...O||[]];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 U.set(N,Object.freeze(G)),H.delete(N),N}function w(){return[...Object.keys(X),...U.keys()]}function v(C){const O=g(C);return O?O.units:[]}function g(C){const O=String(C||""),N=H.get(O);if(N!==void 0)return N;const G=X[O]||U.get(O);if(!G)return H.set(O,null),null;const q=Object.freeze([...G].sort((oe,le)=>oe.factor-le.factor)),Z=new Map,J=new Map,te=(oe,le)=>{const ae=Z.get(oe);ae===void 0?Z.set(oe,le):ae!==le&&Z.set(oe,W)};for(const oe of q){te(oe.symbol.toLowerCase(),oe);for(const le of oe.aliases)te(le.toLowerCase(),oe);if(oe.prefix){const le=J.get(oe.prefix)||[];le.push(oe),J.set(oe.prefix,le)}}const ne={units:q,byToken:Z,byPrefix:J,decimal:q.filter(oe=>!oe.binary&&oe.auto),binary:q.some(oe=>oe.binary)?q.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return H.set(O,ne),ne}function l(C,O){return O&&C.binary||C.decimal}function d(C,O){const N=g(C);if(!N||F(O))return null;const G=N.units.find(Z=>Z.symbol===String(O));if(G)return G;const q=N.byToken.get(String(O).trim().toLowerCase());return q&&q!==W?q:null}const a=new WeakMap;function n(C){const O=C||{};if(typeof O=="object"&&O!==null){const Z=a.get(O);if(Z!==void 0)return Z}const N=O.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=O.unit?d(N,O.unit):null;Z||(O.unit&&B(`unit:unit:${N}:${O.unit}`,`unknown unit "${O.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:O.binary===!0}}return typeof O=="object"&&O!==null&&a.set(O,q),q}const t=new WeakMap;function r(C,O){if(!C||!O||!Array.isArray(C.compound)||C.compound.length===0)return null;const N=t.get(C);if(N!==void 0)return N;const G=new Set,q=[];for(const J of C.compound){const te=d(C.system||"data",J);if(!te){B(`unit:compound:${C.system}:${J}`,`unknown compound unit "${J}" in system "${C.system||"data"}"; ignoring it`);continue}G.has(te.symbol)||(G.add(te.symbol),q.push(te))}q.sort((J,te)=>te.factor-J.factor);const Z=q.length>=2?q:null;return t.set(C,Z),Z}function i(C,O,N){return O===N||O.factor===N.factor?C:C*O.factor/N.factor}const f=new Map;function u(C){const O=C||"",N=f.get(O);if(N)return N;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(C||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return f.set(O,G),G}const o=/[\s ]/g,m=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function s(C,O){const{group:N,decimal:G}=u(O);let q=String(C).replace(o,"");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(".")),!h.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function p(C,O,N){const G=String(C).trim().replace(/\.$/,"");if(G==="")return null;const q=O.units.find(le=>le.symbol===G);if(q)return q;const Z=G.toLowerCase(),J=O.byToken.get(Z);if(J===W)return null;if(J)return J;const te=O.byPrefix.get(Z);if(!te||!te.length)return null;const ne=l(O,N),oe=te.filter(le=>ne.includes(le));return oe.length===1?oe[0]:null}function b(C,O,N,G){let q=C,Z=0,J=!1,te=!1;for(;q!=="";){const ne=m.exec(q)[0];if(ne==="")return null;const oe=s(ne,G&&G.locale);if(oe===null)return null;q=q.slice(ne.length).trim();const le=q.search(/[+-]?[\d]/),ae=(le>=0?q.slice(0,le):q).trim();if(q=le>=0?q.slice(le).trim():"",ae===""){if(J)return null;te=!0,Z+=i(oe,N[0],O.base)}else{const se=p(ae,O.index,O.binary);if(!se)return null;Z+=i(oe,se,O.base)}if(J=!0,te&&q!=="")return null}return J?Z:null}function A(C,O){if(F(C))return null;if(typeof C=="number")return Number.isFinite(C)?C:null;const N=n(O);if(!N)return null;let G=String(C).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Z=r(O,N);if(Z){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const ee=b(G,N,Z,O);return ee===null?null:q?-ee:ee}let J=null;const te=c.exec(G);if(te&&te[0]){const ee=p(te[0].trim(),N.index,N.binary);ee&&(J=ee,G=G.slice(te[0].length).trim())}const ne=m.exec(G)[0],oe=s(ne,O&&O.locale);if(oe===null)return null;const le=G.slice(ne.length).trim();if(J&&le!=="")return null;const ae=J||(le===""?N.base:p(le,N.index,N.binary));if(!ae)return null;const se=i(oe,ae,N.base);return q?-se:se}const k=new Map;function y(C,O,N,G){const q=`${C||""}|${O}|${N}|${G?1:0}`;let Z=k.get(q);return Z||(Z=new Intl.NumberFormat(C||void 0,{minimumFractionDigits:O,maximumFractionDigits:N,useGrouping:G}),k.set(q,Z)),Z}function S(C,O){if(!Number.isFinite(C)||C===0)return Math.max(0,O-1);const N=Math.floor(Math.log10(Math.abs(C)));return Math.min(20,Math.max(0,O-1-N))}function R(C,O){if(!Number.isFinite(C)||C===0)return C;const N=Math.ceil(Math.log10(Math.abs(C))),G=10**(O-N);return Math.round(C*G)/G}function j(C,O,N){if(!N||N===O.base.symbol)return O.base;if(N!=="auto")return x(O,N);if(C===0||!Number.isFinite(C))return O.base;const G=Math.abs(C)*O.base.factor,q=l(O.index,O.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 O.index.units)ne.binary!==O.binary&&ne.factor!==1||ne.factor<=G&&ne.factor>(J===Z?0:J.factor)&&(J=ne);if(J!==Z)return J;let te=Z;for(const ne of O.index.units)ne.binary!==O.binary&&ne.factor!==1||ne.factor<te.factor&&(te=ne);return te.factor<O.base.factor?te:O.base}function x(C,O){const N=C.index.units.find(q=>q.symbol===O);if(N)return N;const G=C.index.byToken.get(String(O).toLowerCase());return G&&G!==W?G:(B(`unit:display:${O}`,`unknown display unit "${O}"; rendering in ${C.base.symbol}`),C.base)}function E(C,O,N,G){const q=C<0;let Z=Math.abs(C)*O.base.factor;const J=typeof G.decimals=="number"?G.decimals:G.minDecimals??0,te=typeof G.decimals=="number"?G.decimals:G.maxDecimals??Math.max(J,2),ne=G.space??" ",oe=[];for(let ae=0;ae<N.length;ae++){const se=N[ae],ee=ae===N.length-1;let ie=ee?Z/se.factor:Math.floor(Z/se.factor);if(Z-=ie*se.factor,ee){const he=10**te;ie=Math.round(ie*he)/he+0}const ce=ee?y(G.locale,J,te,G.group!==!1):y(G.locale,0,0,G.group!==!1);oe.push(`${ce.format(ie)}${ne}${se.symbol}`)}const le=oe.join(" ");return q?`-${le}`:le}function T(C,O){const N=O||{},G=N.nullDisplay??"";if(F(C)||C==="")return G;const q=typeof C=="number"?C:Number(C);if(!Number.isFinite(q))return G;const Z=n(N);if(!Z)return String(q);const J=r(N,Z);if(J)return E(q,Z,J,N);const te=typeof N.significantFigures=="number"&&N.significantFigures>0?N.significantFigures:0,ne=te?R(q,te):q,oe=j(ne,Z,N.display),le=i(ne,Z.base,oe);let ae=typeof N.decimals=="number"?N.decimals:N.minDecimals??0,se=typeof N.decimals=="number"?N.decimals:N.maxDecimals??Math.max(ae,2);te&&(ae=S(le,te),se=ae);const ee=y(N.locale,ae,se,N.group!==!1).format(le),ie=N.space??" ";return N.placement==="prefix"?`${oe.symbol}${N.space??""}${ee}`:`${ee}${ie}${oe.symbol}`}function L(C,O){const N=F(C)||Number.isNaN(C)?null:Number(C),G=F(O)||Number.isNaN(O)?null:Number(O);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 P(C){const O=typeof C.decimals=="number"&&C.decimals>0?`.${"0".repeat(C.decimals)}`:"";return`${typeof C.decimals=="number"?`#,##0${O}`:"#,##0.##"}" ${C.symbol}"`}function D(C){const O={system:"data",...C||{}},N=n(O),G=N?N.base.symbol:String(O.unit||""),q=Object.freeze({...O,unit:G}),Z=Object.freeze({...q,display:G,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),te=ne=>{const oe=ne||"";let le=J.get(oe);return le||(le=Object.freeze({...q,locale:ne||void 0}),J.set(oe,le)),le};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>T(ne.value,ne.locale?te(ne.locale):q),parse:ne=>A(ne.text,ne.locale?te(ne.locale):q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:O.total||"sum"},...O.totals?{totals:O.totals}:{},excel:O.excel||P({decimals:O.decimals,symbol:G}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?A(ne,q):F(ne)?null:A(String(ne),q),toClipboard:ne=>T(ne,Z),fromClipboard:ne=>A(ne,q)}}const I=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 F=K("packages/core/src/internal/util.js").isNil,$=K("packages/core/src/columns/types/unit.js").createUnitType;function _(H){const U=2*Math.PI/H;return z=>{let w=0,v=0,g=0;for(const d of z||[]){if(F(d))continue;const a=Number(d);Number.isFinite(a)&&(w+=Math.cos(a*U),v+=Math.sin(a*U),g+=1)}return!g||Math.hypot(w,v)/g<1e-12?null:(Math.atan2(v,w)/U%H+H)%H}}function X(H){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(H)}}}const W=Object.freeze({metres:$({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:$({system:"length",unit:"mm",maxDecimals:2}),kilometres:$({system:"length",unit:"km",maxDecimals:3}),grams:$({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:$({system:"mass",unit:"kg",maxDecimals:3}),tonnes:$({system:"mass",unit:"t",maxDecimals:3}),seconds:$({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:$({system:"duration",unit:"ms",maxDecimals:3}),hours:$({system:"duration",unit:"h",maxDecimals:2}),speed:$({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:$({system:"speed",unit:"km/h",maxDecimals:1}),mph:$({system:"speed",unit:"mph",maxDecimals:1}),knots:$({system:"speed",unit:"kn",maxDecimals:1}),acceleration:$({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:$({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:$({system:"area",unit:"ha",maxDecimals:4}),volume:$({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:$({system:"volume",unit:"m³",maxDecimals:3}),energy:$({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:$({system:"energy",unit:"kWh",maxDecimals:2}),power:$({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:$({system:"power",unit:"kW",maxDecimals:2}),force:$({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:$({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:$({system:"pressure",unit:"bar",maxDecimals:3}),psi:$({system:"pressure",unit:"psi",maxDecimals:1}),torque:$({system:"torque",unit:"N·m",maxDecimals:2}),density:$({system:"density",unit:"kg/m³",maxDecimals:2}),flow:$({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:$({system:"flow",unit:"L/min",maxDecimals:1}),radians:$({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:$({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:$({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:$({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:$({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:$({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:$({system:"fraction",unit:"bp",maxDecimals:1}),molarity:$({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:$({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:$({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:$({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:$({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:$({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:$({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:$({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 H}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return U}}),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"),F=Q.defineUnit,B=Q.registerUnitSystem,$=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(v){const g=String(v.base),l=new Set([...v.prefixes||X,""]),d=[];for(const a of _){if(!l.has(a.symbol))continue;const n=`${a.symbol}${g}`,t=[];if(v.name){t.push(`${a.name}${v.name}`,`${a.name}${v.name}s`);const r=a.name.slice(-1);if(r&&v.name.startsWith(r)){const i=`${a.name.slice(0,-1)}${v.name}`;t.push(i,`${i}s`)}}a.symbol==="µ"&&t.push(`u${g}`),a.factor===1&&v.aliases&&t.push(...v.aliases),d.push(F(n,a.factor,t))}for(const a of v.extra||[])d.push(a);return d}function H(v,g){const l=W(g);return B(v,l)}function U(v,g,l){return H(v,g),$({system:v,unit:g.base,display:"auto",maxDecimals:3,...l||{}})}const z=Object.freeze({voltage:U("voltage",{base:"V",name:"volt"}),current:U("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:U("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:U("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:U("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:U("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[F("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),F("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:U("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:U("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[F("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:U("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:U("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:U("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:U("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:U("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:U("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:U("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[F("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:U("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=U}),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 $}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const F=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function $(d){if(F(d))return null;const a=String(d).trim();if(a==="")return null;for(const[t,r]of Object.entries(B))if(a===t||a===r.symbol)return{key:t,scale:r};const n=a.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function _(d,a,n){const t=$(a),r=$(n);return!t||!r||!Number.isFinite(Number(d))?null:t.key===r.key?Number(d):r.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const X=new Map;function W(d,a,n){const t=`${d||""}|${a}|${n}`;let r=X.get(t);return r||(r=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:a,maximumFractionDigits:n}),X.set(t,r)),r}function H(d,a){const n=a||{},t=n.nullDisplay??"";if(F(d)||d==="")return t;const r=Number(d);if(!Number.isFinite(r))return t;const i=$(n.scale||"C");if(!i)return String(r);const f=$(n.display||n.scale||"C")||i,u=f.key===i.key?r:f.scale.fromKelvin(i.scale.toKelvin(r)),o=typeof n.decimals=="number"?n.decimals:null,m=o??n.minDecimals??0,c=o??n.maxDecimals??1;return`${W(n.locale,m,c).format(u)}${n.space??" "}${f.scale.symbol}`}const U=/^[+-]?[\d\s., ]*\d/;function z(d,a){const n=String(d).trim();if(n==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",r=t===","?".":",",i=n.split(r).join("").split(/[\s ]/).join("").replace(t,"."),f=Number(i);return Number.isFinite(f)?f:null}function w(d,a){if(F(d))return null;const n=a||{},t=$(n.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let r=String(d).trim();if(r==="")return null;let i=!1;r.startsWith("(")&&r.endsWith(")")&&(i=!0,r=r.slice(1,-1).trim());const f=U.exec(r);if(!f)return null;const u=z(f[0],n.locale);if(u===null)return null;const o=r.slice(f[0].length).trim();if(o==="")return i?-u:u;const m=$(o);if(!m)return null;const c=m.key===t.key?u:t.scale.fromKelvin(m.scale.toKelvin(u));return i?-c:c}function v(d){const a=Object.freeze({scale:"C",...d||{}}),t=($(a.scale)||$("C")).scale.symbol,r=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),i=new Map([[a.locale||"",a]]),f=u=>{const o=u||"";let m=i.get(o);return m||(m=Object.freeze({...a,locale:u||void 0}),i.set(o,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:u=>H(u.value,u.locale?f(u.locale):a),parse:u=>w(u.text,u.locale?f(u.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:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?w(u,a):F(u)?null:w(String(u),a),toClipboard:u=>H(u,r),fromClipboard:u=>w(u,a)}}const g=Object.freeze({celsius:v({scale:"C"}),fahrenheit:v({scale:"F"}),kelvin:v({scale:"K"})}),l=v}),Le("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return o}}),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 x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/core/src/internal/util.js"),F=Q.isNil,B=Q.warnOnce,$=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}),H=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=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,v=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),l=new WeakSet,d=new WeakMap,a=new Map,n=new WeakMap,t=new WeakMap,r=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 i(T){if(T==null)return 16;const L=typeof T=="string"?T.toLowerCase():T,P=$[L];return P||(B(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(T,L){return Math.ceil(T/_[L])}function u(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 P=2**(T-1);return{min:-P,max:P-1}}function o(T){return U[T]||"hexadecimal"}function m(T){if(typeof T=="string"){const L=r[T];return L||B(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(r).join(", ")}`),{...L||{}}}if(T&&typeof T.preset=="string"){const L=r[T.preset];return L||B(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...L||{},...T}}return T||{}}function c(T){const L=m(T),P=i(L.radix),D=_[P];let I=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ne=Number(L.bitWidth);g.includes(ne)?I=ne:B(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let C=L.signed!==!1;!C&&I===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),I=32);const O=L.prefix===void 0||L.prefix===!0?X[P]:L.prefix===!1?"":String(L.prefix);let N=0;L.pad===!0?N=I?f(I,P):0:typeof L.pad=="number"&&L.pad>0&&(N=Math.floor(L.pad));let G=0;L.group===!0?G=W[P]:typeof L.group=="number"&&L.group>0&&(G=Math.floor(L.group));const q=u(I,C),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,te=Object.freeze({radix:P,bits:D,prefix:O,uppercase:L.uppercase!==!1,pad:N,group:G,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:I,signed:C,min:Z,max:J<Z?Z:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:o(P)});return l.add(te),te}function h(T){if(T&&l.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=d.get(T);return L||(L=c(T),d.set(T,L)),L}return h("hex")}function s(T){return T<0?-Math.round(-T):Math.round(T)}function p(T,L,P){if(L<=0||T.length<=L)return T;const D=T.length%L||L,I=[T.slice(0,D)];for(let C=D;C<T.length;C+=L)I.push(T.slice(C,C+L));return I.join(P)}function b(T){const L=h(T),{radix:P,prefix:D,uppercase:I,pad:C,group:O,groupSeparator:N,signed:G,bitWidth:q,nullDisplay:Z}=L,J=q?2**q:0,te=ne=>{if(F(ne)||ne==="")return Z;const oe=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(oe))return Z;const le=s(oe);let ae="",se=le;le<0&&(G?(ae="-",se=-le):se=(le%J+J)%J);let ee=se.toString(P);return ee=I?ee.toUpperCase():ee.toLowerCase(),C>0&&ee.length<C&&(ee=ee.padStart(C,"0")),O>0&&(ee=p(ee,O,N)),ae+D+ee};return te.options=L,te}function A(T,L){const P=h(L);let D=n.get(P);return D||(D=b(P),n.set(P,D)),D(T)}function k(T){const L=h(T),{radix:P,groupSeparator:D,signed:I,min:C,max:O}=L,N=H[P],G=q=>{if(F(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 te=null;for(const[oe,le]of z){const ae=oe.exec(Z);if(!ae)continue;const se=Z.slice(ae[0].length);if(se==="")break;if(!H[le].test(se))return{ok:!1,value:null,reason:"digits"};te=parseInt(se,le);break}if(te===null)if(N.test(Z))te=parseInt(Z,P);else if(v.test(Z))te=Number(Z);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const ne=s(J?-te:te);return!I&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<C||ne>O?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return G.options=L,G}function y(T,L){const P=h(L);let D=t.get(P);return D||(D=k(P),t.set(P,D)),D(T)}function S(T,L){const P=y(T,L);return P.ok?P.value:null}function R(T,L){const P=F(T)||Number.isNaN(T)?null:Number(T),D=F(L)||Number.isNaN(L)?null:Number(L);return P===null?D===null?0:1:D===null||P<D?-1:P>D?1:0}function j(T){const L=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&L?"int32":"float64"}function x(T){const L=c(T),P=b(L),D=k(L);return{base:"number",extends:"number",storage:j(L),matches:null,format:I=>P(I.value),parse:I=>{const C=D(I.text);return C.ok?C.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:I=>P(I),fromClipboard:I=>{const C=D(I);return C.ok?C.value:null},radix:L,formatValue:P,parseText:D}}const E=x}),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 H}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const F=K("packages/core/src/internal/util.js").isNil;function B(z){const w=[];for(const v of z||[]){if(F(v))continue;const g=Number(v);Number.isFinite(g)&&w.push(g)}return w}function $(z){return w=>{const v=B(w);if(!v.length)return null;let g=0;for(const l of v)g+=10**(l/z);return z*Math.log10(g)}}function _(z){return w=>{const v=B(w);if(!v.length)return null;let g=0;for(const l of v)g+=10**(l/z);return z*Math.log10(g/v.length)}}function X(z,w){const v=w&&w.column,l=(v&&v.typeOptions||{}).weight,d=w&&w.valueAt;if(!l||typeof d!="function")return null;let a=0,n=0;for(let t=0;t<z.length;t++){if(F(z[t]))continue;const r=Number(z[t]);if(!Number.isFinite(r))continue;const i=d(l,t);if(F(i))continue;const f=Number(i);!Number.isFinite(f)||f<=0||(a+=r*f,n+=f)}return n===0?null:a/n}function W(z={}){const w=z.factor===20?20:10,v=typeof z.suffix=="string"?z.suffix:"",g=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:l=>{const d=l&&l.value;return F(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(g)}${v}`},parse:l=>{const d=String((l&&l.text)??"").replace(v,"").trim();if(!d)return null;const a=Number(d);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:$(w),avg:_(w)}}}}function H(z={}){const w=Number.isInteger(z.decimals)?z.decimals:1,v=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:g=>{const l=g&&g.value;return F(l)||!Number.isFinite(Number(l))?"":v?`${Number(l).toFixed(w)}%`:Number(l).toFixed(w)},parse:g=>{const l=String((g&&g.text)??"").replace("%","").trim();if(!l)return null;const d=Number(l);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const U=Object.freeze({decibel:W({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:W({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:H({name:"ratio"}),percentRate:H({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 $}}),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 v}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const F=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function $(u){if(F(u))return null;const o=String(u).trim().toUpperCase();return o===""?null:o}function _(u){if(F(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const o=Number(u.amount),m=$(u.code);return!m||!Number.isFinite(o)?null:{amount:o,code:m}}if(Array.isArray(u)&&u.length===2){const o=Number(u[0]),m=$(u[1]);return!m||!Number.isFinite(o)?null:{amount:o,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:"₪"}),H=/[+-]?[\d\s., ]*\d/;function U(u,o){const m=String(u).trim();if(m==="")return null;const c=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",h=c===","?".":",",s=m.split(h).join("").split(/[\s ]/).join("").replace(c,"."),p=Number(s);return Number.isFinite(p)?p:null}function z(u,o){const m=o||{},c=$(m.code);if(F(u))return null;const h=_(u);if(h)return h;if(typeof u=="number")return Number.isFinite(u)&&c?{amount:u,code:c}:null;let s=String(u).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[j,x]of Object.entries(X)){if(s.startsWith(j)){b=x,s=s.slice(j.length).trim();break}if(s.endsWith(j)){b=x,s=s.slice(0,-j.length).trim();break}}const A=H.exec(s);if(!A)return null;const k=U(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=$(y));const S=b||c;return S?{amount:p?-k:k,code:S}:null}function w(u,o){if(typeof u=="function")return(m,c)=>{if(m===c)return 1;const h=u(m,c);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(u&&typeof u=="object"){const m=u;return(c,h)=>{if(c===h)return 1;const s=Number(m[c]),p=Number(m[h]);return!Number.isFinite(s)||!Number.isFinite(p)||s<=0||p<=0?null:p/s}}return(m,c)=>m===c?1:null}function v(u,o,m){if(!u)return null;if(u.code===o)return u.amount;const c=m(u.code,o);return c===null?null:u.amount*c}const g=new Map;function l(u,o,m){const c=`${u||""}|${o}|${m??""}`;let h=g.get(c);if(!h){const s={style:"currency",currency:o};typeof m=="number"&&(s.minimumFractionDigits=m,s.maximumFractionDigits=m);try{h={fmt:new Intl.NumberFormat(u||void 0,s),currency:!0}}catch{h={fmt:new Intl.NumberFormat(u||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(c,h)}return h}function d(u,o){const m=o||{},c=m.nullDisplay??"",h=_(u);if(!h)return c;const s=$(m.display)||h.code;let p=h.amount,b=h.code;if(s!==h.code){const y=m.rateFn||w(m.rates,m.rateBase),S=v(h,s,y);if(S===null)return`${m.missingRate??B} ${h.code}→${s}`;p=S,b=s}const{fmt:A,currency:k}=l(m.locale,b,m.decimals);return k?A.format(p):`${A.format(p)} ${b}`}function a(u){const o=_(u);return o?`${o.amount} ${o.code}`:""}function n(u){const o=u||{},m=$(o.display),c=o.rateFn||w(o.rates,o.rateBase);return(h,s)=>{const p=_(h),b=_(s);if(!p&&!b)return 0;if(!p)return 1;if(!b)return-1;if(m){const A=v(p,m,c),k=v(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(u){const o=u||{},m=(h,s)=>{const p=[];for(const S of h||[]){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=$(o.display);if(!A)return`${o.missingRate??B}: mixed currencies, no display currency set`;const k=o.rateFn||w(o.rates,o.rateBase),y=[];for(const S of p){const R=v(S,A,k);if(R===null)return`${o.missingRate??B}: ${S.code}→${A}`;y.push(R)}return{amount:s(y),code:A}},c=h=>h.reduce((s,p)=>s+p,0);return{sum:h=>m(h,c),avg:h=>m(h,s=>c(s)/s.length),min:h=>m(h,s=>Math.min(...s)),max:h=>m(h,s=>Math.max(...s))}}function r(u){const o=Object.freeze({code:"USD",...u||{}}),m=w(o.rates,o.rateBase),c=Object.freeze({...o,rateFn:m}),h=t(c),s=n(c),p=new Map([[o.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[$(o.display||o.code)]||"",k=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:y=>d(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:h},excel:o.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 i=Object.freeze({currency:r({code:"USD"}),usd:r({code:"USD"}),eur:r({code:"EUR"}),gbp:r({code:"GBP"}),jpy:r({code:"JPY",decimals:0})}),f=r}),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 H}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U}}),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 v}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),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 j}});const Q=K("packages/core/src/columns/types/temporal.js"),F=Q.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),$=B.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),X=_.STRUCTURED_TYPES,W=K("packages/core/src/columns/types/unit.js"),H=W.createUnitType,U=W.UNIT_SYSTEMS,z=W.parseUnit,w=W.formatUnit,v=W.registerUnitSystem,g=W.unitSystemNames,l=W.unitsOf,d=W.defineUnit,a=K("packages/core/src/columns/types/engineering.js"),n=a.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,i=t.createSiType,f=t.createSiSystem,u=t.siUnits,o=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),c=m.TEMPERATURE_TYPES,h=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,j=k.formatRadix,x=K("packages/core/src/columns/types/aggregable.js"),E=x.AGGREGABLE_TYPES,T=K("packages/core/src/columns/types/currency.js"),L=T.CURRENCY_TYPES,P=T.createCurrencyType,D=T.parseMoney,I=T.formatMoney,C=T.convertMoney,O=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 x.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return x.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x.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({...F,...$,...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:H({system:"data",unit:"B",display:"auto"}),megabytes:H({system:"data",unit:"MB"}),gigabytes:H({system:"data",unit:"GB"}),bitrate:H({system:"bitrate",unit:"Mbps"}),gigabits:H({system:"bitrate",unit:"Gbps"}),...n,...r,...c,...L});{const te=new Set;for(const ne of[F,$,X,E,n,r,c,L])for(const oe of Object.keys(ne)){if(te.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);te.add(oe)}}}),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 U}}),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 v}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),F=Q.collator,B=Q.defaultCompare,$=Q.warnOnce;function _(r){const i=new Uint32Array(r);for(let f=0;f<r;f++)i[f]=f;return i}function X(r,i){if(i&&typeof i.count=="number")return i.count;if(!r)return 0;if(typeof r.count=="number")return r.count;if(typeof r.length=="number")return r.length;const f=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):f?r.kind==="bitset"?typeof f.size=="number"?f.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:($(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const W=new WeakMap;function H(r){const i=r.constructor;if(!i)return"unknown";const f=W.get(i);if(f)return f;let u="unknown";try{let o=null;typeof i.from=="function"?o=i.from([!1,!0]):(o=new i(8),o.set(1));const m=o&&o.words;m&&m.length&&(m[0]===2?u="lsb":m[0]===64&&(u="msb"))}catch{u="unknown"}return W.set(i,u),u}function U(r){if(!r)return()=>0;const i=r instanceof Uint8Array?r:r.words;if(i instanceof Uint8Array){const f=r instanceof Uint8Array?"lsb":H(r);if(f==="lsb")return u=>i[u>>>3]>>>(u&7)&1;if(f==="msb")return u=>i[u>>>3]>>>7-(u&7)&1}return typeof r.get=="function"?f=>r.get(f)?1:0:()=>0}function z(r){return!r||!r.presence?null:U(r.presence)}function w(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function v(r,i){return r?typeof r.valueOf=="function"?r.valueOf(i):typeof r.values=="function"?r.values()[i]:null:null}function g(r,i){const f=r.offsets,u=r.values;if(!f||!u)return[];const o=f[i],m=f[i+1];if(!(m>o))return[];const c=r.dict,h=new Array(m-o);for(let s=o;s<m;s++)h[s-o]=c?v(c,u[s]):u[s];return h}function l(r){if(!r)return()=>{};const i=r.values,f=z(r),u=r.kind;if(u==="dictionary"){const o=r.dict;return f?m=>f(m)?v(o,i[m]):null:m=>v(o,i[m])}if(u==="bitset"){const o=U(i);return f?m=>f(m)?o(m)===1:null:m=>o(m)===1}if(u==="multi")return f?o=>f(o)?g(r,o):null:o=>g(r,o);if(!i&&typeof r.get=="function"){const o=r.get.bind(r);return m=>{const c=o(m);return c===void 0?null:c}}return f?o=>{if(!f(o))return null;const m=i[o];return m===void 0?null:m}:o=>{const m=i[o];return m===void 0?null:m}}function d(r,i){if(r<i)return-1;if(r>i)return 1;if(r===i){const o=Object.is(r,-0),m=Object.is(i,-0);return o===m?0:o?-1:1}const f=Number.isNaN(r),u=Number.isNaN(i);return f&&u?0:f?1:-1}function a(r){const i=F(r);return(f,u)=>{if(f===u)return 0;const o=typeof f,m=typeof u;if(o==="string"&&m==="string")return i.compare(f,u);if(o==="number"&&m==="number")return d(f,u);if(o==="boolean"&&m==="boolean")return f===u?0:f?1:-1;if(f instanceof Date||u instanceof Date){const c=f instanceof Date?f.getTime():Number(f),h=u instanceof Date?u.getTime():Number(u);return d(c,h)}return B(f,u)}}function n(r,i){if(r&&typeof r.ranks=="function")return r.ranks(i);const f=r&&typeof r.values=="function"?r.values():[],u=f.length,o=a(i),m=new Array(u);for(let h=0;h<u;h++)m[h]=h;m.sort((h,s)=>o(f[h],f[s])||h-s);const c=new Uint32Array(u);for(let h=0;h<u;h++)c[m[h]]=h;return c}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),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 P}}),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 te}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ae}});const Q=K("packages/core/src/internal/util.js"),F=Q.isBlank,B=Q.toArray,$=Q.warnOnce,_=K("packages/core/src/format/date.js"),X=_.toDate,W=_.toIsoDate,H=K("packages/core/src/compute/handle.js"),U=H.bitReader,z=H.dictSize,w=H.dictValue,v=H.presenceReader,g=H.valueComparator,l=H.valueReader,d=/^\d{4}-\d{2}-\d{2}$/,a="\0null\0";function n(se,ee){const ie=se&&se.pool;if(ie){const ce=ie.mask||ie.acquireMask||ie.acquire||ie.take;if(typeof ce=="function"){const he=ce.call(ie,ee);if(he&&he.length>=ee)return he}}return new Uint8Array(ee)}function t(se,ee){const ie=se&&se.pool;if(!ie||!ee)return;const ce=ie.release||ie.releaseMask||ie.free||ie.recycle;typeof ce=="function"&&ce.call(ie,ee)}function r(se,ee,ie){return se.fill(ie,0,ee),se}function i(se){return se==null||typeof se=="number"&&Number.isNaN(se)}function f(se,ee){if(se==null)return se;if(ee==="number")return typeof se=="number"?se:Number(se);if(ee==="date"||ee==="dateString"){const ie=W(se);return ie===null?u(se):ie}return ee==="boolean"?typeof se=="boolean"?se:se==="true"||se===1?!0:se==="false"||se===0?!1:!!se:se}function u(se){return se instanceof Date?se.getTime():typeof se=="number"?se:Date.parse(String(se))}function o(se){return typeof se=="number"?se:se instanceof Date?se.getTime():se==null||se===""?NaN:Number(se)}function m(se,ee){const ie=typeof se=="string"?se:String(se);return ee?ie:ie.toLowerCase()}function c(se,ee){return se==null?a:typeof se=="string"?ee?se:se.toLowerCase():se instanceof Date?se.getTime():se}function h(se,ee,ie){const ce=new Set;for(const he of B(se)){const ge=f(he,ie);ce.add(c(ge,ee)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(c(String(ge),ee))}return ce}function s(se,ee,ie){if(se==null||ee===null||ee===void 0)return se==null&&ee==null;const ce=typeof se,he=typeof ee;return ce==="string"&&he==="string"?ie?se===ee:se.toLowerCase()===ee.toLowerCase():se instanceof Date||ee instanceof Date?u(se)===u(ee):ce==="number"&&he==="number"?se===ee||Number.isNaN(se)&&Number.isNaN(ee):ce==="number"&&he==="string"?se===Number(ee):ce==="string"&&he==="number"?Number(se)===ee:ce==="boolean"||he==="boolean"?se===ee:Array.isArray(se)&&Array.isArray(ee)?se.length===ee.length&&se.every((ge,Ee)=>s(ge,ee[Ee],ie)):se===ee}function p(se,ee){try{if(se instanceof RegExp){const ie=se.flags.replace(/[gy]/g,"");return new RegExp(se.source,ee||ie.includes("i")?ie:`${ie}i`)}return new RegExp(String(se),ee?"":"i")}catch(ie){return $(`regex:${String(se)}`,`filter operator "matches" received an invalid pattern: ${String(se)}`,ie),null}}function b(se,ee){if(se&&se.type==="datetime"&&A.has(se.op))return j(se,ee);const ie=x(se,ee),ce=se&&se.type;return ce!=="date"&&ce!=="dateString"?ie:he=>ie(typeof he=="string"&&d.test(he)?he:W(he)??he)}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(se,ee){let ie=y.get(ee);if(ie===void 0){try{ie=new Intl.DateTimeFormat("en-CA",{timeZone:ee,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{ie=null}y.set(ee,ie)}if(!ie)return null;const ce={};for(const he of ie.formatToParts(se))he.type!=="literal"&&(ce[he.type]=he.value);return ce}function R(se,ee){if(se==null||se==="")return null;if(typeof se=="string"){const ge=k.exec(se.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 ie=X(se);if(!ie)return null;const ce=ie.getUTCMilliseconds(),he=ee?S(ie,ee):null;return he?Date.UTC(+he.year,+he.month-1,+he.day,he.hour==="24"?0:+he.hour,+he.minute,+he.second,ce):Date.UTC(ie.getFullYear(),ie.getMonth(),ie.getDate(),ie.getHours(),ie.getMinutes(),ie.getSeconds(),ce)}function j(se,ee){const ie=typeof se.timeZone=="string"&&se.timeZone?se.timeZone:void 0,ce=Ee=>R(Ee,ie),he=Array.isArray(se.value)?se.value.map(ce):ce(se.value),ge=x({...se,type:"number",value:he},ee);return Ee=>ge(R(Ee))}function x(se,ee){const ie=se&&se.op,ce=!!(se&&se.caseSensitive),he=se&&se.type,ge=g(ee),Ee=ye=>Ae=>!ye(Ae);switch(ie){case"eq":{const ye=f(se.value,he);return Ae=>s(Ae,ye,ce)}case"ne":{const ye=f(se.value,he);return Ae=>!s(Ae,ye,ce)}case"lt":case"lte":case"gt":case"gte":{const ye=f(se.value,he);if(i(ye))return()=>!1;const Ae=ie==="lt"?-1:ie==="lte"?0:ie==="gt"?1:2;return pe=>{if(i(pe))return!1;const we=ge(pe,ye);return Ae===-1?we<0:Ae===0?we<=0:Ae===1?we>0:we>=0}}case"between":case"notBetween":{const ye=B(se.value),Ae=f(ye[0],he),pe=f(ye[1],he),we=se.bounds||"[]",be=we.charAt(0)!=="(",Ne=we.charAt(1)!==")";if(i(Ae)||i(pe))return ie==="between"?()=>!1:()=>!0;const $e=Ve=>{if(i(Ve))return!1;const Ye=ge(Ve,Ae),je=ge(Ve,pe);return(be?Ye>=0:Ye>0)&&(Ne?je<=0:je<0)};return ie==="between"?$e:Ee($e)}case"in":case"notIn":{const ye=h(se.value,ce,he),Ae=pe=>ye.has(c(pe,ce));return ie==="in"?Ae:Ee(Ae)}case"contains":case"notContains":{const ye=m(f(se.value,he),ce),Ae=pe=>pe==null?!1:m(pe,ce).includes(ye);return ie==="contains"?Ae:Ee(Ae)}case"startsWith":{const ye=m(f(se.value,he),ce);return Ae=>Ae==null?!1:m(Ae,ce).startsWith(ye)}case"endsWith":{const ye=m(f(se.value,he),ce);return Ae=>Ae==null?!1:m(Ae,ce).endsWith(ye)}case"matches":{const ye=p(se.value,ce);return ye?Ae=>Ae==null?!1:ye.test(String(Ae)):()=>!1}case"blank":return ye=>F(ye)||Array.isArray(ye)&&ye.length===0;case"notBlank":return ye=>!(F(ye)||Array.isArray(ye)&&ye.length===0);case"containsAny":case"containsNone":{const ye=h(se.value,ce,he),Ae=pe=>{const we=pe==null?[]:B(pe);for(let be=0;be<we.length;be++)if(ye.has(c(we[be],ce)))return!0;return!1};return ie==="containsAny"?Ae:Ee(Ae)}case"containsAll":{const ye=B(se.value).map(Ae=>c(f(Ae,he),ce));return Ae=>{const pe=Ae==null?[]:B(Ae);if(ye.length===0)return!0;const we=new Set(pe.map(be=>c(be,ce)));for(let be=0;be<ye.length;be++)if(!we.has(ye[be]))return!1;return!0}}default:{const ye=ae(ie);return ye?ye.compile(se.value):($(`op:${String(ie)}`,`unknown filter operator "${String(ie)}"; the condition is refused rather than matching every row`),()=>!1)}}}function E(se,ee,ie){return b(ee,ie)(se)}const T=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),L=new Set(["containsAny","containsAll","containsNone"]);function P(se,ee,ie){const ce=se&&se.op,he=T[ce]||ce,ge=b({...se,op:he,type:ee.type},ie),Ee=ee.items,ye=Ae=>{const pe=Ee(Ae);if(!pe)return!1;for(let we=0;we<pe.length;we++)if(ge(pe[we]))return!0;return!1};return T[ce]?Ae=>!ye(Ae):ye}function D(se,ee,ie,ce){const he=v(se);if(he){const ye=ee?1:0;for(let Ae=0;Ae<ce;Ae++)ie[Ae]=he(Ae)===ye?1:0;return ie}const ge=se.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return r(ie,ce,ee?1:0);const Ee=l(se);for(let ye=0;ye<ce;ye++){const Ae=Ee(ye),pe=F(Ae)||Array.isArray(Ae)&&Ae.length===0;ie[ye]=pe===ee?0:1}return ie}function I(se,ee,ie,ce){const he=se.dict,ge=z(he),Ee=new Uint8Array(ge);for(let we=0;we<ge;we++)Ee[we]=ee(w(he,we))?1:0;const ye=se.values,Ae=v(se);if(!Ae){for(let we=0;we<ce;we++)ie[we]=Ee[ye[we]];return ie}const pe=ee(null)?1:0;for(let we=0;we<ce;we++)ie[we]=Ae(we)===1?Ee[ye[we]]:pe;return ie}function C(se,ee,ie,ce){const he=U(se.values),ge=ee(!0)?1:0,Ee=ee(!1)?1:0,ye=v(se);if(!ye){for(let pe=0;pe<ce;pe++)ie[pe]=he(pe)===1?ge:Ee;return ie}const Ae=ee(null)?1:0;for(let pe=0;pe<ce;pe++)ie[pe]=ye(pe)===0?Ae:he(pe)===1?ge:Ee;return ie}function O(se,ee,ie,ce,he){const ge=se.values,Ee=ee.type,ye=ee.op;let Ae=!0;switch(ye){case"eq":case"ne":{const we=o(f(ee.value,Ee)),be=typeof ee.value=="number"&&Number.isNaN(ee.value),Ne=ye==="ne"?1:0;if(be)for(let $e=0;$e<he;$e++)ce[$e]=(Number.isNaN(ge[$e])?1:0)^Ne;else for(let $e=0;$e<he;$e++)ce[$e]=(ge[$e]===we?1:0)^Ne;break}case"lt":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)ce[be]=ge[be]<we?1:0;break}case"lte":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)ce[be]=ge[be]<=we?1:0;break}case"gt":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)ce[be]=ge[be]>we?1:0;break}case"gte":{const we=o(f(ee.value,Ee));for(let be=0;be<he;be++)ce[be]=ge[be]>=we?1:0;break}case"between":case"notBetween":{const we=B(ee.value),be=o(f(we[0],Ee)),Ne=o(f(we[1],Ee)),$e=ee.bounds||"[]",Ve=$e.charAt(0)!=="(",Ye=$e.charAt(1)!==")",je=ye==="notBetween"?1:0;if(Ve&&Ye)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(ge[Ge]>=be&ge[Ge]<=Ne?1:0)^je;else if(Ve)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(ge[Ge]>=be&ge[Ge]<Ne?1:0)^je;else if(Ye)for(let Ge=0;Ge<he;Ge++)ce[Ge]=(ge[Ge]>be&ge[Ge]<=Ne?1:0)^je;else for(let Ge=0;Ge<he;Ge++)ce[Ge]=(ge[Ge]>be&ge[Ge]<Ne?1:0)^je;break}case"in":case"notIn":{const we=new Set;for(const Ne of B(ee.value)){const $e=o(f(Ne,Ee));Number.isNaN($e)||we.add($e)}const be=ye==="notIn"?1:0;for(let Ne=0;Ne<he;Ne++)ce[Ne]=(we.has(ge[Ne])?1:0)^be;break}default:Ae=!1;break}if(!Ae)return!1;const pe=v(se);if(pe){const we=ie(null)?1:0;for(let be=0;be<he;be++)pe(be)===0&&(ce[be]=we)}return!0}function N(se,ee,ie,ce){const he=l(se);for(let ge=0;ge<ce;ge++)ie[ge]=ee(he(ge))?1:0;return ie}function G(se,ee,ie){const ce=ee.count|0,he=ie||n(ee,ce);if(!se)return r(he,ce,1);const ge=typeof ee.handle=="function"?ee.handle(se.col):void 0,Ee=typeof ee.custom=="function"?ee.custom:null;if(!ge){if(Ee){for(let we=0;we<ce;we++)he[we]=Ee(se,we)?1:0;return he}return $(`filter:col:${String(se.col)}`,`filter references unknown column "${String(se.col)}"; the condition is refused rather than matching every row`),r(he,ce,0)}const ye=se.op;if(ye==="blank"||ye==="notBlank")return D(ge,ye==="notBlank",he,ce);const Ae=typeof ee.itemwise=="function"?ee.itemwise(se.col):null;if(Ae&&!ae(ye)&&!L.has(ye))return N(ge,P(se,Ae,ee.locale),he,ce);const pe=b(se,ee.locale);switch(ge.kind){case"dictionary":return I(ge,pe,he,ce);case"bitset":return C(ge,pe,he,ce);case"float64":case"int32":return O(ge,se,pe,he,ce)?he:N(ge,pe,he,ce);default:return N(ge,pe,he,ce)}}function q(se,ee,ie){if(!se)return r(n(ee,ie),ie,1);if(Array.isArray(se.conditions)){const ce=se.conditions.filter(Ee=>Ee!=null),he=se.op==="or"?"or":se.op==="not"?"not":"and";if(ce.length===0)return r(n(ee,ie),ie,1);const ge=q(ce[0],ee,ie);for(let Ee=1;Ee<ce.length;Ee++){const ye=q(ce[Ee],ee,ie);if(he==="or")for(let Ae=0;Ae<ie;Ae++)ge[Ae]|=ye[Ae];else for(let Ae=0;Ae<ie;Ae++)ge[Ae]&=ye[Ae];t(ee,ye)}if(he==="not")for(let Ee=0;Ee<ie;Ee++)ge[Ee]^=1;return ge}return G(se,ee,n(ee,ie))}function Z(se,ee){return q(se,ee,ee.count|0)}function J(se,ee){if(!se||!ee)return se||null;const ie=se;if(Array.isArray(ie.conditions)){if((ie.op==="or"?"or":ie.op==="not"?"not":"and")!=="and")return te(ie,ee)?null:se;const he=[];for(const ge of ie.conditions){const Ee=J(ge,ee);Ee&&he.push(Ee)}return he.length?{...ie,op:"and",conditions:he}:null}return ie.col===ee?null:se}function te(se,ee){if(!se||typeof se!="object")return!1;const ie=se;if(ie.col===ee)return!0;if(Array.isArray(ie.conditions)){for(const ce of ie.conditions)if(te(ce,ee))return!0}return!1}function ne(se,ee,ie){if(ie&&ie.length>=ee){let Ee=0;for(let ye=0;ye<ee;ye++)se[ye]&&(ie[Ee++]=ye);return ie.subarray(0,Ee)}let ce=0;for(let Ee=0;Ee<ee;Ee++)ce+=se[Ee]?1:0;const he=new Uint32Array(ce);let ge=0;for(let Ee=0;Ee<ee;Ee++)se[Ee]&&(he[ge++]=Ee);return he}const oe=new Map;function le(se){if(!(!se||typeof se!="object"))for(const[ee,ie]of Object.entries(se))ie&&typeof ie.compile=="function"&&oe.set(ee,ie)}function ae(se){return typeof se=="string"?oe.get(se):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 x}}),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"),F=Q.collator,B=Q.defaultCompare,$=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,H=Q.titleCase,U=K("packages/core/src/format/date.js"),z=U.toDate,w=U.toIsoDate,v=U.compareIso,l=K("packages/core/src/format/boolean.js").toTriState,a=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=K("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,f=K("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function o(P){return P.getHours()===0&&P.getMinutes()===0&&P.getSeconds()===0&&P.getMilliseconds()===0}const m=new Map;function c(P){const D=P||"",I=m.get(D);if(I)return I;const C={group:",",decimal:"."};try{for(const O of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))O.type==="group"?C.group=O.value:O.type==="decimal"&&(C.decimal=O.value)}catch{}return m.set(D,C),C}const h=/\d\s*[*/^]\s*[\d.(]/;function s(P,D){if($(P))return null;let I=String(P).trim();if(I===""||I.startsWith("=")||h.test(I))return null;let C=1;I.startsWith("(")&&I.endsWith(")")&&(C=-1,I=I.slice(1,-1));const O=I.endsWith("%"),{group:N,decimal:G}=c(D);if(I=I.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(I=I.split(N).join("")),I=I.replace(/[^0-9eE+\-.,]/g,""),G===","?I=I.split(".").join("").replace(",","."):I=I.split(",").join(""),I===""||I==="-"||I==="+")return null;const q=Number(I);return Number.isNaN(q)?null:C*(O?q/100:q)}function p(P,D){const I=$(P)||Number.isNaN(P)?null:Number(P),C=$(D)||Number.isNaN(D)?null:Number(D);return I===null?C===null?0:1:C===null||I<C?-1:I>C?1:0}function b(P,D){const I=l(P),C=l(D);return I===null?C===null?0:1:C===null?-1:I===C?0:I?1:-1}function A(P,D){const I=z(P),C=z(D);if(!I)return C?1:0;if(!C)return-1;const O=I.getTime(),N=C.getTime();return O<N?-1:O>N?1:0}const k=new Map;function y(P){const D=z(P.value);if(!D)return"";const I=P.locale||"";let C=k.get(I);return C||(C=new Intl.DateTimeFormat(P.locale||void 0,{dateStyle:"medium"}),k.set(I,C)),C.format(D)}const S={boolean:{base:"boolean",storage:"bitset",matches:P=>typeof P=="boolean",parse:P=>l(P.text),compare:b,format:P=>l(P.value)===null?"":l(P.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:P=>l(P)===null?"":String(l(P)),fromClipboard:P=>l(P)},number:{base:"number",storage:"float64",matches:P=>typeof P=="number"&&!Number.isNaN(P),parse:P=>{if(r(P.text)){const D=t(P.text,P);if(!D.ok)return null;const I=Number(D.value);return Number.isFinite(I)?I:null}return s(P.text,P.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:P=>$(P)?"":String(P),fromClipboard:(P,D)=>s(P,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&u.test(P)&&!Number.isNaN(Date.parse(P))||P instanceof Date&&!Number.isNaN(P.getTime())&&o(P),parse:P=>w(P.text),compare:v,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>w(P),toClipboard:P=>$(P)?"":String(P),fromClipboard:P=>w(P)},dateString:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&u.test(P)&&!Number.isNaN(Date.parse(P)),parse:P=>w(P.text),compare:v,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>w(P),toClipboard:P=>$(P)?"":String(P),fromClipboard:P=>w(P)},text:{base:"text",storage:"dictionary",matches:P=>typeof P=="string",parse:P=>P.text===""?null:String(P.text),compare:(P,D)=>$(P)?$(D)?0:1:$(D)?-1:F().compare(String(P),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:P=>$(P)?"":String(P),fromClipboard:P=>P},image:{base:"text",storage:"dictionary",parse:P=>P.text===""||P.text==null?null:String(P.text).trim(),compare:(P,D)=>$(P)?$(D)?0:1:$(D)?-1:F().compare(String(P),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:P=>$(P)?"":String(P),fromClipboard:P=>P},lookup:{base:"text",storage:"dictionary",parse:P=>{if(P.text===""||P.text==null)return null;const D=P.column&&P.column.lookup,I=D&&X(D.options)?D.options():null;if(!I)return P.text;const C=String(P.text),O=I.find(q=>String(q.id)===C);if(O)return O.id;const N=C.trim().toLowerCase(),G=I.find(q=>String(q.label).toLowerCase()===N);return G?G.id:P.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:P=>$(P)?"":String(P),fromClipboard:P=>P},object:{base:"object",storage:"object",matches:P=>P!==null&&typeof P=="object"&&!(P instanceof Date),parse:P=>{try{return P.text===""?null:JSON.parse(P.text)}catch{return P.text}},compare:(P,D)=>B(P,D),format:P=>{const D=P.value;if($(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:P=>$(P)?"":typeof P=="string"?P:JSON.stringify(P),fromClipboard:P=>P}},R=["boolean","number","date","dateString","datetime","text","object"];function j(P,D,I,C){const O=I.get(P);if(O)return O;C.includes(P)&&W(`circular data type extends chain: ${[...C,P].join(" → ")}`);const N=D[P];N||W(`unknown data type "${P}"`);let G=null;N.extends&&(G=j(N.extends,D,I,[...C,P]));const q={...G||{},...N,name:P,defaults:{...G&&G.defaults||{},...N.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),I.set(P,q),q}function x(P,D){const I={...S,...a};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const O of D.names("dataType")){const N=D.dataType(O);N&&(I[O]=N)}if(_(P))for(const[O,N]of Object.entries(P))I[O]=N;const C=new Map;for(const O of R)j(O,I,C,[]);j("lookup",I,C,[]);for(const O of Object.keys(I))j(O,I,C,[]);for(const O of C.values())f(O.operators);return C}function E(P,D){if(P.base==="text"&&(!P.compare||P.compare===S.text.compare)){const I=F(D);return(C,O)=>$(C)?$(O)?0:1:$(O)?-1:I.compare(String(C),String(O))}return P.compare||B}function T(P,D){return D?P.multiStorage||"multi":P.storage||"object"}function L(P){return H(String(P).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 $}}),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"),F=Q.infoOnce,B=Q.isNil,$=100;function _(W,H,U={}){const z=U.sampleSize??$,w=[];for(let v=0;v<W.length&&w.length<z;v++){const g=W[v];B(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[v,g]of H){if(typeof g.matches!="function")continue;let l=!0;for(let d=0;d<w.length;d++)if(!g.matches(w[d])){l=!1;break}if(l)return{type:v,unanimous:!0,sampled:w.length}}return U.quiet||F(`infer:${U.colId||"?"}`,`column "${U.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,H,U,z,w={}){const v=w.sampleSize??$,g=[];for(let l=0;l<H.length&&g.length<v;l++){const d=U(H[l]);B(d)||typeof d=="number"&&Number.isNaN(d)||g.push(d)}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 H}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const Q=K("packages/core/src/internal/util.js"),F=Q.DEV,B=Q.fail,$=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const v=w.value||{};if(!$(v.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const l=v.pure!==!1;return v.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:l}:Array.isArray(v.deps)?{computed:!0,wholeRow:!1,deps:v.deps.slice(),pure:l}:(_(`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:l})}function H(w){const v=new Map;for(const m of w)v.set(m.id,m);const g=new Map,l=new Map,d=new Set,a=new Set,n=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?n:t).add(m.id),c.wholeRow&&d.add(m.id);const h=[],s=[];for(const p of c.deps)(v.has(p)?h:s).push(p);g.set(m.id,h),s.length&&l.set(m.id,s)}for(const m of n)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 r=[],i=new Map,f=[],u=m=>{const c=i.get(m);if(c!=="done"){if(c==="open"){const h=f.indexOf(m);B(`circular column dependency: ${[...f.slice(h),m].join(" → ")}`)}i.set(m,"open"),f.push(m);for(const h of g.get(m)||[])v.has(h)&&u(h);f.pop(),i.set(m,"done"),r.push(m)}};for(const m of w)u(m.id);const o=new Map;for(const m of w)o.set(m.id,[]);for(const m of w)for(const c of g.get(m.id)||[]){const h=o.get(c);h&&!h.includes(m.id)&&h.push(m.id)}if(d.size)for(const m of w){if(a.has(m.id))continue;const c=o.get(m.id);for(const h of d)c.includes(h)||c.push(h)}return{order:r,dependents:o,pure:n,impure:t,computed:a,deps:g,wholeRow:d,external:l,index:v}}function U(w,v){const g=Array.isArray(v)?v:[v],l=new Set,d=[...g];for(;d.length;){const a=d.shift();for(const n of w.dependents.get(a)||[])l.has(n)||(l.add(n),d.push(n))}for(const a of g)l.delete(a);return w.order.filter(a=>l.has(a))}function z(w,v,g){if(!F)return w;const l=v instanceof Set?v:new Set(v);return new Proxy(w,{get(d,a){return typeof a=="string"&&!l.has(a)&&!Object.hasOwn(d,a)&&_(`undeclared:${g}:${a}`,`computed column "${g}" read undeclared dependency "${a}". Add it to \`value.deps\` or the value will go stale.`),d[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 U}}),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 l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return d}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.pathGetter,$=Q.isFunction,_=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],W="";function H(a){if(a===null)return"\0n";if(a===void 0)return"\0u";const n=typeof a;if(n==="string")return a;if(n==="number"||n==="bigint"||n==="boolean")return String(a);if(a instanceof Date)return`\0d${a.getTime()}`;try{return`\0o${JSON.stringify(a)}`}catch{return"\0o?"}}function U(a){if(a.length===1)return H(a[0]);let n="";for(let t=0;t<a.length;t++)t&&(n+=W),n+=H(a[t]);return n}function z(a,n={}){const t=n.warn!==!1;if($(a)){const r=a;return{stable:!0,fields:[],disabled:[],key(i,f){try{const u=r(i);return Array.isArray(u)?U(u):H(u)}catch(u){return F("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",u),`#${f??-1}`}},keyEmpty(i){try{const f=r(i);return Array.isArray(f)?f.length===0||f.some(_):_(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(a)&&a.length>0){const r=a.filter(u=>typeof u=="string"),i=r.map(u=>B(u)),f=i.length;return{stable:!0,fields:r,disabled:[],key(u){const o=new Array(f);for(let m=0;m<f;m++)o[m]=i[m](u);return U(o)},keyEmpty(u){for(let o=0;o<f;o++)if(_(i[o](u)))return!0;return!1},missingFields(u){const o=[];for(let m=0;m<f;m++)_(i[m](u))&&o.push(r[m]);return o}}}if(typeof a=="string"&&a.length>0){const r=B(a);return{stable:!0,fields:[a],disabled:[],key(i){return H(r(i))},keyEmpty(i){return _(r(i))},missingFields(i){return _(r(i))?[a]:[]}}}return t&&F("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(r,i){if(r===null||typeof r!="object")return`#${i??0}:${String(r)}`;let f=w.get(r);return f===void 0&&(f=`#${v++}`,w.set(r,f)),f}}}const w=new WeakMap;let v=0;function g(a,n){if(!a||a.stable===!1||!$(a.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,i;for(let m=0;m<n.length;m++){const c=n[m];a.keyEmpty(c)&&(t++,r===null&&(r=$(a.missingFields)?a.missingFields(c):[],i=c))}if(t===0)return;const f=a.fields.length?a.fields.join(","):"(function)",u=r&&r.length?r.join(", "):a.fields.length?a.fields.join(", "):"the rowKey function",o=i!==null&&typeof i=="object"?Object.keys(i).join(", ")||"(no fields)":String(i);F(`rowKey.emptyValue:${f}`,`rowKey ${u} is missing on ${t} of ${n.length} rows; the first such row has: ${o}. 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 l(a){return U(a)}function d(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 U}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),F=Q.collator,B=Q.defaultCompare,$=Q.isFunction,_=Q.isNil,X=Q.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,U=", ",z="";function w(n,t,r,i){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const f=n[t],u=n[r],o={id:f,label:u==null?String(f??""):String(u)};n.disabled&&(o.disabled=!0),n.variant&&(o.variant=n.variant),n.icon&&(o.icon=n.icon);const m=i?n[i]:n.group;return m!==void 0&&(o.group=m),o}function v(n,t,r=0,i=[],f=[]){for(const u of n||[]){const o=u&&typeof u=="object"?u[t]:null;if(f.push({raw:u,depth:r,path:i}),Array.isArray(o)&&o.length){const m=String(u&&typeof u=="object"?u.label??u.name??u.id??"":u);v(o,t,r+1,[...i,m],f)}}return f}function g(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&$(n.router&&n.router.subscribe)}class l{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#f=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=F(this.#n),Array.isArray(this.#e.options)?this.#h(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??U}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=F(t)}#h(t){const r=this.#e,i=r.valueKey||"id",f=r.labelKey||"label",u=r.childrenKey||"children";this.#o=v(t,u).map(o=>{const m=w(o.raw,i,f,r.groupKey);return o.depth&&(m.depth=o.depth,m.path=o.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((o,m)=>{this.#i.set(o.id,o),this.#s.set(o.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(!$(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 r;try{r=t()}catch(i){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,i),this.#u=Promise.resolve([]),this.#u}return!r||!$(r.then)?(this.#h(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(i=>(this.#h(i),this.#r&&this.#r(this),this.#o),i=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,i),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#h(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 r=this.#e,i=r.valueKey||"id",f=r.labelKey||"label",u=r.groupKey,o=$(t.map)?t.map:null,m=h=>w(o?o(h):h,i,f,u).id,c=h=>this.#m(h,o,i,f,u);return t.router.subscribe(t.predicate,c,{rowKey:m}),this.#d=()=>{$(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,i,f,u){const o=t&&t.add||[],m=t&&t.update||[],c=t&&t.remove||[];if(!(!o.length&&!m.length&&!c.length)){for(const h of o)this.#g(h,r,i,f,u);for(const h of m)this.#g(h,r,i,f,u);for(const h of c){if(!this.#f.has(h))continue;const s=this.#f.get(h);this.#f.delete(h),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((h,s)=>[h.id,s])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,i,f,u){const o=w(r?r(t):t,i,f,u);this.#f.set(H([o.id]),o.id);const m=this.#o.findIndex(c=>c.id===o.id);m>=0?this.#o[m]=o:this.#o.push(o),this.#i.set(o.id,o)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const i=this.#e;if(!$(i.search)){const o=String(t||"").toLowerCase();return Promise.resolve(o===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(o)))}const f=i.valueKey||"id",u=i.labelKey||"label";return Promise.resolve(i.search(t,r)).then(o=>(o||[]).map(m=>w(m,f,u,i.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.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 i=this.#e.unknownLabel;return $(i)?String(i(t)??""):typeof i=="string"?i:String(t)}text(t){if(this.multiple){const r=d(t);return r.length===0?"":r.map(i=>this.label(i)).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((i,f)=>B(i.id,f.id));const r=this.#c;return this.#o.slice().sort((i,f)=>r.compare(i.label,f.label))}comparator(){const t=this.sortBy,r=this.multiple,i=this.#c,f=this.#s;if(r&&t==="count")return(o,m)=>d(o).length-d(m).length;const u=r?o=>d(o)[0]:o=>o;return t==="value"?(o,m)=>B(u(o),u(m)):t==="optionOrder"?(o,m)=>{const c=f.has(u(o))?f.get(u(o)):Number.MAX_SAFE_INTEGER,h=f.has(u(m))?f.get(u(m)):Number.MAX_SAFE_INTEGER;return c-h}:(o,m)=>{const c=u(o),h=u(m);return _(c)?_(h)?0:1:_(h)?-1:i.compare(this.label(c),this.label(h))}}groupKey(t){return this.multiple?d(t).map(i=>String(i)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?d(t).length:_(t)?0:1}contains(t,r,i){const f=this.multiple?d(t):_(t)?[]:[t],u=Array.isArray(r)?r:[r];switch(i){case"containsAll":return u.every(o=>f.includes(o));case"containsNone":return!u.some(o=>f.includes(o));default:return u.some(o=>f.includes(o))}}exportText(t,r="label"){return r==="value"?this.multiple?d(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:i=>t?d(i).includes(r.id):i===r.id}))}}function d(n){return Array.isArray(n)?n:_(n)||n===""?[]:[n]}function a(n,t={}){const r=n.lookup;if(!r)return null;const i=new l(r,{colId:n.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&i.load(),i}}),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 v}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),F=Q.getPath,B=Q.isFunction,$=Q.isNil,_=Q.Lru,X=Q.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,U="\0";function z(n,t={}){const r=t.locale,i=t.grid??null,f=t.context,u=n.value&&n.value.format,o=n.formatter||null,m=n.dataType&&n.dataType.format,c=n.lookup||null,h=(s,p,b)=>({value:s,data:b,row:p,column:n,colId:n.id,grid:i,context:f,locale:r});if(B(u))return(s,p,b)=>{const A=u(h(s,p,b));return A==null?"":String(A)};if(o){if(c){const s=o.kind==="text";return(p,b,A)=>o(s?c.text(p):p,h(p,b,A))}return(s,p,b)=>o(s,h(s,p,b))}return B(m)?(s,p,b)=>{const A=m(h(s,p,b));return A==null?"":String(A)}:c?s=>c.text(s):s=>$(s)?"":typeof s=="string"?s:String(s)}function w(n,t){!n||!n.value||n.value.pure!==!1||X(`impure:${t}:${n.id}`,`column "${n.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class v{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(r=>[r.id,r])),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 r=t&&t.rows?new Set([...t.rows].map(String)):null,i=t&&t.columns?[...t.columns]:null;if(!r&&!i){this.#s.clear();return}const f=i?this.#l(i):null;for(const u of[...this.#s.keys()]){const o=String(u).split(U);o.length===3&&(r&&!r.has(o[0])||f&&!f.has(o[2])||this.#s.delete(u))}}#l(t){const r=new Set,i=this.#t,f=[...t];for(;f.length;){const u=f.pop();if(!r.has(u)){r.add(u);for(const o of i?i.dependents.get(u)||[]:[])f.push(o)}}return r}value(t,r,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,r,i);if(f.value.pure!==!1&&this.#i&&i&&i.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,i.physical);if(f.volatile)return this.compute(f,r,i);if(f.value.pure===!1)return this.compute(f,r,i);const u=`${this.#a(r,i)}${U}${f.id}`;if(this.#s.has(u))return this.#s.get(u);const o=this.compute(f,r,i);return this.#s.set(u,o),o}#a(t,r){return`${this.#o(t,r)}${U}${l(t)}`}#u(t,r,i){if(this.#i&&i&&i.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,i.physical);if(t.field)return t.read?t.read(r):F(r,t.field)}compute(t,r,i){const f=this.#t,u=f&&f.wholeRow.has(t.id);let o;if(u)o=r??{};else{o={};const c=f&&f.deps.get(t.id)||[];for(const s of c)o[s]=this.value(s,r,i);const h=f&&f.external.get(t.id)||[];for(const s of h)o[s]=F(r,s);o=H(o,[...c,...h],t.id)}const m={data:r,row:i,column:t,grid:this.#n,context:this.#r};return t.value.compute(o,m)}values(t,r){const i={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const u of f)i[u]=this.value(u,t,r);return i}text(t,r,i){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,r,i),i,r):""}key(t,r,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const u=this.value(f,r,i);return B(f.value.key)?String(f.value.key(this.#c(f,u,r,i))):f.lookup?f.lookup.groupKey(u):$(u)?"":String(u)}quickFilterText(t,r,i){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const u=this.value(f,r,i);return String(f.value.quickFilterText(this.#c(f,u,r,i))??"")}return this.text(f,r,i)}#c(t,r,i,f){return{value:r,data:i,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,i,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return r;const o={text:r,value:this.value(u,i,f),data:i,row:f,column:u,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(u.value.parse)?u.value.parse(o):u.dataType&&B(u.dataType.parse)?u.dataType.parse(o):r}validate(t,r,i,f,u){const o=typeof t=="string"?this.#e.get(t):t;if(!o||!B(o.edit.validate))return!0;const m=o.edit.validate({value:r,oldValue:i,data:f,row:u,column:o,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,r,i,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return!1;const o=this.value(u,i,f);if(B(u.value.apply)){const m=u.value.apply({value:r,oldValue:o,data:i,row:f,column:u,grid:this.#n,context:this.#r});return this.#d(u,i,f),m!==!1}return u.field?o===r?!1:(u.write(i,r),this.#d(u,i,f),!0):(X(`apply:${u.id}`,`column "${u.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,r,i,f){const u=typeof t=="string"?this.#e.get(t):t;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const o=this.value(u,i,f),m=this.parse(u,r,i,f),c=this.validate(u,m,o,i,f);if(c!==!0)return{ok:!1,value:m,oldValue:o,changed:!1,error:c};const h=this.apply(u,m,i,f);return{ok:!0,value:m,oldValue:o,changed:h}}#d(t,r,i){if(this.#s.size===0)return;const f=this.#a(r,i);this.#s.delete(`${f}${U}${t.id}`);for(const u of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${U}${u}`)}}function g(n,t){return t&&t.key!=null?String(t.key):l(n)}function l(n){if(n&&typeof n=="object"){let t=d.get(n);return t===void 0&&(t=`#${a++}`,d.set(n,t)),t}return String(n)}const d=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 $}}),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 H}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return U}}),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 v}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return d}}),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 o}});const F=K("packages/core/src/internal/util.js").warnOnce,B=2e5,$=20,_=1e3,X=50;function W(m){return Math.min(_,Math.max(X,Math.floor(m)))}const H=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"]),U=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,v=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),l=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=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 h=Number.isFinite(Number(c.lower))?Number(c.lower):null,s=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(h===null&&s===null||!Number.isFinite(m))return null;if(h!==null&&m<h||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 n(m,c,h){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&F(`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 F(`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(h)||$);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;#f=new Map;#h=null;#p=null;#m=null;constructor(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||$),this.#u=Math.max(1,c.max||B),this.#c=c.now||(()=>Date.now()),this.#d=n(this.#e,c.historyWindow,this.#a),this.#d&&(this.#h=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,h){const s=u(h);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.#f.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.#f.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,h]of this.#n)this.#t.set(c,h);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#f.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}retain(c){const h=c instanceof Set?c:new Set(c);let s=0;for(const p of[...this.#n.keys()])h.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#f.delete(p),this.#s.delete(p),s++);return s&&(this.#p=null,this.#m=null),s}advanceHistoryWindow(c=this.#c()){const h=this.#d;if(!h)return 0;const s=Math.floor(c/h.bucketMs),p=s-this.#h;if(!(p>0))return 0;const b=Math.min(p,this.#a);for(const[A,k]of this.#f){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.#h=s,p}read(c,h,s,p){switch(c){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const b=this.#o.get(h);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(h);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(h)?this.#t.get(h):null;case"delta":return this.#n.has(h)?this.#n.get(h)-this.#t.get(h):null;case"deltaPercent":{if(!this.#n.has(h))return null;const b=this.#t.get(h);return b?(this.#n.get(h)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(h),A=this.#o.get(h);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.#f.has(h)?[...this.#f.get(h)]:null:this.#i.has(h)?[...this.#i.get(h)]:null;case"streak":return this.#s.has(h)?this.#s.get(h):0;case"specStatus":return this.#n.has(h)?a(this.#n.get(h),p):null;default:return l.includes(c)?this.#O(c,h,s,p):null}}#b(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const h=this.#w(c);return this.#m={only:c,view:h},h}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(c){const h=[];for(const[x,E]of this.#n)c&&!c.has(x)||h.push(E);const s=h.sort((x,E)=>x-E);let p=0,b=0,A=0,k=0;for(const x of s){k+=x,p++;const E=x-b;b+=E/p,A+=E*(x-b)}const y=[];for(const[x,E]of this.#t)c&&!c.has(x)||y.push(E);const S=p?r(s):0,R=s.map(x=>Math.abs(x-S)).sort((x,E)=>x-E),j=p?r(R):0;return{sorted:s,baseline:y.sort((x,E)=>x-E),sum:k,mean:p?b:0,sd:p>1?Math.sqrt(A/(p-1)):0,median:S,mad:j}}#O(c,h,s,p){if(!this.#n.has(h)||s&&!s.has(h))return null;const b=this.#n.get(h),A=this.#b(s),k=A.sorted.length;if(!k)return null;switch(c){case"rank":return k-f(A.sorted,b)+1;case"rankAsc":return i(A.sorted,b)+1;case"rankChange":{if(!this.#t.has(h)||!A.baseline.length)return null;const y=A.baseline.length-f(A.baseline,this.#t.get(h))+1,S=k-f(A.sorted,b)+1;return y-S}case"percentile":return f(A.sorted,b)/k*100;case"quartile":{const y=f(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):v;return Math.abs(w*(b-A.median)/A.mad)>y}case"shareOfTotal":return A.sum?b/A.sum*100:null;default:return null}}}function r(m){const c=m.length;if(!c)return 0;const h=(c-1)*.5,s=Math.floor(h),p=Math.ceil(h);return s===p?m[s]:m[s]+(h-s)*(m[p]-m[s])}function i(m,c){let h=0,s=m.length;for(;h<s;){const p=h+s>>1;m[p]<c?h=p+1:s=p}return h}function f(m,c){let h=0,s=m.length;for(;h<s;){const p=h+s>>1;m[p]<=c?h=p+1:s=p}return h}function u(m){if(m==null||m==="")return null;if(m instanceof Date){const h=m.getTime();return Number.isFinite(h)?h:null}const c=typeof m=="number"?m:Number(m);return Number.isFinite(c)?c:null}function o(m){const c=[];for(const h of m||[]){const s=h.shadow;if(!s)continue;const p=typeof s=="string"?{kind:s}:s,b=p.kind;H.includes(b)&&(U.includes(b)||z.includes(b)||c.push({colId:h.id||h.field,of:p.of||h.field||h.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 j}}),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 le}});const Q=K("packages/core/src/internal/util.js"),F=Q.expand,B=Q.fail,$=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,H=Q.merge,U=Q.pathGetter,z=Q.pathSetter,w=Q.toArray,v=Q.uid,g=Q.warnOnce,d=K("packages/core/src/format/index.js").compileFormat,a=K("packages/core/src/columns/datatypes.js"),n=a.comparatorFor,t=a.createTypeRegistry,r=a.storageKind,i=K("packages/core/src/columns/infer.js"),f=i.inferColumnType,u=i.DEFAULT_SAMPLE,o=K("packages/core/src/columns/graph.js"),m=o.buildGraph,c=o.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"}),j={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},x={centre:"center"},E=new Set(["start","center","end","left","right"]);function T(se){if(typeof se!="string")return;const ee=se.toLowerCase();return x[ee]?x[ee]:E.has(ee)?ee:void 0}function L(se){if(typeof se!="string")return;const ee=se.toLowerCase();return ee==="center"||ee==="centre"?"middle":ee==="top"||ee==="middle"||ee==="bottom"?ee:void 0}const P=["cell","layout","header"];function D(se){if(!W(se))return{};const ee={...se},ie=(ce,he)=>{if(se[ce]===void 0)return;const ge=F(se[ce],he);ge&&P.includes(ce)&&!W(se[ce])&&delete ge.enabled,ee[ce]=ge};return ie("sort","direction"),ie("filter","type"),ie("cell","render"),ie("edit","editor"),ie("layout","width"),ie("group","index"),ie("pivot","index"),ie("header","render"),ie("facet","strategy"),ee}function I(se,ee){const ie={...se||{}},ce=W(ee)&&W(ee.layout)&&ee.layout.width!==void 0;return ie.fit==="content"&&!ce&&delete ie.width,ie}const C=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"]),O=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function N(se,ee,ie,ce){const he=ie==="columnGroup"?"column group":"column";for(const ge of Object.keys(se))if(!ee.has(ge)){if(ge==="timeZone"&&ie==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${ce}". 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(`${ie}.unknown:${ge}`,`'${ge}' is not a configuration key this grid recognises, so it had no effect on ${he} "${ce}". Check the spelling against the reference.`)}}function G(se){W(se.cell)&&se.cell.autoHeight!==void 0&&g("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${se.id||se.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function q(se,ee){const ie=ee&&X(se.defaultsFor)?se.defaultsFor(ee):null,ce={...se.defaults||{},...W(ie)?ie:{}},he={};return ce.align&&(he.align=ce.align,he.cell={align:ce.align},he.header={align:ce.align}),ce.filter&&(he.filter=ce.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ce.filter}),ce.editor&&(he.edit=ce.editor==="none"?{editor:null}:{editor:ce.editor}),ce.total&&(he.total=ce.total),ce.render&&(he.cell={...he.cell||{},render:ce.render}),se.export&&(he.export={...se.export}),he}function Z(se){if(typeof se=="string")return se.trim()?[se.trim()]:[];if(!Array.isArray(se))return[];const ee=[];for(const ie of se){if(typeof ie!="string")continue;const ce=ie.trim();ce&&!ee.includes(ce)&&ee.push(ce)}return ee}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(ee,ie,ce){const he=this.#d(ee,ie,ce);if(typeof he!="string"||!this.#f)return he??null;const ge=ie&&ie.totals&&ie.totals.implement;if(ge&&X(ge[he])){const ye=ge[he];return ye.totalName=he,ye}const Ee=this.#f.totalFn?.(he);return X(Ee)?Ee:he}#d(ee,ie,ce){if(typeof ee!="string")return ee;const he=ie&&ie.totals&&ie.totals.supported;if(!Array.isArray(he)||he.includes(ee))return ee;const ge=he.length?he.join(", "):"none";return B(`column "${ce}" is typed ${ie.name||"a type"}, for which the total "${ee}" is not meaningful. Supported: ${ge}. Aggregating it anyway would produce a confident wrong number.`),ee}#f;#h;#p;#m;#g;#b;#w=!1;#O;#y;constructor(ee={}){this.#i=D(ee.columnDefaults||{}),this.#s=ee.columnPresets||{},this.#a=ee.locale,this.#l=ee.timeZone,this.#u=L(ee.verticalAlign),this.#f=ee.registry||null,this.#h=ee.grid||null,this.#p=ee.context,this.#O=ee.sampleSize??u,this.#y=ee.onChange||null,this.#b=X(ee.rowKey)?ee.rowKey:void 0,this.#o=t(ee.dataTypes,this.#f);const{leaves:ie,groups:ce}=le(ee.columns||[]);this.#n=ce;for(const he of ie){he.facet!==void 0&&this.#r.set(he.def,he.facet);const ge=this.#j(he.def,null);if(ge.groupPath=he.path,this.#e.has(ge.id)){g(`columns.duplicate:${ge.id}`,`two columns resolve to the id '${ge.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}he.column=ge,this.#e.set(ge.id,ge),this.#t.push(ge.id)}this.#E(ee.stored||null)}#j(ee,ie){N(ee,C,"column",ee.id||ee.field||"(unnamed)"),G(ee);const ce=D(ee),he=w(ee.preset),ge=he.map(je=>{const Ge=this.#s[je];return Ge?D(Ge):(g(`preset:${je}`,`unknown column preset "${je}"; ignoring`),{})}),Ee=this.#S(ce,ge,ie),ye=this.#o.get(Ee)||this.#o.get("text");if(!this.#o.has(Ee)&&ee.type){const je=R[Ee];g(`type:${Ee}`,`unknown data type "${Ee}"; falling back to "text"`+(je?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${je}'.`:""))}const Ae=X(ye.items)?this.#C(ce,ge,ee.id||ee.field||"(unnamed)"):null;let pe=j;pe=H(pe,this.#i),ee.type!==!1&&(pe=H(pe,q(ye,Ae)));for(const je of ge)pe=H(pe,je);this.#r.has(ee)&&(pe=H(pe,D({facet:this.#r.get(ee)}))),pe=H(pe,ce);const we=pe.edit;we&&we.editor&&we.enabled!==!0&&!X(we.enabled)&&(ee.edit||{}).editor&&g(`column.editor-not-enabled:${ee.id||ee.field}`,`column '${ee.id||ee.field}' names the editor '${we.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const be=ee.id||ee.field||v("col");if(ee.shadow&&!X(pe.value&&pe.value.compute)){const je=typeof ee.shadow=="string"?{kind:ee.shadow}:ee.shadow,Ge=je.of||ee.field||be,Ze=S.includes(je.kind),rt=Ze?je.model||je:null,st=Ze&&rt?[...Array.isArray(rt.predictors)?rt.predictors:[],rt.response].filter(Boolean):null;pe.value={...pe.value||{},deps:st&&st.length?st:je.orderBy&&je.orderBy!==Ge?[Ge,je.orderBy]:[Ge],pure:!1,compute:(ft,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=je.model?{...je.model,threshold:je.threshold}:je;return Ot.fitShadow(je.kind,Ct,Tt)}return Ot.shadow(Ge,je.kind,Ct,je.scope,je)}}}if(ee.running&&!X(pe.value&&pe.value.compute)){const je=typeof ee.running=="string"?{kind:ee.running}:ee.running,Ge=je.of||ee.field||be;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 ft=rt.row&&rt.row.key||st.keyOf(rt.data);return ft?st.running(Ge,je.kind||"total",ft):null}},ee.sort===void 0&&(pe.sort={...pe.sort||{},enabled:!1})}const Ne=ee.field??(X(pe.value&&pe.value.compute)?null:ee.id??null),$e=X(pe.value&&pe.value.compute),Ve={id:be,field:Ne,shadow:ee.shadow||null,running:ee.running||null,spec:ee.spec||null,validation:ee.validation||null,volatile:!!(ee.shadow||ee.running),title:pe.title??_(Ne||be),type:ye.name,dataType:ye,itemType:Ae,nullable:pe.nullable!==!1,align:T(ce.cell&&ce.cell.align||ce.align||pe.cell&&pe.cell.align||pe.align||ye.defaults&&ye.defaults.align)||"start",verticalAlign:L(ce.cell&&ce.cell.verticalAlign||ce.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,ye,ee.id||ee.field||"(unnamed)"),groupTotal:pe.groupTotal===void 0?null:this.#c(pe.groupTotal,ye,ee.id||ee.field||"(unnamed)"),grandTotal:pe.grandTotal===void 0?null:this.#c(pe.grandTotal,ye,ee.id||ee.field||"(unnamed)"),tags:Z(pe.tags),typeOptions:pe.typeOptions??null,...W(pe[Ee])?{[Ee]:pe[Ee]}:{},layout:I(pe.layout,ce),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:ee,format:pe.format,presets:he,inferred:ie!=null&&!ee.type,computed:$e,diff:ee.diff===void 0?void 0:!!ee.diff,read:Ne?U(Ne):null,write:Ne?z(Ne):null};Ve.cell.align=T(ce.cell&&ce.cell.align)||Ve.align,Ve.header.align=T(ce.header&&ce.header.align)||Ve.align;const Ye=pe.lookup||null;return Ve.lookup=Ye?s({id:be,lookup:Ye},{locale:this.#a,onChange:()=>{this.#y&&this.#y("lookup",{colId:be})}}):null,Ve.group.explode&&Ve.lookup&&Ve.lookup.multiple&&g(`explode:${be}`,`column "${be}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#k(Ve),Ve}#k(ee){ee.formatter=d(ee.format,ee.dataType,this.#a,this.#l,ee.id),ee.formatValue=b(ee,{locale:this.#a,grid:this.#h,context:this.#p}),ee.itemCompare=ee.itemType?n(ee.itemType,this.#a):null,ee.compare=X(ee.value.compare)?ee.value.compare:ee.lookup?ee.lookup.comparator():X(ee.dataType.compareFor)?ee.dataType.compareFor(ee):n(ee.dataType,this.#a),ee.excel=ee.formatter&&ee.formatter.ooxml||ee.dataType&&ee.dataType.excel||"General",ee.storeKind=r(ee.dataType,!!(ee.lookup&&ee.lookup.multiple))}#C(ee,ie,ce){let he=W(ee.typeOptions)?ee.typeOptions:null;for(let Ae=ie.length-1;!he&&Ae>=0;Ae--)W(ie[Ae].typeOptions)&&(he=ie[Ae].typeOptions);!he&&W(this.#i.typeOptions)&&(he=this.#i.typeOptions);const ge=he&&he.of!==void 0?he.of:"text",Ee=typeof ge=="string"?this.#o.get(ge):void 0;return Ee&&!X(Ee.items)&&Ee.storage!=="object"?Ee:(g(`type:of:${String(ge)}`,`column "${ce}" names "${String(ge)}" as its item type (typeOptions.of), which is not ${Ee?"a scalar data type":"a known data type"}; its items are read as text.`),this.#o.get("text"))}#S(ee,ie,ce){if(ee.type===!1)return"text";if(ee.type)return ee.type;for(let he=ie.length-1;he>=0;he--)if(ie[he].type)return ie[he].type;if(this.#i.type)return this.#i.type;if(ee.shadow){const he=typeof ee.shadow=="string"?ee.shadow:ee.shadow.kind;if(he==="fitInfluence")return"boolean";if(he==="fitPredicted"||he==="fitResidual"||he==="fitStdResidual"||he==="fitLeverage"||he==="fitCooksD"||he==="tsTrend"||he==="tsSeasonal"||he==="tsResidual"||he==="tsCoverage"||he==="tsSmoothed"||he==="tsSmoothingAlpha"||he==="tsSmoothingBeta")return"number"}return ce||(ee.lookup?"lookup":"text")}#E(ee){const ie=this.all();this.#m=m(ie),this.#g?this.#g.setGraph(this.#m):this.#g=new A({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:ee||null,rowKey:this.#b});const ce=this.#g;for(const he of ie)he.getValue=(ge,Ee)=>ce.value(he,ge,Ee)}all(){return this.#t.map(ee=>this.#e.get(ee))}visible(){return this.all().filter(ee=>!ee.layout.hidden)}get(ee){return this.#e.get(ee)}groups(){const ee=ie=>{const ce=[];for(const he of ie)Array.isArray(he.columns)?ce.push({...he,columns:ee(he.columns)}):he.column&&ce.push(he.column);return ce};return ee(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(ee){return c(this.#m,ee)}value(ee,ie,ce){return this.#g.value(ee,ie,ce)}text(ee,ie,ce){return this.#g.text(ee,ie,ce)}checkImpure(ee,ie){k(this.#e.get(ee),ie)}setLocale(ee){this.#a=ee;for(const ie of this.all())ie.lookup&&ie.lookup.setLocale(ee),this.#k(ie);this.#y&&this.#y("locale",{locale:ee})}infer(ee){const ie={};if(this.#w||!Array.isArray(ee)||ee.length===0)return ie;this.#w=!0;let ce=!1;for(const he of this.all()){const ge=he.def;if(ge.type!==void 0||!he.field||he.computed||he.lookup||this.#T(he))continue;const Ee=he.read||(pe=>$(pe,he.field)),ye=f(he.id,ee,Ee,this.#o,{sampleSize:this.#O});if(ye===he.type)continue;ie[he.id]=ye;const Ae=this.#j(ge,ye);Ae.groupPath=he.groupPath,Ae.layout={...Ae.layout,...te(he.layout)},this.#e.set(he.id,Ae),ae(this.#n,he.id,Ae),ce=!0}return ce&&this.#E(null),ie}redecorate(ee,ie,ce={}){const he=this.#e.get(ee);if(!he){g(`redecorate:${ee}`,`columns.decorate('${ee}', …): no column with id '${ee}'.`);return}const ge=he.def||{},Ee={...W(ge.cell)?ge.cell:{}};Ee.decoration=ie??void 0,ce&&"variant"in ce&&(Ee.variant=ce.variant);const ye={...ge,cell:Ee};this.#r.has(ge)&&this.#r.set(ye,this.#r.get(ge));const Ae=this.#j(ye,he.type);return Ae.groupPath=he.groupPath,Ae.layout={...Ae.layout,...te(he.layout)},he.lookup&&he.lookup!==Ae.lookup&&X(he.lookup.destroy)&&he.lookup.destroy(),this.#e.set(ee,Ae),ae(this.#n,ee,Ae),this.#E(null),this.#y&&this.#y("decorate",{colId:ee}),Ae}destroy(){for(const ee of this.#e.values())ee.lookup&&X(ee.lookup.destroy)&&ee.lookup.destroy()}#T(ee){for(const ie of ee.presets){const ce=this.#s[ie];if(ce&&ce.type)return!0}return!!this.#i.type}#P(ee){return!ee.computed&&X(ee.dataType&&ee.dataType.toStorage)}storeReader(ee){if(ee.computed)return ie=>this.#g.value(ee,ie,null);if(this.#P(ee)){const ie=ee.dataType.toStorage,ce={timeZone:this.#l,colId:ee.id,itemType:ee.itemType||null};return he=>ie(ee.read(he),ce)}return ee.read}storeValue(ee,ie){if(!(!ee||ee.computed)&&X(ee.read))return this.storeReader(ee)(ie)}storeSchema(){const ee=[];for(const ie of this.all()){if(ie.computed&&ie.value.pure===!1||!ie.computed&&!ie.field)continue;const ce=this.storeReader(ie);let he=null;!ie.computed&&!this.#P(ie)&&typeof ie.field=="string"&&!ie.lookup&&(he=ie.field);const ge={id:ie.id,kind:ie.storeKind,nullable:ie.nullable,read:ce};he!==null&&(ge.field=he),ie.lookup&&(ge.dictionary=ie.lookup.dictionary()),ee.push(ge)}return ee}state(){return this.all().map(ee=>({id:ee.id,width:ee.layout.width,flex:ee.layout.flex||void 0,hidden:!!ee.layout.hidden,pin:ee.layout.pin??null,sort:ee.sort.direction??null,sortIndex:ee.sort.direction?ee.sort.order??0:null,groupIndex:ee.group.enabled?ee.group.index??0:null,pivotIndex:ee.pivot.enabled?ee.pivot.index??0:null,total:typeof ee.total=="string"?ee.total:null,groupTotal:typeof ee.groupTotal=="string"?ee.groupTotal:void 0,grandTotal:typeof ee.grandTotal=="string"?ee.grandTotal:void 0,decoration:ee.cell&&ee.cell.decoration!=null?ne(ee.cell.decoration):void 0,variant:ee.cell&&ee.cell.variant!=null?ne(ee.cell.variant):void 0}))}applyState(ee,ie={}){const ce={applied:[],skipped:[]},he=Array.isArray(ee)?ee:ee&&ee.columns||[],ge=!Array.isArray(ee)&&ee&&ee.columnOrder||null;for(const ye of he){if(!ye||!ye.id){ce.skipped.push({key:"?",reason:"no id"});continue}let Ae=this.#e.get(ye.id);if(!Ae){ce.skipped.push({key:ye.id,reason:"unknown column"});continue}if(Object.hasOwn(ye,"decoration")||Object.hasOwn(ye,"variant")){const pe=Ae.cell?Ae.cell.decoration:void 0,we=ye.decoration??null,be=Object.hasOwn(ye,"variant"),Ne=be&&!oe(Ae.cell?Ae.cell.variant:void 0,ye.variant);(!oe(pe,we)||Ne)&&(this.redecorate(ye.id,we,be?{variant:ye.variant??void 0}:{}),Ae=this.#e.get(ye.id)||Ae)}ye.width!=null&&(Ae.layout.width=ye.width),ye.flex!=null&&(Ae.layout.flex=ye.flex),ye.hidden!=null&&(Ae.layout.hidden=!!ye.hidden),ye.pin!==void 0&&(Ae.layout.pin=ye.pin),ye.sort!==void 0&&(Ae.sort.direction=ye.sort),ye.sortIndex!=null&&(Ae.sort.order=ye.sortIndex),ye.groupIndex!=null&&(Ae.group.enabled=!0,Ae.group.index=ye.groupIndex),ye.pivotIndex!=null&&(Ae.pivot.enabled=!0,Ae.pivot.index=ye.pivotIndex),ye.total!==void 0&&(Ae.total=ye.total),ye.groupTotal!==void 0&&(Ae.groupTotal=ye.groupTotal),ye.grandTotal!==void 0&&(Ae.grandTotal=ye.grandTotal),ce.applied.push(ye.id)}const Ee=ge||(ie&&ie.keepOrder?[]:he.map(ye=>ye&&ye.id).filter(Boolean));if(Ee.length){const ye=Ee.filter(pe=>this.#e.has(pe)),Ae=this.#t.filter(pe=>!ye.includes(pe));this.#t=[...ye,...Ae]}return this.#y&&this.#y("state",ce),ce}move(ee,ie){this.#M(ee,ie)&&(this.#$(),this.#y&&this.#y("move",{id:ee,to:ie}))}reorder(ee){const ie={applied:[],skipped:[]},ce=[];let he=0;for(const ge of Array.isArray(ee)?ee:[]){const Ee=he++;this.#M(ge,Ee)&&(ie.applied.push(ge),ce.push({id:ge,to:Ee}))}if(!ce.length)return ie;if(this.#$(),this.#y)for(const ge of ce)this.#y("move",ge);return ie}#M(ee,ie){const ce=this.#t.indexOf(ee);if(ce===-1||Math.max(0,Math.min(Number(ie)||0,this.#t.length-1))===ce)return!1;const ge=this.#e.get(ee);if(ge.layout.movable===!1||ge.layout.lockPosition)return g(`move:${ee}`,`column "${ee}" is not movable; the move was ignored`),!1;const Ee=this.#N(ee,ie);return Ee?(g(`move.married:${Ee}`,`band "${Ee}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ce,1),this.#t.splice(Math.max(0,Math.min(ie,this.#t.length)),0,ee),!0)}#N(ee,ie){if(!this.#n||!this.#n.length)return null;const ce=this.#t.filter(ye=>ye!==ee),he=Math.max(0,Math.min(ie,ce.length)),ge=(ye,Ae)=>{if(Array.isArray(ye.columns)){for(const we of ye.columns)ge(we,Ae);return Ae}const pe=ye.column?ye.column.id:ye.id;return pe&&Ae.push(pe),Ae},Ee=ye=>{for(const Ae of ye){if(!Array.isArray(Ae.columns))continue;if(Ae.marryChildren===!0){const we=ge(Ae,[]),be=we.includes(ee),Ne=we.map($e=>ce.indexOf($e)).filter($e=>$e>=0);if(Ne.length){const $e=Math.min(...Ne),Ve=Math.max(...Ne);if(be?he<$e||he>Ve+1:he>$e&&he<=Ve)return Ae.id}}const pe=Ee(Ae.columns);if(pe)return pe}return null};return Ee(this.#n)}#$(){const ee=new Map(this.#t.map((he,ge)=>[he,ge])),ie=he=>{if(!Array.isArray(he.columns)){const Ee=he.column?he.column.id:he.id;return ee.has(Ee)?ee.get(Ee):1/0}let ge=1/0;for(const Ee of he.columns)ge=Math.min(ge,ie(Ee));return ge},ce=he=>{he.sort((ge,Ee)=>ie(ge)-ie(Ee));for(const ge of he)Array.isArray(ge.columns)&&ce(ge.columns)};ce(this.#n)}#z(ee){const ie=ce=>{for(let he=0;he<ce.length;he++){const ge=ce[he];if(Array.isArray(ge.columns)){const Ee=ie(ge.columns);if(Ee)return Ee}else if(ge.column&&ge.column.id===ee)return ce.splice(he,1)[0]}return null};return ie(this.#n)}#V(ee){const ie=[];for(let ce=ee.length-1;ce>=0;ce--){const he=ee[ce];Array.isArray(he.columns)&&(ie.push(...this.#V(he.columns)),he.columns.length===0&&(ie.push(he.id),ee.splice(ce,1)))}return ie}#B(){const ee=(ie,ce,he)=>{for(const ge of ie)Array.isArray(ge.columns)?ee(ge.columns,[...ce,ge.id]):ge.column&&(ge.column.groupPath=ce)};ee(this.#n,[])}#L(ee){const ie=new Set(ee),ce=this.#t.filter(ye=>ie.has(ye));if(!ce.length)return;const he=Math.min(...ce.map(ye=>this.#t.indexOf(ye))),ge=this.#t.slice(0,he).filter(ye=>!ie.has(ye)),Ee=this.#t.slice(he).filter(ye=>!ie.has(ye));this.#t=[...ge,...ce,...Ee]}#I(ee){const ie=[],ce=he=>{if(Array.isArray(he.columns))for(const ge of he.columns)ce(ge);else he.column&&ie.push(he.column.id)};return ce(ee),ie}#D(ee){const ie=ce=>{for(const he of ce){if(!Array.isArray(he.columns))continue;if(he.id===ee)return{node:he,parent:ce};const ge=ie(he.columns);if(ge)return ge}return null};return ie(this.#n)}groupColumns(ee,ie={}){const ce=w(ee).filter(Ae=>this.#e.has(Ae));if(!ce.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ae of ce)if(this.#e.get(Ae).layout.lockPosition)return g(`columns.group.locked:${Ae}`,`column "${Ae}" is position-locked and cannot be grouped.`),null;const he=ie.groupId?this.#D(ie.groupId):null;if(ie.groupId&&!he)return g(`columns.group.unknown:${ie.groupId}`,`no band "${ie.groupId}" to add to; nothing was grouped.`),null;let ge=null;if(!he&&ie.id!=null&&(ge=String(ie.id),this.#D(ge)||this.#e.has(ge)))return g(`columns.group.idtaken:${ge}`,`band id "${ge}" is already in use; nothing was grouped.`),null;const Ee=ce.map(Ae=>this.#z(Ae)).filter(Boolean);if(!Ee.length)return null;let ye;if(he)he.node.columns.push(...Ee),ye=he.node.id;else{const Ae={id:ge||v("grp"),title:ie.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ee},pe=Number.isInteger(ie.at)?Math.max(0,Math.min(ie.at,this.#n.length)):this.#n.length;this.#n.splice(pe,0,Ae),ye=Ae.id}return this.#V(this.#n),this.#L(ce),this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"formed",groupId:ye,ids:ce}),ye}ungroupColumn(ee){const ie=this.#e.get(ee);if(!ie){g(`columns.ungroup.unknown:${ee}`,`no column "${ee}" to ungroup.`);return}const ce=ie.groupPath||[];if(!ce.length)return;const he=ce[ce.length-1],ge=this.#D(he);if(!ge)return;const Ee=this.#z(ee);if(!Ee)return;const ye=ge.parent.indexOf(ge.node);ge.parent.splice(ye+1,0,Ee);const Ae=this.#V(this.#n),pe=this.#I(ge.node);if(pe.length){this.#L(pe);const we=Math.max(...pe.map(Ne=>this.#t.indexOf(Ne))),be=this.#t.filter(Ne=>Ne!==ee);be.splice(we+1,0,ee),this.#t=be}this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"removed",id:ee,dissolved:Ae})}renameGroup(ee,ie){const ce=this.#D(ee);if(!ce){g(`columns.group.rename:${ee}`,`no band "${ee}" to rename.`);return}ce.node.title=String(ie??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:ee,title:ce.node.title})}dissolveGroup(ee){const ie=this.#D(ee);if(!ie){g(`columns.group.dissolve:${ee}`,`no band "${ee}" to dissolve.`);return}const ce=ie.parent.indexOf(ie.node);ie.parent.splice(ce,1,...ie.node.columns),this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:ee})}moveGroup(ee,ie){const ce=this.#D(ee);if(!ce){g(`columns.group.move:${ee}`,`no band "${ee}" to move.`);return}const he=ce.parent,ge=he.indexOf(ce.node);ge!==-1&&(he.splice(ge,1),he.splice(Math.max(0,Math.min(ie,he.length)),0,ce.node),this.#_(),this.#B(),this.#y&&this.#y("columngroup",{action:"moved",groupId:ee,to:ie}))}#_(){const ee=[],ie=he=>{for(const ge of he)Array.isArray(ge.columns)?ie(ge.columns):ge.column&&ee.push(ge.column.id)};ie(this.#n);const ce=new Set(ee);this.#t=[...ee,...this.#t.filter(he=>!ce.has(he))]}groupTree(){const ee=ce=>ce.map(he=>Array.isArray(he.columns)?{id:he.id,title:he.title||"",collapsible:!!he.collapsible,openByDefault:he.openByDefault!==!1,columns:ee(he.columns)}:he.column?he.column.id:null).filter(he=>he!==null),ie=ee(this.#n);return ie.some(ce=>ce&&typeof ce=="object")?ie:[]}applyGroupTree(ee){if(!Array.isArray(ee))return;const ie=new Set,ce=ge=>{const Ee=[];for(const ye of ge)if(ye&&typeof ye=="object"&&Array.isArray(ye.columns)){const Ae=ce(ye.columns);if(!Ae.length)continue;Ee.push({id:ye.id||v("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ae})}else if(typeof ye=="string"){const Ae=this.#e.get(ye);Ae&&!ie.has(ye)&&(ie.add(ye),Ee.push({column:Ae,path:[]}))}return Ee},he=ce(ee);for(const ge of this.#t){if(ie.has(ge))continue;const Ee=this.#e.get(ge);Ee&&he.push({column:Ee,path:[]})}this.#n=he,this.#B(),this.#$(),this.#y&&this.#y("columngroup",{action:"applied"})}show(ee){this.#X(ee,!1)}hide(ee){this.#X(ee,!0)}#X(ee,ie){const ce=[];for(const he of w(ee)){const ge=this.#e.get(he);if(ge){if(ie&&ge.layout.lockVisible){g(`lockVisible:${he}`,`column "${he}" is \`layout.lockVisible\` and cannot be hidden`);continue}ge.layout.hidden!==ie&&(ge.layout.hidden=ie,ce.push(he))}}ce.length&&this.#y&&this.#y("visible",{ids:ce,hidden:ie})}pin(ee,ie){const ce=this.#e.get(ee);ce&&(ce.layout.pin=ie??null,this.#y&&this.#y("pin",{id:ee,side:ce.layout.pin}))}resize(ee,ie){const ce=this.#e.get(ee);if(!ce)return;if(ce.layout.resizable===!1){g(`resize:${ee}`,`column "${ee}" is not resizable; the resize was ignored`);return}const he=ce.layout.min??0,ge=ce.layout.max;let Ee=Math.max(he,ie);ge!=null&&(Ee=Math.min(ge,Ee)),ce.layout.width=Ee,ce.layout.flex=0,this.#y&&this.#y("resize",{id:ee,width:Ee})}}function te(se){const ee={};return se.width!=null&&(ee.width=se.width),se.hidden!=null&&(ee.hidden=se.hidden),se.pin!==void 0&&(ee.pin=se.pin),ee}function ne(se){if(se===null||typeof se!="object")return se;try{return structuredClone(se)}catch{}try{return JSON.parse(JSON.stringify(se))}catch{return se}}function oe(se,ee){const ie=se??null,ce=ee??null;if(ie===ce)return!0;if(ie===null||ce===null)return!1;if(typeof ie!="object"||typeof ce!="object")return ie===ce;try{return JSON.stringify(ie)===JSON.stringify(ce)}catch{return!1}}function le(se){const ee=[],ie=(he,ge,Ee)=>{const ye=[];for(const Ae of he){if(!W(Ae)){B("a column definition must be an object");continue}if(Array.isArray(Ae.columns)){N(Ae,O,"columnGroup",Ae.title||Ae.id||"(unnamed)");const pe={id:Ae.id||v("grp"),title:Ae.title||"",collapsible:Ae.collapsible===!0,openByDefault:Ae.openByDefault!==!1,showWhen:Ae.showWhen||"always",marryChildren:Ae.marryChildren===!0,header:Ae.header||{},def:Ae,columns:[]};pe.columns=ie(Ae.columns,[...ge,pe.id],Ae.facet!==void 0?Ae.facet:Ee),ye.push(pe)}else{const pe={def:Ae,path:ge,facet:Ee};ee.push(pe),ye.push(pe)}}return ye},ce=ie(se,[],void 0);return{leaves:ee,groups:ce}}function ae(se,ee,ie){for(const ce of se){if(ce.columns){if(ae(ce.columns,ee,ie))return!0;continue}if(ce.column&&ce.column.id===ee)return ce.column=ie,!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 F=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",$=240,_=.5;function X(H){const{columns:U,groupBy:z}=H,w=z.map(l=>U.get(l)).filter(Boolean),v=w.length?w.map(l=>l.title||l.id).join(" > "):"Group",g=H.config&&H.config.autoGroupColumnWidth||$;return{id:B,field:null,title:v,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:H.config&&H.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,d){return d&&d.group?d.groupValue:null},formatValue(l,d){if(!d||!d.group)return"";if(d.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const a=w[Math.min(d.level||0,w.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(l,d):l==null?"":String(l)}}}function W(H,U,z){!H.length||z<100||U<z*_||F(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${U} 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 $}});const Q="__lattice_select",F=44;function B(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||F;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(H,U){return U?U.selected:!1},formatValue(){return""}}}const $=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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",$=40,_=9,X=22;function W(z){const w=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max($,w*_+X)}function H(z){const w=z.rowNumbers,v=w&&typeof w=="object"?w:{},g=Number.isFinite(v.start)?v.start:1,l=Number.isFinite(v.width)?v.width:W((z.maxNumber||0)+g),d=F(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof v.title=="string"?v.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:l,min:l,max:l,pin:"start",hidden:!1,resizable:v.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,n){const t=d(n);return t==null?null:t-1+g},formatValue(a){return a==null?"":String(a)}}}const U=H}),Le("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return $}}),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 H}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,$=240,_=10;function X(U){if(!U)return null;const z=U===!0?{}:U;return z.enabled===!1?null:!F(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:F(z.rows)?z.rows:null,height:z.height??$,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:F(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:F(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=F(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 F(w)?Number(w(z))||$:w==="auto"?$:Number(w)||$}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||!F(z))return;let w=!1;for(const v of[...this.#t])z(v)||(this.#t.delete(v),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const w=Array.isArray(z)?z:[];for(const v of this.inline?w:w.slice(0,1))this.#t.add(v);this.#o()}#o(){this.#r++,this.#n()}}const H=W}),Le("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return $}}),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 U}}),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 l}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),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]),F=3e-12,B=1e-300;function $(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-$(1-n);const t=n-1;let r=.9999999999998099;const i=t+7.5;for(let f=0;f<Q.length;f++)r+=Q[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(i)-i+Math.log(r)}function _(n,t,r){const i=n+t,f=n+1,u=n-1;let o=1,m=1-i*r/f;Math.abs(m)<B&&(m=B),m=1/m;let c=m;for(let h=1;h<=300;h++){const s=2*h;let p=h*(t-h)*r/((u+s)*(n+s));m=1+p*m,Math.abs(m)<B&&(m=B),o=1+p/o,Math.abs(o)<B&&(o=B),m=1/m,c*=m*o,p=-(n+h)*(i+h)*r/((n+s)*(f+s)),m=1+p*m,Math.abs(m)<B&&(m=B),o=1+p/o,Math.abs(o)<B&&(o=B),m=1/m;const b=m*o;if(c*=b,Math.abs(b-1)<F)break}return c}function X(n,t,r){if(!(n>0)||!(t>0)||!Number.isFinite(r))return Number.NaN;if(r<=0)return 0;if(r>=1)return 1;const i=Math.exp($(n+t)-$(n)-$(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?i*_(n,t,r)/n:1-i*_(t,n,1-r)/t}function W(n){if(!(n>0)||!(n<1))return n===0?-1/0:n===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],i=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let o,m,c;n<u?(o=Math.sqrt(-2*Math.log(n)),c=(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1)):n<=1-u?(o=n-.5,m=o*o,c=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*o/(((((r[0]*m+r[1])*m+r[2])*m+r[3])*m+r[4])*m+1)):(o=Math.sqrt(-2*Math.log(1-n)),c=-(((((i[0]*o+i[1])*o+i[2])*o+i[3])*o+i[4])*o+i[5])/((((f[0]*o+f[1])*o+f[2])*o+f[3])*o+1));const s=(.5*H(-c/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-s/(1+c*s/2)}function H(n){const t=Math.abs(n),r=2/(2+t),i=4*r-2,f=[-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 u=0,o=0,m;for(let h=f.length-1;h>0;h--)m=o,o=i*o-u+f[h],u=m;const c=r*Math.exp(-t*t+.5*(f[0]+i*o)-u);return n>=0?c:2-c}function U(n){return .5*H(-n/Math.SQRT2)}function z(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*X(t/2,.5,t/(t+n*n));return n>0?1-r:r}function w(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return W(n);let r=-1e4,i=1e4,f=W(n);const u=$(t/2)+$(.5)-$((t+1)/2);for(let o=0;o<60;o++){const m=z(f,t);m<n?r=f:i=f;const c=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-u)/Math.sqrt(t),h=c>0?(m-n)/c:0;if(Math.abs(h)<1e-12)break;const s=f-h;if(f=s>r&&s<i&&Number.isFinite(s)?s:(r+i)/2,i-r<1e-12)break}return f}function v(n,t){let r=n,i=1/n,f=i;for(let u=0;u<300&&(r+=1,f*=t/r,i+=f,!(Math.abs(f)<Math.abs(i)*F));u++);return i*Math.exp(-t+n*Math.log(t)-$(n))}function g(n,t){let r=t+1-n,i=1/B,f=1/r,u=f;for(let o=1;o<=300;o++){const m=-o*(o-n);r+=2,f=m*f+r,Math.abs(f)<B&&(f=B),i=r+m/i,Math.abs(i)<B&&(i=B),f=1/f;const c=f*i;if(u*=c,Math.abs(c-1)<F)break}return Math.exp(-t+n*Math.log(t)-$(n))*u}function l(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?v(n,t):1-g(n,t)}function d(n,t){return t>0?l(t/2,n/2):Number.NaN}function a(n,t){const r=d(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),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 F}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(W){const H=W.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++)for(let w=0;w<=z;w++){let v=W[z][w];for(let g=0;g<w;g++)v-=U[z][g]*U[w][g];if(z===w){if(!(v>0))return null;U[z][w]=Math.sqrt(v)}else U[z][w]=v/U[w][w]}return U}function F(W,H){const U=W.length,z=new Array(U).fill(0);for(let v=0;v<U;v++){let g=H[v];for(let l=0;l<v;l++)g-=W[v][l]*z[l];z[v]=g/W[v][v]}const w=new Array(U).fill(0);for(let v=U-1;v>=0;v--){let g=z[v];for(let l=v+1;l<U;l++)g-=W[l][v]*w[l];w[v]=g/W[v][v]}return w}function B(W){const H=W.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++){const w=new Array(H).fill(0);w[z]=1;const v=F(W,w);for(let g=0;g<H;g++)U[g][z]=v[g]}return U}function $(W,H,U){const z=W.length,w=z?W[0].length:0,v=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let l=0;l<z;l++){const d=U?U[l]:1,a=W[l];for(let n=0;n<w;n++){const t=d*a[n];g[n]+=t*H[l];for(let r=n;r<w;r++)v[n][r]+=t*a[r]}}for(let l=0;l<w;l++)for(let d=0;d<l;d++)v[l][d]=v[d][l];return{xtwx:v,xtwy:g}}function _(W,H){return W.map(U=>U.reduce((z,w,v)=>z+w*H[v],0))}function X(W,H){let U=0;for(let z=0;z<W.length;z++){let w=0;for(let v=0;v<W.length;v++)w+=H[z][v]*W[v];U+=W[z]*w}return U}}),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 F}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return U}}),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 v}});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(l){if(!Number.isFinite(l))return;this.#e++;const d=l-this.#t;this.#t+=d/this.#e,this.#n+=d*(l-this.#t)}merge(l){if(l.#e===0)return;if(this.#e===0){this.#e=l.#e,this.#t=l.#t,this.#n=l.#n;return}const d=this.#e+l.#e,a=l.#t-this.#t;this.#t+=a*(l.#e/d),this.#n+=l.#n+a*a*(this.#e*l.#e/d),this.#e=d}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 l=this.variance();return l===null?null:Math.sqrt(l)}stddevP(){const l=this.varianceP();return l===null?null:Math.sqrt(l)}}class F{#e=[];#t=0;#n;#r;constructor(l,d=Math.random){if(!(l>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(l),this.#r=d}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(l){if(!Number.isFinite(l))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(l);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=l)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let l=0;for(const d of this.#e)l+=d;return l/this.#e.length}quantile(l){const d=this.#e.length;if(!d)return null;const a=this.#e.slice().sort((i,f)=>i-f);if(d===1)return a[0];const n=(d-1)*Math.min(1,Math.max(0,l)),t=Math.floor(n),r=Math.ceil(n);return t===r?a[t]:a[t]+(n-t)*(a[r]-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 $(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 l=typeof g=="string"?g:String(g);let d=2166136261;for(let a=0;a<l.length;a++)d^=l.charCodeAt(a),d=Math.imul(d,16777619);return B(d)}class _{#e;#t;#n;constructor(l=14){const d=Math.floor(l);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(l=14){const d=1<<Math.floor(l),a=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(l){const d=$(l),a=d&this.#t-1,n=d>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const l=this.#t,d=32-this.#e,a=new Float64Array(d+2);for(let r=0;r<l;r++)a[this.#n[r]]++;let n=l*H(1-a[d+1]/l);for(let r=d;r>=1;r--)n=.5*(n+a[r]);n+=l*W(a[0]/l);const t=X*l*l/n;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let l=1,d=g,a;do g*=g,a=d,d+=g*l,l+=l;while(d!==a);return d}function H(g){if(g===0||g===1)return 0;let l=1,d=1-g,a;do g=Math.sqrt(g),a=d,l*=.5,d-=(1-g)**2*l;while(d!==a);return d/3}class U{#e=new Map;#t;#n=0;constructor(l){if(!(l>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(l)}errorBoundFor(l){const d=l/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${l}, m=${this.#t})`})}get seen(){return this.#n}add(l){this.#n++;const d=this.#e.get(l);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(l,{count:1,error:0});return}let a,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,a=t);this.#e.delete(a),this.#e.set(l,{count:n+1,error:n})}top(l=this.#t){return[...this.#e.entries()].map(([a,n])=>({item:a,count:n.count,error:n.error})).sort((a,n)=>n.count-a.count).slice(0,Math.max(0,Math.floor(l)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(l=200,d=Math.random){this.#e=Math.max(8,Math.floor(l)),this.#r=d,this.#o=2/3}static errorBoundFor(l=200){const d=1/Math.max(8,Math.floor(l));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${l})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(l){const a=this.#t.length-1-l,n=Math.ceil(this.#e*this.#o**a);return Math.max(2,n)}add(l){Number.isFinite(l)&&(this.#n++,this.#t[0].push(l),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(l){const d=this.#t[l];d.sort((t,r)=>t-r),l+1>=this.#t.length&&this.#t.push([]);const a=this.#t[l+1],n=this.#r()<.5?0:1;for(let t=n;t<d.length;t+=2)a.push(d[t]);this.#t[l]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const l=[];for(let d=0;d<this.#t.length;d++){const a=1<<d;for(const n of this.#t[d])l.push({v:n,w:a})}return l}quantile(l){const d=this.#l();if(!d.length)return null;d.sort((r,i)=>r.v-i.v);let a=0;for(const r of d)a+=r.w;const n=Math.min(1,Math.max(0,l))*a;let t=0;for(const r of d)if(t+=r.w,t>=n)return r.v;return d[d.length-1].v}rank(l){let d=0;for(let a=0;a<this.#t.length;a++){const n=1<<a;for(const t of this.#t[a])t<=l&&(d+=n)}return d}}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"})}),v={Welford:Q,Reservoir:F,HyperLogLog:_,SpaceSaving:U,KLL:z,hash32:$,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 r}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),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 j}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),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 P}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return O}}),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 ee}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return be}}),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 Ve}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return 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 ft}}),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 de}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ke}}),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"),F=Q.presenceReader,B=Q.valueReader,$=K("packages/core/src/compute/special.js"),_=$.studentTQuantile,X=$.studentT,W=$.normalQuantile,H=$.normalCdf,U=$.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),w=z.cholesky,v=z.choleskySolve,g=z.choleskyInverse,l=z.normalEquations,d=z.quadForm,n=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,r=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"}),i=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:n.distinct}),median:Object.freeze({sketch:"KLL",bound:n.median}),p25:Object.freeze({sketch:"KLL",bound:n.p25}),p75:Object.freeze({sketch:"KLL",bound:n.p75}),p90:Object.freeze({sketch:"KLL",bound:n.p90}),p95:Object.freeze({sketch:"KLL",bound:n.p95}),p99:Object.freeze({sketch:"KLL",bound:n.p99}),iqr:Object.freeze({sketch:"KLL",bound:n.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK})});function f(ve){const Se=ve==="sum"||ve==="avg"||ve==="countValues"||ve==="min"||ve==="max"?"maintained":Object.prototype.hasOwnProperty.call(r,ve)?r[ve]:null,me=Object.prototype.hasOwnProperty.call(i,ve)?i[ve]:null;return{stat:ve,exact:Se,approximate:me}}function u(ve,Se){const me=Se.length,Pe=new Float64Array(me);let Me=0;if(ve&&(ve.kind==="float64"||ve.kind==="int32")){const De=ve.values,Oe=F(ve);for(let xe=0;xe<me;xe++){const Be=Se[xe];if(Oe&&Oe(Be)!==1)continue;const Je=De[Be];Number.isNaN(Je)||(Pe[Me++]=Je)}return Pe.subarray(0,Me)}const _e=B(ve);for(let De=0;De<me;De++){const Oe=_e(Se[De]);if(Oe==null||Oe==="")continue;const xe=typeof Oe=="number"?Oe:Number(Oe);Number.isFinite(xe)&&(Pe[Me++]=xe)}return Pe.subarray(0,Me)}function o(ve,Se){const me=new Map,Pe=B(ve);let Me=0;for(let _e=0;_e<Se.length;_e++){const De=Pe(Se[_e]);if(De==null||De===""||typeof De=="number"&&Number.isNaN(De))continue;const Oe=typeof De=="object"?String(De):De;me.set(Oe,(me.get(Oe)||0)+1),Me++}const ze=[...me.values()].sort((_e,De)=>De-_e);return{counts:ze,total:Me,distinct:ze.length}}function m(ve){return ve.total>0?ve.counts.map(Se=>Se/ve.total):[]}function c(ve,Se){const me=o(ve,Se);if(!me.total)return null;let Pe=0;for(const Me of m(me))Pe+=Me*Me;return Pe}function h(ve,Se){const me=o(ve,Se);if(!me.total)return null;let Pe=0;for(const Me of m(me))Me>0&&(Pe-=Me*Math.log2(Me));return Pe}function s(ve,Se){const me=o(ve,Se);if(!me.total||me.distinct<2)return me.total?1:null;let Pe=0;for(const Me of m(me))Me>0&&(Pe-=Me*Math.log2(Me));return Pe/Math.log2(me.distinct)}function p(ve,Se,me=3){const Pe=o(ve,Se);if(!Pe.total)return null;const Me=Math.max(1,Math.floor(me));let ze=0;for(let _e=0;_e<Math.min(Me,Pe.counts.length);_e++)ze+=Pe.counts[_e];return ze/Pe.total}function b(ve,Se){const me=u(ve,Se),Pe=me.length;if(!Pe)return null;const Me=me.slice().sort();if(Me[0]<0)return null;let ze=0,_e=0;for(let De=0;De<Pe;De++)ze+=Me[De],_e+=(De+1)*Me[De];return ze===0?0:2*_e/(Pe*ze)-(Pe+1)/Pe}function A(ve){let Se=0,me=0,Pe=0;for(let Me=0;Me<ve.length;Me++){const ze=ve[Me];Se++;const _e=ze-me;me+=_e/Se,Pe+=_e*(ze-me)}return{n:Se,mean:me,m2:Pe}}function k(ve,Se){const me=ve.length;if(!me)return NaN;if(me===1)return ve[0];const Pe=(me-1)*Math.min(1,Math.max(0,Se)),Me=Math.floor(Pe),ze=Math.ceil(Pe);return Me===ze?ve[Me]:ve[Me]+(Pe-Me)*(ve[ze]-ve[Me])}function y(ve,Se){if(!ve.length)return NaN;const me=ve.slice().sort();return k(me,Se)}function S(ve,Se){const me=B(ve);let Pe=0,Me=0,ze=0;for(let _e=0;_e<Se.length;_e++){const De=me(Se[_e]);if(De==null||De==="")continue;const Oe=String(De).toUpperCase();Oe==="PASS"?Pe++:Oe==="FAIL"?Me++:Oe==="WARN"&&ze++}return{pass:Pe+ze,fail:Me,warn:ze,judged:Pe+ze+Me}}const R=Object.freeze({hhi:(ve,Se)=>c(ve,Se),entropy:(ve,Se)=>h(ve,Se),evenness:(ve,Se)=>s(ve,Se),top3Share:(ve,Se)=>p(ve,Se,3),top10Share:(ve,Se)=>p(ve,Se,10),gini:(ve,Se)=>b(ve,Se),trimmedMean:(ve,Se)=>L(u(ve,Se),.1),winsorizedMean:(ve,Se)=>P(u(ve,Se),.1),robustOutliers:(ve,Se)=>D(u(ve,Se),3.5),jarqueBera:(ve,Se)=>I(u(ve,Se)),variance:(ve,Se)=>{const{n:me,m2:Pe}=A(u(ve,Se));return me>1?Pe/(me-1):null},varianceP:(ve,Se)=>{const{n:me,m2:Pe}=A(u(ve,Se));return me>0?Pe/me:null},stddev:(ve,Se)=>{const{n:me,m2:Pe}=A(u(ve,Se));return me>1?Math.sqrt(Pe/(me-1)):null},stddevP:(ve,Se)=>{const{n:me,m2:Pe}=A(u(ve,Se));return me>0?Math.sqrt(Pe/me):null},median:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.5):null},p25:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.25):null},p75:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.75):null},p90:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.9):null},p95:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.95):null},p99:(ve,Se)=>{const me=u(ve,Se);return me.length?y(me,.99):null},iqr:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;const Pe=me.slice().sort();return k(Pe,.75)-k(Pe,.25)},mad:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;const Pe=y(me,.5),Me=new Float64Array(me.length);for(let ze=0;ze<me.length;ze++)Me[ze]=Math.abs(me[ze]-Pe);return y(Me,.5)},range:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Pe=1/0,Me=-1/0;for(let ze=0;ze<me.length;ze++)me[ze]<Pe&&(Pe=me[ze]),me[ze]>Me&&(Me=me[ze]);return Me-Pe},distinct:(ve,Se)=>{const me=B(ve),Pe=new Set;for(let Me=0;Me<Se.length;Me++){const ze=me(Se[Me]);ze==null||ze===""||Pe.add(ze instanceof Date?ze.getTime():ze)}return Pe.size},mode:(ve,Se)=>{const me=B(ve),Pe=new Map;for(let _e=0;_e<Se.length;_e++){const De=me(Se[_e]);if(De==null||De==="")continue;const Oe=De instanceof Date?De.getTime():De;Pe.set(Oe,(Pe.get(Oe)||0)+1)}let Me=null,ze=1;for(const[_e,De]of Pe)De>ze&&(ze=De,Me=_e);return Me},skewness:(ve,Se)=>{const me=u(ve,Se),{n:Pe,mean:Me,m2:ze}=A(me);if(Pe<3||ze<=0)return null;const _e=Math.sqrt(ze/(Pe-1));let De=0;for(let Oe=0;Oe<me.length;Oe++)De+=((me[Oe]-Me)/_e)**3;return Pe/((Pe-1)*(Pe-2))*De},kurtosis:(ve,Se)=>{const me=u(ve,Se),{n:Pe,mean:Me,m2:ze}=A(me);if(Pe<4||ze<=0)return null;const _e=Math.sqrt(ze/(Pe-1));let De=0;for(let Be=0;Be<me.length;Be++)De+=((me[Be]-Me)/_e)**4;const Oe=Pe*(Pe+1)/((Pe-1)*(Pe-2)*(Pe-3)),xe=3*(Pe-1)**2/((Pe-2)*(Pe-3));return Oe*De-xe},geomean:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Pe=0;for(let Me=0;Me<me.length;Me++){if(me[Me]<=0)return null;Pe+=Math.log(me[Me])}return Math.exp(Pe/me.length)},harmean:(ve,Se)=>{const me=u(ve,Se);if(!me.length)return null;let Pe=0;for(let Me=0;Me<me.length;Me++){if(me[Me]===0)return null;Pe+=1/me[Me]}return me.length/Pe},sumSquares:(ve,Se)=>{const me=u(ve,Se);let Pe=0;for(let Me=0;Me<me.length;Me++)Pe+=me[Me]*me[Me];return Pe},passRate:(ve,Se)=>{const{pass:me,judged:Pe}=S(ve,Se);return Pe?me/Pe:null},failureCount:(ve,Se)=>S(ve,Se).fail}),j=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 x(ve,Se,me){const Pe=B(ve),Me=B(Se);let ze=0,_e=0;for(let De=0;De<me.length;De++){const Oe=me[De],xe=Number(Pe(Oe)),Be=Number(Me(Oe));!Number.isFinite(xe)||!Number.isFinite(Be)||(ze+=xe*Be,_e+=Be)}return _e===0?null:ze/_e}function E(ve,Se,me){const Pe=B(ve);let Me=null,ze=me?-1/0:1/0;for(let _e=0;_e<Se.length;_e++){const De=Se[_e],Oe=Number(Pe(De));Number.isFinite(Oe)&&(me?Oe>ze:Oe<ze)&&(ze=Oe,Me=De)}return Me}function T(ve,Se,me){const Pe=B(ve),Me=B(Se);let ze=0,_e=0,De=0,Oe=0,xe=0,Be=0;for(let it=0;it<me.length;it++){const gt=me[it],wt=Number(Pe(gt)),dt=Number(Me(gt));!Number.isFinite(wt)||!Number.isFinite(dt)||(ze++,_e+=wt,De+=dt,Oe+=wt*wt,xe+=dt*dt,Be+=wt*dt)}if(ze<2)return null;const Je=ze*Be-_e*De,Qe=Math.sqrt((ze*Oe-_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(ve,Se=.1){const me=ve.length;if(!me)return null;const Pe=Array.from(ve).sort((De,Oe)=>De-Oe),Me=Math.floor(me*Math.min(.49,Math.max(0,Se))),ze=Pe.slice(Me,me-Me);if(!ze.length)return k(Pe,.5);let _e=0;for(const De of ze)_e+=De;return _e/ze.length}function P(ve,Se=.1){const me=ve.length;if(!me)return null;const Pe=Array.from(ve).sort((Oe,xe)=>Oe-xe),Me=Math.floor(me*Math.min(.49,Math.max(0,Se))),ze=Pe[Me],_e=Pe[me-1-Me];let De=0;for(const Oe of Pe)De+=Math.min(_e,Math.max(ze,Oe));return De/me}function D(ve,Se=3.5){if(!ve.length)return null;const Pe=Array.from(ve).sort((Oe,xe)=>Oe-xe),Me=k(Pe,.5),ze=Pe.map(Oe=>Math.abs(Oe-Me)).sort((Oe,xe)=>Oe-xe),_e=k(ze,.5);if(_e===0)return null;let De=0;for(const Oe of Pe)Math.abs(.6745*(Oe-Me)/_e)>Se&&De++;return De}function I(ve){const Se=ve.length;if(Se<8)return null;let me=0;for(const Oe of ve)me+=Oe;me/=Se;let Pe=0,Me=0,ze=0;for(const Oe of ve){const xe=Oe-me;Pe+=xe*xe,Me+=xe*xe*xe,ze+=xe*xe*xe*xe}if(Pe/=Se,Me/=Se,ze/=Se,Pe===0)return null;const _e=Me/Pe**1.5,De=ze/(Pe*Pe)-3;return Se/6*(_e*_e+De*De/4)}function C(ve,Se,me){const Pe=[];let Me=0;for(let Oe=0;Oe<ve.length;Oe++){const xe=Number(ve[Oe]),Be=Number(Se[Oe]);!Number.isFinite(xe)||!Number.isFinite(Be)||Be<=0||(Pe.push([xe,Be]),Me+=Be)}if(!Pe.length||Me<=0)return null;if(Pe.sort((Oe,xe)=>Oe[0]-xe[0]),Pe.length===1)return Pe[0][0];const ze=[];let _e=0;for(const[,Oe]of Pe)ze.push((_e+Oe/2)/Me),_e+=Oe;const De=Math.max(0,Math.min(1,me));if(De<=ze[0])return Pe[0][0];if(De>=ze[ze.length-1])return Pe[Pe.length-1][0];for(let Oe=1;Oe<ze.length;Oe++){if(De>ze[Oe])continue;const xe=ze[Oe]-ze[Oe-1],Be=xe>0?(De-ze[Oe-1])/xe:0;return Pe[Oe-1][0]+(Pe[Oe][0]-Pe[Oe-1][0])*Be}return Pe[Pe.length-1][0]}function O(ve,Se,me){const Pe=B(ve),Me=B(Se),ze=new Float64Array(me.length),_e=new Float64Array(me.length);let De=0;for(let Oe=0;Oe<me.length;Oe++){const xe=me[Oe],Be=Number(Pe(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(ve,Se,me,Pe=!1){const{xs:Me,ys:ze,n:_e}=O(ve,Se,me);if(_e<2)return null;let De=0,Oe=0;for(let Be=0;Be<_e;Be++)De+=Me[Be],Oe+=ze[Be];De/=_e,Oe/=_e;let xe=0;for(let Be=0;Be<_e;Be++)xe+=(Me[Be]-De)*(ze[Be]-Oe);return xe/(Pe?_e:_e-1)}function G(ve,Se,me){const{xs:Pe,ys:Me,n:ze}=O(ve,Se,me);if(ze<2)return null;let _e=0,De=0;for(let wt=0;wt<ze;wt++)_e+=Pe[wt],De+=Me[wt];_e/=ze,De/=ze;let Oe=0,xe=0,Be=0;for(let wt=0;wt<ze;wt++){const dt=Pe[wt]-_e,At=Me[wt]-De;Oe+=dt*dt,xe+=dt*At,Be+=At*At}if(Oe===0)return null;const Je=xe/Oe,Qe=De-Je*_e,at=Be===0?1:Math.max(0,Math.min(1,xe*xe/(Oe*Be))),it=Math.max(0,Be-Je*xe),gt=ze>2?Math.sqrt(it/(ze-2)/Oe):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"]),te=1.345;function ne(ve,Se,me){const{xtwx:Pe,xtwy:Me}=l(ve,Se,me),ze=w(Pe);if(!ze)return null;const _e=v(ze,Me),De=g(ze),Oe=oe(ve,_e),xe=Se.map((Be,Je)=>Be-Oe[Je]);return{beta:_e,cov:De,fitted:Oe,residuals:xe}}function oe(ve,Se){return ve.map(me=>me.reduce((Pe,Me,ze)=>Pe+Me*Se[ze],0))}function le(ve,Se){const me=ve.length,Pe=ve.map(xe=>xe[Se]),Me=ve.map(xe=>[1,...xe.filter((Be,Je)=>Je!==Se)]),ze=ne(Me,Pe,null);if(!ze)return 1;const _e=Pe.reduce((xe,Be)=>xe+Be,0)/me;let De=0,Oe=0;for(let xe=0;xe<me;xe++)De+=ze.residuals[xe]**2,Oe+=(Pe[xe]-_e)**2;return Oe===0?1:Math.max(0,Math.min(1,1-De/Oe))}function ae(ve){const Se=[...ve].sort((Me,ze)=>Me-ze),me=se(Se),Pe=ve.map(Me=>Math.abs(Me-me)).sort((Me,ze)=>Me-ze);return se(Pe)/.6745}function se(ve){const Se=ve.length;if(!Se)return 0;const me=Math.floor(Se/2);return Se%2?ve[me]:(ve[me-1]+ve[me])/2}function ee(ve,Se,me={}){const Pe=me.method||"ols";if(J.has(Pe))throw new Error(`[lattice] regression method "${Pe}" is out of scope; use ols, wls or robust.`);if(Z.has(Pe))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!q.has(Pe))throw new Error(`[lattice] unknown regression method "${Pe}"; use ols, wls or robust.`);const Me=Array.isArray(Se)?Se.length:0,ze=Me&&Array.isArray(ve[0])?ve[0].length:0,_e=ze+1;if(!(Me>_e))return null;for(let Mt=0;Mt<Me;Mt++){if(!Number.isFinite(Se[Mt])||!Array.isArray(ve[Mt])||ve[Mt].length!==ze)return null;for(let xt=0;xt<ze;xt++)if(!Number.isFinite(ve[Mt][xt]))return null}let De=null;if(Pe==="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 Oe=ve.map(Mt=>[1,...Mt]);let xe,Be=null;if(Pe==="robust"){if(xe=ne(Oe,Se,null),!xe)return null;for(let Mt=0;Mt<50;Mt++){const xt=ae(xe.residuals);if(!(xt>0))break;const Bt=xe.residuals.map(Yt=>{const Jt=Math.abs(Yt/xt);return Jt<=te?1:te/Jt}),Kt=ne(Oe,Se,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(Oe,Se,De),!xe)return null;const Je=Pe==="robust"?Be:De,{beta:Qe,cov:at,fitted:it,residuals:gt}=xe;let wt=0,dt=0,At=0;for(let Mt=0;Mt<Me;Mt++){const xt=Je?Je[Mt]:1;wt+=xt*gt[Mt]**2,dt+=xt,At+=xt*Se[Mt]}const He=At/dt;let pt=0;for(let Mt=0;Mt<Me;Mt++){const xt=Je?Je[Mt]:1;pt+=xt*(Se[Mt]-He)**2}const ct=Me-_e,ot=wt/ct,St=pt===0?1:Math.max(0,Math.min(1,1-wt/pt)),jt=1-(1-St)*(Me-1)/ct,ht=Array.isArray(me.names)&&me.names.length===ze?me.names:ve[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)":ht[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*d(Oe[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=ve[0].map((Mt,xt)=>{if(ze<2)return 1;const Bt=le(ve,xt);return Bt>=1?1/0:1/(1-Bt)});let qt=null;{const Mt=gt.map(Bt=>Bt*Bt),xt=ne(Oe,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=U(Jt,ze);qt={statistic:Jt,df:ze,p:nn,heteroscedastic:nn<.05}}}let Wt=null;if(ze===1){const Mt=ve.map((xt,Bt)=>Bt).sort((xt,Bt)=>ve[xt][0]-ve[Bt][0]);Wt={confidence:Nt,points:Mt.map(xt=>{const Bt=Oe[xt],Kt=Math.sqrt(Math.max(0,ot*d(Bt,at)));return{x:ve[xt][0],yhat:it[xt],lower:it[xt]-Dt*Kt,upper:it[xt]+Dt*Kt}})}}return{method:Pe,coefficients:_t,r2:St,adjR2:jt,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 ie(ve){const Se=ve.length,me=Array.from({length:Se},(ze,_e)=>_e).sort((ze,_e)=>ve[ze]-ve[_e]),Pe=new Float64Array(Se);let Me=0;for(;Me<Se;){let ze=Me;for(;ze+1<Se&&ve[me[ze+1]]===ve[me[Me]];)ze++;const _e=(Me+ze)/2+1;for(let De=Me;De<=ze;De++)Pe[me[De]]=_e;Me=ze+1}return Pe}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function he(ve){const Se=[.01,.05,.1],me=[ce["1%"],ce["5%"],ce["10%"]];if(ve<=me[0]){const ze=(Math.log(Se[1])-Math.log(Se[0]))/(me[1]-me[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Se[0])+ze*(ve-me[0]))))}if(ve>=me[2]){const ze=(Math.log(Se[2])-Math.log(Se[1]))/(me[2]-me[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Se[2])+ze*(ve-me[2]))))}const Pe=ve<me[1]?0:1,Me=(ve-me[Pe])/(me[Pe+1]-me[Pe]);return Math.exp(Math.log(Se[Pe])+Me*(Math.log(Se[Pe+1])-Math.log(Se[Pe])))}function ge(ve,Se,me,Pe){const Me=me-Pe,ze=Pe+3,_e=new Array(Me),De=new Array(Me);let Oe=!0,xe=Pe;for(let it=0;it<Me;it++){const gt=Pe+it,wt=new Float64Array(ze);wt[0]=1,wt[1]=it+1,wt[2]=ve[gt];for(let dt=1;dt<=Pe;dt++)wt[2+dt]=Se[gt-dt];for(let dt=1;dt<ze;dt++)Number.isFinite(wt[dt])||(xe=Math.min(xe,dt-3));_e[it]=wt,De[it]=Se[gt],Number.isFinite(De[it])||(Oe=!1)}if(!Oe)return 0;const{xtwx:Be,xtwy:Je}=l(_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 At=v(dt,Je.slice(0,gt));let He=0;for(let St=0;St<Me;St++){const jt=_e[St];let ht=0;for(let Nt=0;Nt<gt;Nt++)ht+=jt[Nt]*At[Nt];He+=(De[St]-ht)**2}const ct=He/(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 Ee(ve,Se={}){const me=[];for(let at=0;at<ve.length;at++){const it=Number(ve[at]);Number.isFinite(it)&&me.push(it)}const Pe=me.length,Me=Pe-1;if(Pe<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(Se.maxlag)?Math.floor(Se.maxlag):Math.ceil(12*(Pe/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 At=[dt-it+1,me[dt]];for(let He=1;He<=at;He++)At.push(ze[dt-He]);gt.push(At),wt.push(ze[dt])}return ee(gt,wt,{method:"ols"})},Oe=ge(me,ze,Me,_e),xe=De(Oe,Oe);if(!xe||!xe.coefficients[2])return null;const Be=xe.coefficients[2].t,Je=he(Be),Qe=Be<ce["5%"];return{statistic:Be,usedLag:Oe,nobs:Me-Oe,criticalValues:{...ce},pValue:Je,pApproximate:!0,stationary:Qe,verdict:Qe?"stationary":"non-stationary",regression:"ct"}}function ye(ve,Se={}){const me=[];for(let Qe=0;Qe<ve.length;Qe++){const at=Number(ve[Qe]);Number.isFinite(at)&&me.push(at)}const Pe=me.length;if(Pe<3)return null;let Me=Number.isFinite(Se.maxlag)?Math.floor(Se.maxlag):Math.min(10,Pe-1);Me=Math.max(1,Math.min(Me,Pe-1));let ze=0;for(const Qe of me)ze+=Qe;ze/=Pe;const _e=me.map(Qe=>Qe-ze);let De=0;for(const Qe of _e)De+=Qe*Qe;De/=Pe;const Oe=new Array(Me+1).fill(0);Oe[0]=1;for(let Qe=1;Qe<=Me;Qe++){let at=0;for(let it=Qe;it<Pe;it++)at+=_e[it]*_e[it-Qe];Oe[Qe]=De>0?at/Pe/De:0}const xe=new Array(Me+1).fill(0);xe[0]=1;let Be=[];for(let Qe=1;Qe<=Me;Qe++){let at=Oe[Qe];for(let dt=1;dt<Qe;dt++)at-=Be[dt-1]*Oe[Qe-dt];let it=1;for(let dt=1;dt<Qe;dt++)it-=Be[dt-1]*Oe[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(Pe);return{acf:Oe,pacf:xe,bounds:{upper:Je,lower:-Je},n:Pe,nlags:Me,approximate:!0}}function Ae(ve,Se,me){const{xs:Pe,ys:Me,n:ze}=O(ve,Se,me);if(ze<2)return null;const _e=ie(Pe),De=ie(Me);let Oe=0,xe=0;for(let at=0;at<ze;at++)Oe+=_e[at],xe+=De[at];Oe/=ze,xe/=ze;let Be=0,Je=0,Qe=0;for(let at=0;at<ze;at++){const it=_e[at]-Oe,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(ve,Se,me){const{xs:Pe,ys:Me,n:ze}=O(ve,Se,me);if(ze<2||ze>t)return null;let _e=0,De=0,Oe=0,xe=0;for(let Qe=0;Qe<ze;Qe++)for(let at=Qe+1;at<ze;at++){const it=Math.sign(Pe[Qe]-Pe[at]),gt=Math.sign(Me[Qe]-Me[at]),wt=it*gt;wt>0?_e++:wt<0?De++:it===0&>===0||(it===0?Oe++:xe++)}const Be=_e+De+xe,Je=_e+De+Oe;return Be===0||Je===0?null:(_e-De)/Math.sqrt(Be*Je)}function we(ve,Se={}){const me=ve.length;if(me<2)return null;const Pe=ve[0],Me=ve[me-1],ze=[];for(let dt=1;dt<me;dt++){const At=ve[dt-1];At!==0&&ze.push((ve[dt]-At)/Math.abs(At))}let _e=null;if(ze.length>1){let dt=0;for(const He of ze)dt+=He;dt/=ze.length;let At=0;for(const He of ze)At+=(He-dt)**2;_e=Math.sqrt(At/(ze.length-1))}const De=Number(Se.periodsPerYear)>0?Number(Se.periodsPerYear):null;let Oe=ve[0],xe=0,Be=0,Je=0,Qe=0;for(let dt=1;dt<me;dt++){if(ve[dt]>Oe){Oe=ve[dt],xe=dt;continue}if(Oe<=0)continue;const At=(Oe-ve[dt])/Oe;At>Be&&(Be=At,Je=xe,Qe=dt)}let at=null;if(me>2){let dt=0;for(let pt=0;pt<me;pt++)dt+=ve[pt];dt/=me;let At=0,He=0;for(let pt=0;pt<me;pt++){const ct=ve[pt]-dt;He+=ct*ct,pt>0&&(At+=ct*(ve[pt-1]-dt))}at=He>0?At/He:null}let it=0,gt=0;for(const dt of ze)dt>0?it++:dt<0&>++;let wt=null;if(Pe>0&&Me>0){const dt=(Me/Pe)**(1/(me-1))-1;wt=De?(1+dt)**De-1:dt}return{n:me,first:Pe,last:Me,change:Me-Pe,changePercent:Pe===0?null:(Me-Pe)/Math.abs(Pe)*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 be=1.128,Ne=3.267;function $e(ve){const Se=ve.length;if(Se<2)return null;const me=[];for(let Me=1;Me<Se;Me++)me.push(Math.abs(ve[Me]-ve[Me-1]));const Pe=me.reduce((Me,ze)=>Me+ze,0)/me.length;return{ranges:me,centre:Pe,upper:Ne*Pe,lower:0}}function Ve(ve){const Se=ve.length;if(Se<2)return null;let me=0;for(let Me=1;Me<Se;Me++)me+=Math.abs(ve[Me]-ve[Me-1]);const Pe=me/(Se-1);return{sigma:Pe/be,meanRange:Pe}}function Ye(ve,Se){const me=ve.length;if(me<2||!Se)return null;const Pe=Number.isFinite(Number(Se.lower))?Number(Se.lower):null,Me=Number.isFinite(Number(Se.upper))?Number(Se.upper):null;if(Pe===null&&Me===null)return null;let ze=0;for(let it=0;it<me;it++)ze+=ve[it];ze/=me;let _e=0;for(let it=0;it<me;it++)_e+=(ve[it]-ze)**2;const De=Math.sqrt(_e/(me-1)),Oe=Ve(ve),xe=Oe?Oe.sigma:null,Be=it=>{if(!it||it<=0)return{index:null,k:null};const wt=Pe!==null&&Me!==null?(Me-Pe)/(6*it):null,dt=Me!==null?(Me-ze)/(3*it):1/0,At=Pe!==null?(ze-Pe)/(3*it):1/0;return{index:wt,k:Math.min(dt,At)}},Je=Be(xe),Qe=Be(De);let at=0;for(let it=0;it<me;it++){if(Pe!==null&&ve[it]<Pe){at++;continue}Me!==null&&ve[it]>Me&&at++}return{n:me,mean:ze,lower:Pe,upper:Me,target:Number.isFinite(Number(Se.target))?Number(Se.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 je(ve){const Se=ve.length;if(Se<2)return null;const me=Ve(ve);if(!me||!(me.sigma>0))return null;let Pe=0;for(let Me=0;Me<Se;Me++)Pe+=ve[Me];return Pe/=Se,{centre:Pe,sigma:me.sigma,upper:Pe+3*me.sigma,lower:Pe-3*me.sigma}}function Ge(ve,Se){if(!Se||!(Se.sigma>0))return[];const me=ve.length,{centre:Pe,sigma:Me}=Se,ze=De=>(ve[De]-Pe)/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 Oe of[1,-1]){let xe=0;for(let Be=De-2;Be<=De;Be++)ze(Be)*Oe>2&&xe++;if(xe>=2){_e.push({index:De,rule:2,description:"two of three past two sigma"});break}}if(De>=4)for(const Oe of[1,-1]){let xe=0;for(let Be=De-4;Be<=De;Be++)ze(Be)*Oe>1&&xe++;if(xe>=4){_e.push({index:De,rule:3,description:"four of five past one sigma"});break}}if(De>=7)for(const Oe of[1,-1]){let xe=!0;for(let Be=De-7;Be<=De;Be++)if(ze(Be)*Oe<=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(ve,Se){if(!Se||!(Se.sigma>0))return[];const me=ve.length,{centre:Pe,sigma:Me}=Se,ze=Oe=>(ve[Oe]-Pe)/Me,_e=(Oe,xe,Be,Je)=>{for(const Qe of[1,-1]){let at=0;for(let it=Oe;it<=xe;it++)ze(it)*Qe>Be&&at++;if(at>=Je)return!0}return!1},De=[];for(let Oe=0;Oe<me;Oe++){if(Math.abs(ze(Oe))>3&&De.push({index:Oe,rule:1,description:"beyond three sigma"}),Oe>=8)for(const xe of[1,-1]){let Be=!0;for(let Je=Oe-8;Je<=Oe;Je++)if(ze(Je)*xe<=0){Be=!1;break}if(Be){De.push({index:Oe,rule:2,description:"nine in a row on one side"});break}}if(Oe>=5)for(const xe of[1,-1]){let Be=!0;for(let Je=Oe-4;Je<=Oe;Je++)if((ve[Je]-ve[Je-1])*xe<=0){Be=!1;break}if(Be){De.push({index:Oe,rule:3,description:xe>0?"six rising":"six falling"});break}}if(Oe>=13){let xe=!0;for(let Be=Oe-12;Be<=Oe;Be++){const Je=ve[Be]-ve[Be-1],Qe=ve[Be+1<=Oe?Be+1:Be]-ve[Be];if(Be+1>Oe)break;if(Je===0||Qe===0||Je>0==Qe>0){xe=!1;break}}xe&&De.push({index:Oe,rule:4,description:"fourteen alternating"})}if(Oe>=2&&_e(Oe-2,Oe,2,2)&&De.push({index:Oe,rule:5,description:"two of three past two sigma"}),Oe>=4&&_e(Oe-4,Oe,1,4)&&De.push({index:Oe,rule:6,description:"four of five past one sigma"}),Oe>=14){let xe=!0;for(let Be=Oe-14;Be<=Oe;Be++)if(Math.abs(ze(Be))>=1){xe=!1;break}xe&&De.push({index:Oe,rule:7,description:"fifteen within one sigma"})}if(Oe>=7){let xe=!0;for(let Be=Oe-7;Be<=Oe;Be++)if(Math.abs(ze(Be))<=1){xe=!1;break}xe&&De.push({index:Oe,rule:8,description:"eight beyond one sigma"})}}return De}const rt=Object.freeze(["westernElectric","nelson"]);function st(ve,Se,me="westernElectric"){return String(me)==="nelson"?Ze(ve,Se):Ge(ve,Se)}function ft(ve,Se,me){let Pe=0;for(let Me=0;Me<ve.length;Me++)(ve[Me]<Se||ve[Me]>me)&&Pe++;return Pe}function yt(ve,Se,me,Pe=20){const Me=ve.length;if(!Me)return[];const ze=ve[0],_e=ve[Me-1];if(_e===ze)return[{from:ze,to:_e,count:Me}];const De=me-Se,Oe=1.5*De;let xe=De>0?Math.max(ze,Se-Oe):ze,Be=De>0?Math.min(_e,me+Oe):_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(Pe,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((ve[gt]-xe)/at)));it[wt].count++}return it[0].from=ze,it[Qe-1].to=_e,it}const Ot=.95;function Ct(ve){const Se=Number(ve);return Number.isFinite(Se)&&Se>0&&Se<1?Se:Ot}function Tt(ve,Se=Ot){const me=ve.length;if(me<2)return null;let Pe=0;for(let Be=0;Be<me;Be++)Pe+=ve[Be];const Me=Pe/me;let ze=0;for(let Be=0;Be<me;Be++){const Je=ve[Be]-Me;ze+=Je*Je}const _e=Math.sqrt(ze/(me-1)),De=Ct(Se),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(ve,Se,me=Ot){const Pe=Number(ve),Me=Number(Se);if(!(Me>0)||!(Pe>=0)||Pe>Me)return null;const ze=Ct(me),_e=W(1-(1-ze)/2),De=Pe/Me,Oe=_e*_e,xe=1+Oe/Me,Be=(De+Oe/(2*Me))/xe,Je=_e/xe*Math.sqrt(De*(1-De)/Me+Oe/(4*Me*Me));return{proportion:De,lower:Math.max(0,Be-Je),upper:Math.min(1,Be+Je),n:Me,confidence:ze}}function zt(ve,Se=Ot){if(!ve||!(ve.n>2)||!Number.isFinite(ve.stdError))return null;const me=Ct(Se),Me=_(1-(1-me)/2,ve.n-2)*ve.stdError;return{slope:ve.slope,lower:ve.slope-Me,upper:ve.slope+Me,margin:Me,confidence:me}}function It(ve,Se,me=Ot){const Pe=Number(ve),Me=Number(Se);if(!Number.isFinite(Pe)||!(Me>1))return null;const ze=Ct(me),De=W(1-(1-ze)/2)*Math.sqrt(1/(9*Me)+Pe*Pe/(2*(Me-1)));return{index:Pe,lower:Pe-De,upper:Pe+De,margin:De,n:Me,confidence:ze}}function ut(ve,Se){return!ve||!(ve.sd>0)||!Number.isFinite(Se)||!Number.isFinite(ve.mean)?null:(Se-ve.mean)/ve.sd}function nt(ve){return Number.isFinite(ve)?Math.min(1,Math.max(0,2*H(Math.abs(ve)/2)-1)):0}function de(ve,Se){const me=new Map,Pe=B(ve);let Me=0;for(let ze=0;ze<Se.length;ze++){const _e=Pe(Se[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 ke(ve,Se,me,Pe){if(!(Se>0)||!(Pe>0))return null;let Me=0;const ze=new Set(ve.keys());for(const _e of me.keys())ze.add(_e);for(const _e of ze){const De=(ve.get(_e)||0)/Se,Oe=(me.get(_e)||0)/Pe;Me+=Math.abs(De-Oe)}return Me/2}const Re=10;function We(ve,Se,me){if(me&&me.numeric){const De=u(ve,Se),{n:Oe,mean:xe}=A(De),Be=Oe>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:Oe,populationN:me.n||0,reliable:Oe>=Re}}const{map:Me,total:ze}=de(ve,Se),_e=ke(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(ve,Se){if(ve&&(ve.kind==="float64"||ve.kind==="int32"))return!0;const me=B(ve);let Pe=0,Me=0;for(let ze=0;ze<Se.length&&Pe<200;ze++){const _e=me(Se[ze]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Pe++;const De=typeof _e=="number"?_e:Number(_e);Number.isFinite(De)&&Me++}return Pe===0?!1:Me/Pe>=.9}function qe(ve,Se){if(Ie(ve,Se)){const Me=u(ve,Se),{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:Pe}=de(ve,Se);return{numeric:!1,map:me,total:Pe}}}),Le("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return h}}),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"),F=Q.isFunction,B=Q.warnOnce,$=K("packages/core/src/compute/handle.js"),_=$.presenceReader,X=$.valueComparator,W=$.valueReader,H=K("packages/core/src/compute/statistics.js"),U=H.STAT_FNS,z=H.STAT_LABELS;function w(A){return!!A&&(A.kind==="float64"||A.kind==="int32")}function v(A,k){const y=k.length;let S=0;if(w(A)){const j=A.values,x=_(A);if(!x){for(let E=0;E<y;E++){const T=j[k[E]];Number.isNaN(T)||(S+=T)}return S}for(let E=0;E<y;E++){const T=k[E];if(x(T)===1){const L=j[T];Number.isNaN(L)||(S+=L)}}return S}const R=W(A);for(let j=0;j<y;j++){const x=f(R(k[j]));x!==null&&(S+=x)}return S}v.kernel=!0;function g(A,k){const y=k.length;let S=0;if(w(A)){const j=A.values,x=_(A);if(!x){for(let E=0;E<y;E++)Number.isNaN(j[k[E]])||S++;return S}for(let E=0;E<y;E++){const T=k[E];x(T)===1&&!Number.isNaN(j[T])&&S++}return S}const R=W(A);for(let j=0;j<y;j++){const x=R(k[j]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&S++}return S}g.kernel=!0;function l(A,k){return k.length}l.kernel=!0;function d(A,k){const y=g(A,k);return y===0?null:v(A,k)/y}d.kernel=!0;function a(A,k,y,S){const R=k.length;if(w(A)){const T=A.values,L=_(A);let P=null;if(!L){for(let D=0;D<R;D++){const I=T[k[D]];Number.isNaN(I)||(P===null||(y<0?I<P:I>P))&&(P=I)}return P}for(let D=0;D<R;D++){const I=k[D];if(L(I)===0)continue;const C=T[I];Number.isNaN(C)||(P===null||(y<0?C<P:C>P))&&(P=C)}return P}const j=W(A),x=X(S);let E=null;for(let T=0;T<R;T++){const L=j(k[T]);L==null||typeof L=="number"&&Number.isNaN(L)||(E===null||(y<0?x(L,E)<0:x(L,E)>0))&&(E=L)}return E}function n(A,k,y){return a(A,k,-1,y&&y.locale)}n.kernel=!0;function t(A,k,y){return a(A,k,1,y&&y.locale)}t.kernel=!0;function r(A,k){return k.length===0?null:W(A)(k[0])}r.kernel=!0;function i(A,k){return k.length===0?null:W(A)(k[k.length-1])}i.kernel=!0;function f(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 u={sum:v,min:n,max:t,avg:d,count:l,first:r,last:i,countValues:g,...U},o=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"?o[A]||A:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(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 u);for(const S of Object.keys(u))y.includes(S)||y.push(S);return y}function s(A,k){return typeof k!="string"?!0:h(A).includes(k)}function p(A,k){const y=W(A),S=[];for(let R=0;R<k.length;R++){const j=y(k[R]);j!=null&&S.push(j)}return S}function b(A,k,y,S){const R=k||[];if(typeof y=="string"){const j=u[y];return j?j(A,R,S):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return F(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 $}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const F=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,U=0,z=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(U>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(U),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(H,U=this.#r()){Number.isFinite(H)&&(this.#n.push({t:U,v:H}),this.#i(U))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const U=H-this.#t;for(;this.#n.length&&this.#n[0].t<U;)this.#n.shift()}}spec(){const H=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const U=new F;let z=0,w=1/0,v=-1/0;for(const{v:g}of this.#n)z+=g,g<w&&(w=g),g>v&&(v=g),U.add(g);return{over:H,count:this.#n.length,sum:z,mean:U.mean(),min:w,max:v,variance:U.variance(),stddev:U.stddev()}}reduce(H){const U=this.aggregate(),z={sum:U.sum,avg:U.mean,mean:U.mean,min:U.min,max:U.max,count:U.count,variance:U.variance,stddev:U.stddev};if(!(H in z))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:z[H],over:U.over}}}const $=Object.freeze(["count","time","session"]);function _(W,H=Date.now){const U=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new B(W.kind,U,H)}const X={Window:B,WINDOW_KINDS:$,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 H}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return U}}),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 d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const F=K("packages/core/src/compute/windowed.js").openWindow,$=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(o,m,c,h){if(o.kind==="count"){const s=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,m/s),partial:m<s}}if(o.kind==="time"){const s=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(s>0))return{coverage:1,partial:!1};const p=c-h;return{coverage:Math.min(1,p/s),partial:p<s}}return{coverage:null,partial:!1}}function W(o,m){const c=F(m),h=new Map,s=o.length?o[0].at:0;for(let p=0;p<o.length;p++){const{key:b,at:A,value:k}=o[p];Number.isFinite(k)&&c.push(k,A);const y=c.aggregate(),S=X(m,y.count,A,s);b!=null&&h.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 h}function H(o){const m=new Map;let c=0;for(const{key:h,value:s}of o)Number.isFinite(s)&&(c+=s),h!=null&&m.set(String(h),c);return m}function U(o,m=1){const c=new Map,h=Math.max(1,Math.floor(m));for(let s=0;s<o.length;s++){const{key:p,value:b}=o[s];if(p==null)continue;const A=s>=h?o[s-h].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(o){let m=o>>>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 v(o,m){const c=o.length;if(c===1)return o[0];const h=(c-1)*m,s=Math.floor(h),p=Math.ceil(h);return s===p?o[s]:o[s]+(h-s)*(o[p]-o[s])}function g(o,m,c={}){const h=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=o.length?o[0].at:0;if(m.kind==="session"){const y=new $(200,p);let S=0;for(const{key:R,value:j}of o)Number.isFinite(j)&&(y.add(j),S++),R!=null&&b.set(String(R),{value:S?y.quantile(h):null,approx:S>0,count:S,coverage:null,partial:!1});return b}const k=F(m);for(const{key:y,at:S,value:R}of o){Number.isFinite(R)&&k.push(R,S);const j=k.values(),x=j.length;let E=null,T=!1;if(x)if(x<=s)E=v([...j].sort((P,D)=>P-D),h);else{const P=new $(200,p);for(const D of j)P.add(D);E=P.quantile(h),T=!0}const L=X(m,x,S,A);y!=null&&b.set(String(y),{value:E,approx:T,count:x,coverage:L.coverage,partial:L.partial})}return b}function l(o,m){const c=o.length,h=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=o[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=o[b+y];if(!Number.isFinite(S)){k=!1;break}A+=S}k&&(h[b]=A/m)}return h}function d(o,m){const c=new Map,h=Math.floor(Number(m&&m.period));if(!(h>=2))return c;const s=m&&m.model==="multiplicative",p=o.length,b=o.map(T=>Number.isFinite(T.value)?T.value:null),A=l(b,h),k=new Array(p).fill(null);for(let T=0;T<p;T++){const L=A[T],P=b[T];L===null||P===null||(s?L!==0&&(k[T]=P/L):k[T]=P-L)}const y=new Array(h).fill(0),S=new Array(h).fill(0);for(let T=0;T<p;T++){if(k[T]===null)continue;const L=T%h;y[L]+=k[T],S[L]+=1}const R=s?1:0,j=y.map((T,L)=>S[L]?T/S[L]:R),x=j.reduce((T,L)=>T+L,0)/h,E=s?j.map(T=>x!==0?T/x:1):j.map(T=>T-x);for(let T=0;T<p;T++){const{key:L}=o[T];if(L==null)continue;const P=A[T],D=E[T%h],I=b[T];let C=null;P!==null&&I!==null&&(C=s?P*D!==0?I/(P*D):null:I-P-D),c.set(String(L),{trend:P,seasonal:I===null?null:D,residual:C,coverage:P===null?0:1,partial:P===null})}return c}function a(o,m,c,h=80){const s=(Math.sqrt(5)-1)/2;let p=m,b=c,A=b-s*(b-p),k=p+s*(b-p),y=o(A),S=o(k);for(let R=0;R<h;R++)y<S?(b=k,k=A,S=y,A=b-s*(b-p),y=o(A)):(p=A,A=k,y=S,k=p+s*(b-p),S=o(k));return(p+b)/2}const n=1e-4,t=1-1e-4;function r(o,m){const c=o.length,h=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=o[A];if(!Number.isFinite(k)){p!==null&&(s[A]=p,h[A]=p);continue}if(p===null){p=k,s[A]=k,h[A]=k;continue}s[A]=p,b+=(k-p)**2,p=m*k+(1-m)*p,h[A]=p}return{smoothed:h,fitted:s,sse:b}}function i(o,m,c){const h=o.length,s=new Array(h).fill(null),p=new Array(h).fill(null);let b=null,A=null,k=0;for(let y=0;y<h;y++){const S=o[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 x=b+A;p[y]=x,k+=(S-x)**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 j=b;b=m*S+(1-m)*(j+A),A=c*(b-j)+(1-c)*A,s[y]=b}return{smoothed:s,fitted:p,sse:k}}function f(o,m={}){const c=new Map,h=m.method==="holt",s=o.map(R=>Number.isFinite(R.value)?R.value:null),p=s.filter(R=>R!==null).length,b=R=>Math.min(t,Math.max(n,R)),A=()=>{for(const{key:R}of o)R!=null&&c.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(p<(h?2:1))return A();let k=Number.isFinite(m.alpha)?b(m.alpha):null,y=h&&Number.isFinite(m.beta)?b(m.beta):null;if(h){if(k===null||y===null){let R=k===null?.5:k,j=y===null?.5:y;for(let x=0;x<6;x++)k===null&&(R=a(E=>i(s,E,j).sse,n,t)),y===null&&(j=a(E=>i(s,R,E).sse,n,t));k=k===null?R:k,y=y===null?j:y}}else k===null&&(k=a(R=>r(s,R).sse,n,t));const S=h?i(s,k,y):r(s,k);for(let R=0;R<o.length;R++){const{key:j}=o[R];j!=null&&c.set(String(j),{smoothed:S.smoothed[R],fitted:S.fitted[R],alpha:k,beta:h?y:null,sse:S.sse})}return c}const u={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:W,rollingQuantile:g,cumulativeToDate:H,periodOverPeriod:U,seasonalDecompose:d,exponentialSmoothing:f}}),Le("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return U}}),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 v}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/compute/statistics.js"),F=Q.numbers,B=Q.moments,$=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,H=Q.SUBSET_RELIABILITY_FLOOR,U=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(d,a){if(!d||!a||!(d.n>0)||!(a.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(a.mean))return null;const n=(d.n*d.sd*d.sd+a.n*a.sd*a.sd)/(d.n+a.n);return n>0?(d.mean-a.mean)/Math.sqrt(n):null}function w(d,a){const n=F(d,a),{n:t,mean:r,m2:i}=B(n),f=t>0?Math.sqrt(i/t):0;return{mean:r,sd:f,n:t}}function v(d,a,n,t){return W(d,a)&&W(n,t)}function g(d,a,n,t){if(v(d,a,n,t)){const u=w(d,a),o=w(n,t),m=z(u,o);return{measure:U.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:u.n,nB:o.n,reliable:u.n>=H&&o.n>=H}}const r=$(d,a),i=$(n,t),f=_(r.map,r.total,i.map,i.total);return{measure:U.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:r.total,nB:i.total,reliable:r.total>=H&&i.total>=H}}function l(d,a,n={}){const t=new Set(d.columns),r=new Set(a.columns),i=d.columns.filter(c=>r.has(c)),f=Array.isArray(n.columns)&&n.columns.length?i.filter(c=>n.columns.includes(c)):i,u=d.indices(),o=a.indices(),m=[];for(const c of f){const h=d.handle(c),s=a.handle(c);if(!h||!s)continue;const p=g(h,u,s,o);m.push({column:c,name:d.name&&d.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,h)=>h.distance-c.distance||Math.abs(h.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:m,nA:u.length,nB:o.length,unmatched:{onlyA:d.columns.filter(c=>!r.has(c)),onlyB:a.columns.filter(c=>!t.has(c))},measures:U}}}),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 H}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U}}),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 v}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const F=K("packages/core/src/compute/statistics.js").quantileSorted,$=K("packages/core/src/compute/special.js").logGamma,_=.6745,X=3.5,W=1.5,H=.975,U=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(o){if(!o.length)return null;const c=Array.from(o,Number).sort((b,A)=>b-A),h=F(c,.5),s=c.map(b=>Math.abs(b-h)).sort((b,A)=>b-A),p=F(s,.5);return{median:h,mad:p}}function w(o,m={}){const c=Number.isFinite(m.threshold)?m.threshold:X,h=o.length,s=new Array(h).fill(null),p=new Array(h).fill(!1),b=[];for(let y=0;y<h;y++){const S=Number(o[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<h;y++){const S=Number(o[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 v(o,m={}){const c=Number.isFinite(m.k)?m.k:W,h=[];for(let k=0;k<o.length;k++){const y=Number(o[k]);Number.isFinite(y)&&h.push(y)}if(!h.length)return null;const s=h.sort((k,y)=>k-y),p=F(s,.25),b=F(s,.75),A=b-p;return{q1:p,q3:b,iqr:A,lower:p-c*A,upper:b+c*A,k:c}}function g(o,m){if(m<=0)return 0;const c=$(o);if(m<o+1){let y=o,S=1/o,R=S;for(let j=0;j<1e3&&(y+=1,R*=m/y,S+=R,!(Math.abs(R)<Math.abs(S)*1e-15));j++);return S*Math.exp(-m+o*Math.log(m)-c)}const h=1e-300;let s=m+1-o,p=1/h,b=1/s,A=b;for(let y=1;y<1e3;y++){const S=-y*(y-o);s+=2,b=S*b+s,Math.abs(b)<h&&(b=h),p=s+S/p,Math.abs(p)<h&&(p=h),b=1/b;const R=b*p;if(A*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+o*Math.log(m)-c)*A}function l(o,m){return o<=0?0:g(m/2,o/2)}function d(o,m=H){if(!(m>0)||!(m<1))return NaN;let c=0,h=Math.max(1,o);for(;l(h,o)<m;)h*=2;for(let s=0;s<200;s++){const p=(c+h)/2;if(l(p,o)<m?c=p:h=p,h-c<1e-10)break}return(c+h)/2}function a(o){const m=o.length,c=o.map((h,s)=>{const p=h.slice();for(let b=0;b<m;b++)p.push(s===b?1:0);return p});for(let h=0;h<m;h++){let s=h;for(let b=h+1;b<m;b++)Math.abs(c[b][h])>Math.abs(c[s][h])&&(s=b);if(Math.abs(c[s][h])<1e-12)return null;if(s!==h){const b=c[s];c[s]=c[h],c[h]=b}const p=c[h][h];for(let b=0;b<2*m;b++)c[h][b]/=p;for(let b=0;b<m;b++){if(b===h)continue;const A=c[b][h];if(A!==0)for(let k=0;k<2*m;k++)c[b][k]-=A*c[h][k]}}return c.map(h=>h.slice(m))}function n(o,m){const c=o.length,h=new Array(m).fill(0);for(const b of o)for(let A=0;A<m;A++)h[A]+=b[A];for(let b=0;b<m;b++)h[b]/=c;const s=Array.from({length:m},()=>new Array(m).fill(0));for(const b of o)for(let A=0;A<m;A++){const k=b[A]-h[A];for(let y=A;y<m;y++)s[A][y]+=k*(b[y]-h[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:h,cov:s}}function t(o,m={}){const c=Number.isFinite(m.p)?m.p:H,h=Number.isFinite(m.ridge)?m.ridge:1e-6,s=o.length;if(!s)return null;const p=o[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=o[D];let C=I.length===p;const O=new Array(p);for(let N=0;C&&N<p;N++){const G=Number(I[N]);Number.isFinite(G)?O[N]=G:C=!1}C&&(y.push(D),S.push(O))}const R=p,j=d(R,c);if(S.length<=p)return{center:[],df:R,cutoff:j,singular:!0,used:S.length,distances:b,squared:A,flags:k,flagged:0};const{mean:x,cov:E}=n(S,p);let T=a(E),L=!1;if(!T){L=!0;let D=0;for(let O=0;O<p;O++)D+=E[O][O];const I=D/p*h||h,C=E.map((O,N)=>O.map((G,q)=>N===q?G+I:G));if(T=a(C),!T)return{center:x,df:R,cutoff:j,singular:!0,used:S.length,distances:b,squared:A,flags:k,flagged:0}}let P=0;for(let D=0;D<S.length;D++){const I=S[D],C=new Array(p);for(let G=0;G<p;G++)C[G]=I[G]-x[G];let O=0;for(let G=0;G<p;G++){let q=0;for(let Z=0;Z<p;Z++)q+=T[G][Z]*C[Z];O+=C[G]*q}O<0&&(O=0);const N=y[D];A[N]=O,b[N]=Math.sqrt(O),O>j&&(k[N]=!0,P++)}return{center:x,df:R,cutoff:j,singular:L,used:S.length,distances:b,squared:A,flags:k,flagged:P}}const r=20,i=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(o,m={}){const c=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):r,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):h,A=o.length,k=new Array(A).fill(null),y=new Array(A).fill(!1);let S=0;for(let R=0;R<A;R++){const j=Number(o[R]);if(!Number.isFinite(j))continue;const x=Math.max(0,R-h+1),E=[];for(let T=x;T<=R;T++){const L=Number(o[T]);Number.isFinite(L)&&E.push(L)}if(!(E.length<b))if(c==="rollingIqr"){const T=v(E,{k:p});if(!T)continue;(j<T.lower||j>T.upper)&&(y[R]=!0,S++)}else{const T=z(E);if(!T||T.mad===0)continue;const L=_*(j-T.median)/T.mad;k[R]=L,Math.abs(L)>s&&(y[R]=!0,S++)}}return{method:c,windowLen:h,minPeriods:b,threshold:s,k:p,scores:k,flags:y,flagged:S}}function u(o={}){const m=o||{},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 h=m.method||"modifiedZScore";if(!(U.includes(h)||i.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,b=m.latest===!0,A=i.includes(h),k=y=>Number(y==null?NaN:y[c]);return y=>{const S=Array.isArray(y)?y.slice():[...y];p&&S.sort((T,L)=>{const P=T?.[p],D=L?.[p];return P===D?0:P==null?-1:D==null?1:P<D?-1:1});const R=S.map(k);let j,x;if(A)({flags:j,scores:x}=f(R,{method:h,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(h==="iqr"){const T=v(R,{k:m.k});j=R.map(L=>T?Number.isFinite(L)&&(L<T.lower||L>T.upper):!1),x=R.map(()=>null)}else({flags:j,scores:x}=w(R,{threshold:m.threshold}));if(b){const T=j.length-1;return T<0||!j[T]?!1:{method:h,field:c,flagged:[{row:S[T],score:x[T]}]}}const E=[];for(let T=0;T<j.length;T++)j[T]&&E.push({row:S[T],score:x[T]});return E.length?{method:h,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 n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/compute/special.js"),F=Q.normalQuantile,B=Q.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),W=1e-4,H=1-1e-4;function U(m){const c=[];for(let h=0;h<m.length;h++){const s=m[h];if(s!==null&&typeof s=="object"){const p=Number.isFinite(s.at)?s.at:h,b=Number.isFinite(s.value)?s.value:null;c.push({at:p,value:b})}else c.push({at:h,value:Number.isFinite(s)?Number(s):null})}return c}function z(m){const c=m.filter(A=>A.value!==null),h=c[0],s=c[c.length-1],p=s.at-h.at,b=c.length>1&&p>0?p/(c.length-1):1;return{lastAt:s.at,step:b}}function w(m){return Math.min(H,Math.max(W,m))}function v(m,c=W,h=H,s=80){const p=(Math.sqrt(5)-1)/2;let b=c,A=h,k=A-p*(A-b),y=b+p*(A-b),S=m(k),R=m(y);for(let j=0;j<s;j++)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 h=null,s=0,p=0;for(let b=0;b<m.length;b++){const A=m[b];if(A!==null){if(h===null){h=A;continue}s+=(A-h)**2,p+=1,h=c*A+(1-c)*h}}return{level:h,sse:s,m:p}}function l(m,c,h){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=h*(s-R)+(1-h)*p}return{level:s,trend:p,sse:b,m:A}}function d(m,c,h,s,p){const b=m.length;if(b<2*c)return null;const A=L=>{let P=0,D=0;for(let I=L;I<L+c&&I<b;I++)m[I]!==null&&(P+=m[I],D+=1);return D?P/D:null},k=A(0),y=A(c);if(k===null||y===null)return null;let S=k,R=(y-k)/c;const j=new Array(c).fill(0);for(let L=0;L<c;L++)j[L]=m[L]===null?0:m[L]-S;const x=j.reduce((L,P)=>L+P,0)/c;for(let L=0;L<c;L++)j[L]-=x;let E=0,T=0;for(let L=c;L<b;L++){const P=L%c,D=j[P],I=m[L];if(I===null){S+=R;continue}const C=S+R+D;E+=(I-C)**2,T+=1;const O=S;S=h*(I-D)+(1-h)*(S+R),R=s*(S-O)+(1-s)*R,j[P]=p*(I-S)+(1-p)*D}return{level:S,trend:R,season:j,phase:(b-1)%c,sse:E,count:T}}function a(m,c,h){let s=1;for(const b of c)s+=b*b;const p=Math.sqrt(m*s);return{se:p,margin:h*p}}function n(m,c={}){if(!m||typeof m.length!="number"||m.length===0)return null;const h=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=U(m),k=A.map(E=>E.value),y=k.filter(E=>E!==null),S=y.length,{lastAt:R,step:j}=S?z(A):{lastAt:0,step:1},x=E=>R+E*j;return h==="linear"?t(A,S,s,p,b,x):h==="movingAverage"?r(y,S,s,p,b,c,x):h==="ses"?i(k,S,s,p,b,c,x):h==="holt"?f(k,S,s,p,b,c,x):u(k,S,s,p,b,c,x)}function t(m,c,h,s,p,b){if(c<2)return null;let A=0,k=0;for(const I of m)I.value!==null&&(A+=I.at,k+=I.value);A/=c,k/=c;let y=0,S=0,R=0;for(const I of m){if(I.value===null)continue;const C=I.at-A,O=I.value-k;y+=C*C,S+=C*O,R+=O*O}if(y===0)return null;const j=S/y,x=k-j*A,E=R===0?1:Math.max(0,Math.min(1,S*S/(y*R))),T=Math.max(0,R-j*S),L=c>2?Math.sqrt(T/(c-2)):null,P=c>2?B(p,c-2):null,D=[];for(let I=1;I<=h;I++){const C=b(I),O=x+j*C;let N=null,G=null,q=null,Z=null,J=null;if(L!==null){const te=1/c+(C-A)**2/y,ne=L*Math.sqrt(1+te),oe=L*Math.sqrt(te);J=ne,N=O-P*ne,G=O+P*ne,q=O-P*oe,Z=O+P*oe}D.push({step:I,at:C,mean:O,lower:N,upper:G,lowerMean:q,upperMean:Z,se:J})}return{method:"linear",horizon:h,confidence:s,n:c,sigma:L,r2:E,params:{slope:j,intercept:x},points:D}}function r(m,c,h,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 j=null,x=null;if(k>1){let L=0;for(const D of y)L+=(D-R)**2;j=Math.sqrt(L/(k-1))*Math.sqrt(1+1/k),x=B(p,k-1)}const E=j===null?null:x*j,T=[];for(let L=1;L<=h;L++)T.push({step:L,at:A(L),mean:R,lower:E===null?null:R-E,upper:E===null?null:R+E,se:j});return{method:"movingAverage",horizon:h,confidence:s,n:c,sigma:j===null?null:j,params:{windowLen:k},points:T}}function i(m,c,h,s,p,b,A){if(c<1)return null;let k=Number.isFinite(b.alpha)?w(b.alpha):null;k===null&&(k=v(x=>g(m,x).sse));const y=g(m,k),S=F(p),R=y.m>0?y.sse/y.m:null,j=[];for(let x=1;x<=h;x++){const E=y.level;let T=null,L=null,P=null;if(R!==null){const D=[];for(let C=1;C<x;C++)D.push(k);const I=a(R,D,S);P=I.se,T=E-I.margin,L=E+I.margin}j.push({step:x,at:A(x),mean:E,lower:T,upper:L,se:P})}return{method:"ses",horizon:h,confidence:s,n:c,sigma:R===null?null:Math.sqrt(R),params:{alpha:k},points:j}}function f(m,c,h,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 P=0;P<6;P++)k===null&&(T=v(D=>l(m,D,L).sse)),y===null&&(L=v(D=>l(m,T,D).sse));k=k===null?T:k,y=y===null?L:y}const S=l(m,k,y),R=F(p),j=S.m>0?S.sse/S.m:null,x=k*y,E=[];for(let T=1;T<=h;T++){const L=S.level+T*S.trend;let P=null,D=null,I=null;if(j!==null){const C=[];for(let N=1;N<T;N++)C.push(k+N*x);const O=a(j,C,R);I=O.se,P=L-O.margin,D=L+O.margin}E.push({step:T,at:A(T),mean:L,lower:P,upper:D,se:I})}return{method:"holt",horizon:h,confidence:s,n:c,sigma:j===null?null:Math.sqrt(j),params:{alpha:k,beta:y},points:E}}function u(m,c,h,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 j=(I,C,O)=>{const N=d(m,k,I,C,O);return N?N.sse:1/0};if(y===null||S===null||R===null){let I=y===null?.5:y,C=S===null?.5:S,O=R===null?.5:R;for(let N=0;N<8;N++)y===null&&(I=v(G=>j(G,C,O))),S===null&&(C=v(G=>j(I,G,O))),R===null&&(O=v(G=>j(I,C,G)));y=y===null?I:y,S=S===null?C:S,R=R===null?O:R}const x=d(m,k,y,S,R);if(!x)return null;const E=F(p),T=x.count>0?x.sse/x.count:null,L=y*S,P=R*(1-y),D=[];for(let I=1;I<=h;I++){const C=x.season[(x.phase+I)%k],O=x.level+I*x.trend+C;let N=null,G=null,q=null;if(T!==null){const Z=[];for(let te=1;te<I;te++)Z.push(y+te*L+(te%k===0?P:0));const J=a(T,Z,E);q=J.se,N=O-J.margin,G=O+J.margin}D.push({step:I,at:A(I),mean:O,lower:N,upper:G,se:q})}return{method:"holtWinters",horizon:h,confidence:s,n:c,sigma:T===null?null:Math.sqrt(T),params:{alpha:y,beta:S,gamma:R,period:k},points:D}}const o={FORECAST_METHODS:X,forecast:n}}),Le("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),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 F=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),X=_.numbers,W=_.moments,H=_.frequencyMap,U=_.categoricalDistance,z=_.isNumericColumn,w=_.jarqueBera,v=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,d=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=K("packages/core/src/compute/special.js"),n=a.studentT,t=a.studentTQuantile,r=a.normalCdf,i=a.normalQuantile,f=a.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,m=2e6;function c(T){const L=Number(T);return Number.isFinite(L)&&L>0&&L<1?L:.95}function h(T){const{n:L,mean:P,m2:D}=W(T);return{mean:P,sd:L>0?Math.sqrt(D/L):0,n:L}}function s(T,L){const P=T.length;if(P<2)return 0;let D=0;for(let I=0;I<P;I++){const C=T[I]-L;D+=C*C}return D/(P-1)}function p(T,L){return{name:"pooledStandardMeanDifference",value:d(h(T),h(L))}}function b(T,L,P){const D=T.length,I=L.length;if(D<2||I<2)return null;const C=c(P),{mean:O}=W(T),{mean:N}=W(L),G=s(T,O),q=s(L,N),Z=G/D+q/I;if(!(Z>0))return null;const J=Math.sqrt(Z),te=(O-N)/J,ne=G/D*(G/D)/(D-1),oe=q/I*(q/I)/(I-1),le=Z*Z/(ne+oe),ae=Math.min(1,Math.max(0,2*(1-n(Math.abs(te),le)))),se=O-N,ee=t(1-(1-C)/2,le)*J;return{test:u.WELCH,statistic:te,statisticName:"t",df:le,pValue:ae,interval:{estimate:se,lower:se-ee,upper:se+ee,confidence:C,method:"welch-t (difference of means)"},effectSize:p(T,L),nA:D,nB:I,reliable:D>=g&&I>=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 P=L>>1;return L%2?T[P]:(T[P-1]+T[P])/2}function k(T,L,P){const D=T.length,I=L.length,C=D*I;if(C===0||C>m)return null;const O=new Float64Array(C);let N=0;for(let ne=0;ne<D;ne++)for(let oe=0;oe<I;oe++)O[N++]=T[ne]-L[oe];O.sort();const G=A(O),q=Math.sqrt(D*I*(D+I+1)/12),Z=i(1-(1-P)/2);let J=Math.round(C/2-Z*q);J>=0||(J=0);const te=Math.floor((C-1)/2);return J>te&&(J=te),{estimate:G,lower:O[J],upper:O[C-1-J],confidence:P,method:"hodges-lehmann (normal approximation)"}}function y(T,L,P){const D=T.length,I=L.length;if(D<1||I<1)return null;const C=c(P),O=D+I,N=new Array(O);for(let ae=0;ae<D;ae++)N[ae]={v:T[ae],g:0};for(let ae=0;ae<I;ae++)N[D+ae]={v:L[ae],g:1};N.sort((ae,se)=>ae.v-se.v);let G=0,q=0,Z=0;for(;Z<O;){let ae=Z;for(;ae<O&&N[ae].v===N[Z].v;)ae++;const se=ae-Z,ee=(Z+1+ae)/2;for(let ie=Z;ie<ae;ie++)N[ie].g===0&&(G+=ee);q+=se*se*se-se,Z=ae}const J=G-D*(D+1)/2,te=D*I/2,ne=D*I/12*(O+1-q/(O*(O-1)));let oe=1;if(ne>0){const ae=Math.max(0,Math.abs(J-te)-.5);oe=Math.min(1,2*r(-ae/Math.sqrt(ne)))}const le=k(T,L,C);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:le,effectSize:p(T,L),nA:D,nB:I,reliable:D>=g&&I>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function S(T,L,P,D,I){const C=v(T,L,I),O=v(P,D,I);if(!C||!O)return null;const N=C.proportion-O.proportion,G=N-Math.sqrt((C.proportion-C.lower)**2+(O.upper-O.proportion)**2),q=N+Math.sqrt((C.upper-C.proportion)**2+(O.proportion-O.lower)**2);return{lower:G,upper:q}}function R(T,L,P,D,I,C={}){if(!(L>0)||!(D>0))return null;const O=new Set([...T.keys(),...P.keys()]),N=O.size;if(N<2)return null;const G=L+D;let q=0;for(const oe of O){const le=T.get(oe)||0,ae=P.get(oe)||0,se=le+ae,ee=L*se/G,ie=D*se/G;ee>0&&(q+=(le-ee)*(le-ee)/ee),ie>0&&(q+=(ae-ie)*(ae-ie)/ie)}const Z=N-1,J=f(q,Z);let te=null;C.category!==void 0&&O.has(C.category)?te=C.category:N===2&&([te]=[...O]);let ne=null;if(te!==null){const oe=S(T.get(te)||0,L,P.get(te)||0,D,c(I));oe&&(ne={estimate:(T.get(te)||0)/L-(P.get(te)||0)/D,lower:oe.lower,upper:oe.upper,confidence:c(I),method:"newcombe (difference in this category's share)",category:te})}return{test:u.CHI_SQUARE,statistic:q,statisticName:"chiSquare",df:Z,pValue:J,interval:ne,effectSize:{name:"categoricalTotalVariation",value:U(T,L,P,D)},nA:L,nB:D,reliable:L>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function j(T){return T==null||T===""||typeof T=="number"&&Number.isNaN(T)?null:T instanceof Date?T.getTime():typeof T=="object"?String(T):T}function x(T,L,P){if(P===u.WELCH||P===u.MANN_WHITNEY)return{test:P,chosenBy:"override",reason:`caller override: ${P}`};const D=w(T),I=w(L),C=D===null?null:Math.exp(-D/2),O=I===null?null:Math.exp(-I/2);return C!==null&&C<o||O!==null&&O<o?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:u.WELCH,chosenBy:"auto",reason:C!==null||O!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(T,L,P,D={}){if(!T||!L)return null;const I=c(D.confidence),C=$(L);let O;if(Array.isArray(D.groups)&&D.groups.length===2)O=[j(D.groups[0]),j(D.groups[1])];else{const{map:ae}=H(L,P),se=[...ae.entries()].sort((ee,ie)=>ie[1]-ee[1]).slice(0,2).map(ee=>ee[0]);if(se.length<2)return F("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;O=se}const[N,G]=O;if(N===null||G===null||N===G)return F("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const q=[],Z=[];for(let ae=0;ae<P.length;ae++){const se=j(C(P[ae]));se===N?q.push(P[ae]):se===G&&Z.push(P[ae])}if(q.length===0||Z.length===0)return F("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,te=z(T,q.concat(Z));let ne,oe,le;if(J===u.CHI_SQUARE||!J&&!te){oe=J?"override":"auto",le=J?"caller override: chiSquare":"column family: categorical";const ae=H(T,q),se=H(T,Z);ne=R(ae.map,ae.total,se.map,se.total,I,{category:D.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!te)return F("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const ae=X(T,q),se=X(T,Z),ee=x(ae,se,J);oe=ee.chosenBy,le=ee.reason,ne=ee.test===u.MANN_WHITNEY?y(ae,se,I):b(ae,se,I)}return ne?{...ne,chosenBy:oe,reason:le,groups:[N,G]}:(F("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 $}});const Q="__lattice_detail",F=36;function B(_){const X=_.config&&_.config.detailColumnWidth||F;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,H){return!!(H&&H.expanded)},formatValue(){return""}}}const $=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 F=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",$=260;function _(W){const H=W.tree||{},U=W.config&&W.config.treeColumnWidth||$,z=()=>(W.columns&&F(W.columns.visible)?W.columns.visible():[]).find(l=>!l.generated)||null,w=(g,l)=>{if(l&&l.group)return l.groupValue;if(F(H.label))return H.label(g,l);if(typeof H.label=="string")return g==null?null:g[H.label];const d=z();return d&&F(d.getValue)?d.getValue(g,l):null},v=()=>{if(H.title)return H.title;const g=typeof H.label=="string"?W.columns&&F(W.columns.get)?W.columns.get(H.label):null:z();return g&&(g.title||g.id)||"Hierarchy"};return{id:B,get title(){return v()},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:U,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,l){return w(g,l)},formatValue(g,l){if(l&&l.grandTotal)return W.config&&W.config.grandTotalLabel||"Total";if(g==null)return"";if(!H.label){const d=z();if(d&&F(d.formatValue))return d.formatValue(g,l)}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 F=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",$=500;function _(U){const{pivot:z,valueColumns:w,config:v}=U,g=z&&z.paths||[],l=U.separator||v&&v.pivot&&v.pivot.separator||" | ",d=v&&v.pivot&&v.pivot.maxColumns||$;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const a=X(v),n=g.length*w.length+(a?w.length:0);if(n>d){const i=`pivot would generate ${n} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return F(`pivot.maxColumns:${n}`,i),{tree:[],leaves:[],error:i}}const t=[],r=[];for(const i of g){const f=[];for(const u of w){const o=H(i,u,l);f.push(o),r.push(o)}f.length===1?(f[0].title=String(i),t.push(f[0])):t.push({id:`${B}:group:${i}`,title:String(i),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const i=w.map(u=>W(u,v));r.push(...i);const f=v&&v.pivot&&v.pivot.totalsLabel||"Total";if(i.length===1)i[0].title=f,a==="before"?t.unshift(i[0]):t.push(i[0]);else{const u={id:`${B}:group:__totals`,title:f,columns:i,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:r,error:null}}function X(U){const z=U&&U.pivot&&U.pivot.groupTotals;return z==="before"||z==="after"?z:null}function W(U,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:U.id,total:!0},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.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,v){const g=v&&v.totals;return g&&Object.hasOwn(g,U.id)?g[U.id]:null},formatValue(w,v){return w==null?"":U.formatValue?U.formatValue(w,v):String(w)}}}function H(U,z,w){return{id:`${B}:${U}${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:U,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(v,g){return v==null?"":z.formatValue?z.formatValue(v,g):String(v)}}}}),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 v}});const Q=K("packages/core/src/compute/handle.js"),F=Q.dictSize,B=Q.identity,$=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",H="\0",U=1<<20;function z(g,l,d,a){const n=g.length,t=g.map(m=>X(m)),r=Array.isArray(a)&&a.some(Boolean),i=r?t.map((m,c)=>a[c]?h=>a[c](m(h)):m):t;if(!r&&n>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(h=>F(h.dict)+1);let c=1;for(let h=0;h<n;h++)c*=m[h];if(c<=Number.MAX_SAFE_INTEGER){const h=g.map(A=>A.values),s=g.map(A=>$(A)),p=A=>{let k=0;for(let y=0;y<n;y++){const S=s[y],R=S&&S(A)===0?m[y]-1:h[y][A];k=k*m[y]+R}return k},b=new Float64Array(d);for(let A=0;A<d;A++)b[A]=p(l[A]);return{packed:b,strings:null,product:c,readers:i,keyOf:p}}}const u=m=>{let c="";for(let h=0;h<n;h++){const s=i[h](m);c+=(h===0?"":W)+(s==null?H:String(s))}return c},o=new Array(d);for(let m=0;m<d;m++)o[m]=u(l[m]);return{packed:null,strings:o,product:1/0,readers:i,keyOf:u}}function w(g,l,d,a){const n=new Uint32Array(a+1);for(let f=0;f<d;f++)n[l[f]+1]++;for(let f=0;f<a;f++)n[f+1]+=n[f];const t=new Uint32Array(d),r=n.slice(0,a);for(let f=0;f<d;f++)t[r[l[f]]++]=g[f];const i=new Array(a);for(let f=0;f<a;f++)i[f]=t.subarray(n[f],n[f+1]);return i}function v(g,l,d={}){const a=g||[],n=l||B(_(a[0],d)),t=n.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:i,product:f,readers:u}=z(a,n,t,d.project),o=new Uint32Array(t);let m=0,c=null;if(r&&f<=Math.max(1024,Math.min(U,t*4))){const b=f,A=new Int32Array(b).fill(-1);for(let k=0;k<t;k++)A[r[k]]=0;for(let k=0;k<b;k++)A[k]===0&&(A[k]=m++);for(let k=0;k<t;k++)o[k]=A[r[k]];c=new Float64Array(m);for(let k=0;k<b;k++)A[k]>=0&&(c[A[k]]=k)}else if(r){const b=new Map;for(let A=0;A<t;A++){const k=r[A];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),o[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=i[A];let y=b.get(k);y===void 0&&(y=m++,b.set(k,y)),o[A]=y}}const h=w(n,o,t,m),s=new Array(m);for(let b=0;b<m;b++){const A=h[b][0],k=new Array(u.length);for(let y=0;y<u.length;y++)k[y]=u[y](A);s[b]=k}const p={keys:s,buckets:h};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 U}}),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 v}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const F=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/core/src/compute/handle.js").valueComparator,X=K("packages/core/src/compute/group.js").packKeys,H=K("packages/core/src/compute/total.js").total,U="|",z="/",w=2e3;function v(f,u,o){return`${f}${U}${u}${U}${o}`}function g(f,u){let o="";for(let m=0;m<f.length;m++){const c=f[m];o+=(m===0?"":u)+(c==null?"":String(c))}return o}function l(f,u,o={}){const m=o.separator||z,c=u.length,{keyOf:h,readers:s}=X(f,u,0),p=new Map,b=[],A=[];for(let E=0;E<c;E++){const T=u[E],L=h(T);if(p.has(L))continue;p.set(L,b.length),A.push(L);const P=new Array(s.length);for(let D=0;D<s.length;D++)P[D]=s[D](T);b.push(P)}const k=$(o.locale),y=b.map((E,T)=>T);y.sort((E,T)=>{const L=b[E],P=b[T];for(let D=0;D<L.length;D++){const I=d(L[D],P[D],k);if(I!==0)return I}return E-T});const S=new Array(y.length),R=new Array(y.length),j=new Map;for(let E=0;E<y.length;E++){const T=y[E];S[E]=b[T],R[E]=g(b[T],m),j.set(A[T],E)}return{keys:S,paths:R,idOf:E=>{const T=j.get(h(E));return T===void 0?-1:T}}}function d(f,u,o){const m=f==null,c=u==null;return m||c?m&&c?0:m?1:-1:o(f,u)}function a(f){const u=f.values||f.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(h=>h&&h.handle);const o=typeof f.handle=="function"?f.handle:null;if(!o)return u.length&&F("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 f.totalOf=="function"?f.totalOf:null,c=[];for(const h of u){const s=o(h);s&&c.push({colId:h,handle:s,fn:m?m(h):"sum"})}return c}function n(f,u,o){if(Array.isArray(f)){const m=o||{};return{...m,pivotHandles:f,order:u||null,groups:m.groups||null}}return f||{}}function t(f,u,o){const m=n(f,u,o),c=m.separator||z,h=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=i(b),{keys:y,paths:S,idOf:R}=l(m.pivotHandles||[],k,m),j=S.length*Math.max(1,h.length),x=r(S,h,c);if(s&&j>s){const L=new Map;return{keys:y,paths:S,fields:x,groupPaths:A,columns:j,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${j} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:j,maxColumns:s}}}const E=new Map,T=S.length;for(let L=0;L<b.length;L++){const P=b[L],D=A[L]===void 0?"":A[L],I=P.length;if(I===0)continue;const C=new Int32Array(I),O=new Uint32Array(T+1);for(let q=0;q<I;q++){const Z=R(P[q]);C[q]=Z,Z>=0&&O[Z+1]++}for(let q=0;q<T;q++)O[q+1]+=O[q];const N=new Uint32Array(I),G=O.slice(0,T);for(let q=0;q<I;q++){const Z=C[q];Z>=0&&(N[G[Z]++]=P[q])}for(let q=0;q<T;q++){const Z=O[q],J=O[q+1];if(J===Z)continue;const te=N.subarray(Z,J);for(let ne=0;ne<h.length;ne++){const oe=h[ne],le=H(oe.handle,te,oe.fn,m.totalContext||{locale:m.locale});E.set(v(D,S[q],oe.colId),le)}}}return{keys:y,paths:S,fields:x,groupPaths:A,columns:j,values:E,cells:E,error:null}}function r(f,u,o){if(u.length===0)return f.slice();const m=[];for(const c of f)for(const h of u)m.push(`${c}${o}${h.colId}`);return m}function i(f){if(f.length===1)return f[0]||new Uint32Array(0);let u=0;for(const c of f)u+=c?c.length:0;const o=new Uint32Array(u);let m=0;for(const c of f)!c||c.length===0||(o.set(c,m),m+=c.length);return o}}),Le("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return F}});const Q=8;class F{static#e=new Uint8Array(256);static{for(let $=1;$<256;$++)F.#e[$]=F.#e[$>>1]+($&1)}#t;#n;constructor($=0){const _=Math.max(0,$|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($){return $<0||$>=this.#n?0:this.#t[$>>3]>>($&7)&1}set($){return $>=0&&$<this.#n&&(this.#t[$>>3]|=1<<($&7)),this}clear($){return $>=0&&$<this.#n&&(this.#t[$>>3]&=~(1<<($&7))),this}assign($,_){return _?this.set($):this.clear($)}fill($=!1){return this.#t.fill($?255:0),$&&this.#r(),this}grow($){const _=Math.max(0,$|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 $=this.#t,_=F.#e;let X=0;for(let W=0;W<$.length;W++)X+=_[$[W]];return X}and($){const _=$ instanceof F?$.words:$,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]&=_[H];for(let H=W;H<X.length;H++)X[H]=0;return this}or($){const _=$ instanceof F?$.words:$,X=this.#t,W=Math.min(X.length,_.length);for(let H=0;H<W;H++)X[H]|=_[H];return this}not(){const $=this.#t;for(let _=0;_<$.length;_++)$[_]=~$[_]&255;return this.#r(),this}clone(){const $=new F(this.#n);return $.words.set(this.#t.subarray(0,$.words.length)),$}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const $=this.#n&7;if($===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<$)-1)}static from($){const _=Array.isArray($)?$:Array.from($),X=new F(_.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 $}});const Q=K("packages/core/src/internal/util.js"),F=Q.collator,B=Q.defaultCompare;class ${#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 H=X[W];this.#t.has(H)||(this.#t.set(H,this.#e.length),this.#e.push(H))}}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 H=this.#e[W];typeof H=="string"&&(X+=H.length*2),X+=16}return X}codeOf(X){const W=this.#t.get(X);if(W!==void 0)return W;const H=this.#e.length;return this.#e.push(X),this.#t.set(X,H),this.#n++,H}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 H=this.#e.length,U=new Array(H);for(let g=0;g<H;g++)U[g]=g;const z=F(X).compare,w=this.#e;U.sort((g,l)=>this.#s(w[g],w[l],z));const v=new Uint32Array(H);for(let g=0;g<H;g++)v[U[g]]=g;return this.#r=v,this.#o=this.#n,this.#i=W,v}#s(X,W,H){return typeof X=="string"&&typeof W=="string"?H(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 $=Math.max(1,B.rows??16),_=Math.max(1,B.values??$);this.#e=new Int32Array(_),this.#t=new Uint32Array($+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,$){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]===$)return!0;return!1}hasAny(B,$){for(let _=0;_<$.length;_++)if(this.has(B,$[_]))return!0;return!1}hasAll(B,$){for(let _=0;_<$.length;_++)if(!this.has(B,$[_]))return!1;return!0}hasNone(B,$){return!this.hasAny(B,$)}push(B){const $=this.#n,_=B.length;this.#o($+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=$+1,this.#t[$]=X,this.#t[$+1]=this.#r,$}write(B,$){if(B===this.#n){this.push($);return}if(B<0||B>this.#n)return;const _=this.#t[B],X=this.#t[B+1],W=$.length;if(X-_===W){for(let H=0;H<W;H++)this.#e[_+H]=$[H]|0;return}this.#s(B,$)}compact(B,$,_){const X=this.#e,W=this.#t,H=this.#n,U=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array($+1);let w=0;for(let v=0;v<H;v++){if(B[v]===_)continue;const g=W[v],l=W[v+1];z[B[v]]=w;for(let d=g;d<l;d++)U[w++]=X[d];z[B[v]+1]=w}this.#e=U,this.#t=z,this.#n=$,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 $=this.#t.length-1;for(;$<B;)$=$*2||16;const _=new Uint32Array($+1);_.set(this.#t),this.#t=_}#i(B){if(B<=this.#e.length)return;let $=this.#e.length;for(;$<B;)$=$*2||16;const _=new Int32Array($);_.set(this.#e),this.#e=_}#s(B,$){const _=this.#e,X=this.#t,W=this.#n,H=$.length-(X[B+1]-X[B]),U=new Int32Array(Math.max(1,this.#r+H)),z=new Uint32Array(X.length);let w=0;for(let v=0;v<W;v++){if(z[v]=w,v===B)for(let g=0;g<$.length;g++)U[w++]=$[g]|0;else for(let g=X[v];g<X[v+1];g++)U[w++]=_[g];z[v+1]=w}this.#e=U,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 o}}),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 h}}),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"),F=Q.bitReader,B=Q.dictRanks,$=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,H=Q.rowCount,U=Q.valueComparator,z=Q.valueReader,w=new Uint32Array(0),v=new ArrayBuffer(8),g=new Float64Array(v),l=new Uint32Array(v),d=(g[0]=-1,(l[1]&2147483648)!==0?1:0),a=d===1?0:1;function n(P,D){g[0]=P;let I=l[d],C=l[a];(I&2147483648)!==0?(I=~I>>>0,C=~C>>>0):I=(I^2147483648)>>>0,D[0]=C,D[1]=I}function t(P,D,I,C){if(C<2)return P;const O=new Uint32Array(256*8);for(let oe=0;oe<C;oe++){const le=D[oe],ae=I[oe];O[le&255]++,O[256+(le>>>8&255)]++,O[512+(le>>>16&255)]++,O[768+(le>>>24&255)]++,O[1024+(ae&255)]++,O[1280+(ae>>>8&255)]++,O[1536+(ae>>>16&255)]++,O[1792+(ae>>>24&255)]++}let N=P,G=D,q=I,Z=new Uint32Array(C),J=new Uint32Array(C),te=new Uint32Array(C);const ne=new Uint32Array(256);for(let oe=0;oe<8;oe++){const le=oe<<8,ae=(oe&3)<<3,se=oe>=4;let ee=!1;for(let he=0;he<256;he++)if(O[le+he]===C){ee=!0;break}if(ee)continue;let ie=0;for(let he=0;he<256;he++)ne[he]=ie,ie+=O[le+he];for(let he=0;he<C;he++){const ge=G[he],Ee=q[he],ye=(se?Ee:ge)>>>ae&255,Ae=ne[ye]++;Z[Ae]=N[he],J[Ae]=ge,te[Ae]=Ee}let ce=N;N=Z,Z=ce,ce=G,G=J,J=ce,ce=q,q=te,te=ce}return N}function r(P,D,I){if(I<2)return P;const C=new Uint32Array(256*4);for(let J=0;J<I;J++){const te=D[J];C[te&255]++,C[256+(te>>>8&255)]++,C[512+(te>>>16&255)]++,C[768+(te>>>24&255)]++}let O=P,N=D,G=new Uint32Array(I),q=new Uint32Array(I);const Z=new Uint32Array(256);for(let J=0;J<4;J++){const te=J<<8,ne=J<<3;let oe=!1;for(let se=0;se<256;se++)if(C[te+se]===I){oe=!0;break}if(oe)continue;let le=0;for(let se=0;se<256;se++)Z[se]=le,le+=C[te+se];for(let se=0;se<I;se++){const ee=N[se],ie=Z[ee>>>ne&255]++;G[ie]=O[se],q[ie]=ee}let ae=O;O=G,G=ae,ae=N,N=q,q=ae}return O}function i(P,D,I,C){const O=new Uint32Array(C+1);for(let q=0;q<I;q++)O[D[q]]++;let N=0;for(let q=0;q<=C;q++){const Z=O[q];O[q]=N,N+=Z}const G=new Uint32Array(I);for(let q=0;q<I;q++)G[O[D[q]]++]=P[q];return G}function f(P,D,I,C){return I<2?P:C<=65536||C<=I*2?i(P,D,I,C):r(P,D,I)}function u(P,D){return P.length===D&&P.byteOffset===0?P:Uint32Array.prototype.slice.call(P,0,D)}function o(P,D,I=!1){const C=D||_(P.length),O=C.length;if(O<2)return Uint32Array.from(C);const N=new Uint32Array(O),G=new Uint32Array(O),q=new Uint32Array(O),Z=new Uint32Array(O),J=new Uint32Array(2);let te=0,ne=0;for(let ae=0;ae<O;ae++){const se=C[ae],ee=P[se];if(Number.isNaN(ee)){Z[ne++]=se;continue}n(ee,J),I?(G[te]=~J[0]>>>0,q[te]=~J[1]>>>0):(G[te]=J[0],q[te]=J[1]),N[te++]=se}const oe=t(N.subarray(0,te),G.subarray(0,te),q.subarray(0,te),te);if(ne===0)return u(oe,te);const le=new Uint32Array(O);return le.set(oe.subarray(0,te),0),le.set(Z.subarray(0,ne),te),le}function m(P,D,I=!1){const C=D||_(P.length),O=C.length;if(O<2)return Uint32Array.from(C);const N=Uint32Array.from(C),G=new Uint32Array(O);for(let q=0;q<O;q++){const Z=(P[N[q]]^2147483648)>>>0;G[q]=I?~Z>>>0:Z}return u(r(N,G,O),O)}function c(P,D,I={}){const C=D||_(H(P,I)),O=C.length;if(O<2)return Uint32Array.from(C);const N=B(P.dict,I.locale),G=P.values,q=W(P),Z=Math.max($(P.dict),N.length),J=Z,te=Uint32Array.from(C),ne=new Uint32Array(O),oe=!!I.descending;for(let le=0;le<O;le++){const ae=te[le];let se=q&&q(ae)===0?J:N[G[ae]];se===void 0&&(se=J),ne[le]=oe?J-se:se}return u(f(te,ne,O,Z+1),O)}function h(P,D,I){const C=D.length;let O=Uint32Array.from(D);if(C<2)return O;let N=new Uint32Array(C);for(let G=1;G<C;G<<=1){for(let Z=0;Z<C;Z+=G<<1){const J=Math.min(Z+G,C),te=Math.min(Z+(G<<1),C);let ne=Z,oe=J,le=Z;for(;ne<J&&oe<te;)N[le++]=I(P[O[ne]],P[O[oe]])<=0?O[ne++]:O[oe++];for(;ne<J;)N[le++]=O[ne++];for(;oe<te;)N[le++]=O[oe++]}const q=O;O=N,N=q}return O}function s(P,D,I){const C=F(P.values),O=D.length,N=new Uint32Array(O),G=I?1:0;let q=0;for(let Z=0;Z<O;Z++)C(D[Z])===G&&(N[q++]=D[Z]);for(let Z=0;Z<O;Z++)C(D[Z])!==G&&(N[q++]=D[Z]);return N}function p(P,D){const I=P.values,C=P.kind;if((C==="object"||C===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!P.presence)return I;const N=z(P),G=new Array(H(P)||0);for(let q=0;q<D.length;q++){const Z=D[q];G[Z]=N(Z)}return G}function b(P,D){for(let I=0;I<D.length;I++)if(typeof P[D[I]]!="string")return!1;return!0}function A(P,D,I,C,O){const N=P.length,G=Uint32Array.from(P);if(N<2||C<1)return G;const q=new Uint32Array(N),Z=C-1;for(let J=0;J<N;J++){const te=I[D[J]];q[J]=O?Z-te:te}return u(f(G,q,N,C),N)}function k(P,D,I){const C=U(I),O=new Array(D);for(let G=0;G<D;G++)O[G]=G;O.sort((G,q)=>C(P[G],P[q])||G-q);const N=new Uint32Array(D);for(let G=0;G<D;G++)N[O[G]]=G;return N}function y(P,D,I){const C=D.length,O=new Map,N=[],G=new Uint32Array(C);for(let J=0;J<C;J++){const te=P[D[J]];let ne=O.get(te);ne===void 0&&(ne=N.length,O.set(te,ne),N.push(te)),G[J]=ne}const q=N.length,Z=k(N,q,I.locale);return A(D,G,Z,q,!!I.descending)}function S(P,D,I){const C=p(P,D);if(D.length>=2&&b(C,D)){const G=P.stringRank;return G&&G.version===P.version&&G.usable(D,C,I.locale)?G.sort(D,I):y(C,D,I)}const O=U(I.locale),N=I.descending?(G,q)=>O(q,G):O;return h(C,D,N)}function R(P,D,I){const C=p(P,D),O=I.compare,G=!!I.descending?(q,Z)=>-O(q,Z,void 0,void 0,!0):(q,Z)=>O(q,Z,void 0,void 0,!1);return h(C,D,G)}function j(P,D){const I=D.length,C=W(P),O=P.values,N=P.kind==="float64"&&!!O,G=P.kind==="object"||P.kind==="multi"||P.kind===void 0;if(!C&&!N&&!G)return{present:D,absent:w};const q=new Uint32Array(I),Z=new Uint32Array(I);let J=0,te=0;if(C&&N)for(let ne=0;ne<I;ne++){const oe=D[ne];C(oe)===1&&!Number.isNaN(O[oe])?q[J++]=oe:Z[te++]=oe}else if(N&&!C)for(let ne=0;ne<I;ne++){const oe=D[ne];Number.isNaN(O[oe])?Z[te++]=oe:q[J++]=oe}else if(C&&!G)for(let ne=0;ne<I;ne++){const oe=D[ne];C(oe)===1?q[J++]=oe:Z[te++]=oe}else{const ne=z(P);for(let oe=0;oe<I;oe++){const le=D[oe];X(ne(le))?Z[te++]=le:q[J++]=le}}return te===0?{present:D,absent:w}:{present:q.subarray(0,J),absent:Z.subarray(0,te)}}function x(P,D,I){if(D.length===0)return P;const C=new Uint32Array(P.length+D.length);return I?(C.set(D,0),C.set(P,D.length)):(C.set(P,0),C.set(D,P.length)),C}function E(P,D,I={}){const C=D||_(H(P,I));if(!P||C.length<2)return Uint32Array.from(C);const{present:O,absent:N}=j(P,C);if(O.length===0)return Uint32Array.from(C);const G=!!I.descending;let q;if(typeof I.compare=="function")q=R(P,O,I);else switch(P.kind){case"float64":q=o(P.values,O,G);break;case"int32":q=m(P.values,O,G);break;case"dictionary":q=c(P,O,I);break;case"bitset":q=s(P,O,G);break;default:q=S(P,O,I);break}return x(q,N,!!I.nullsFirst)}function T(P,D,I,C={}){const O=D||[],N=O.length&&(O[0].handle||L(P,O[0].col))||P&&P[0];let G=I||_(H(N,C));for(let q=O.length-1;q>=0;q--){const Z=O[q],J=Z.handle||L(P,Z.col)||P&&P[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:C.locale,compare:Z.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function L(P,D){if(!(!P||D===void 0)){for(let I=0;I<P.length;I++)if(P[I]&&P[I].id===D)return P[I]}}}),Le("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/compute/sort.js"),F=Q.collateStringRanks,B=Q.rankSortStrings,$=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(W=$){this.#s=W>0?W:$,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 H=this.#e;for(let U=0;U<H.length;U++)W+=H[U].length*2+24;return W}#d(W,H){const U=this.#t.get(W);if(U!==void 0)return U;if(this.#l)return-1;if(H&&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,H){const U=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(U);for(let z=0;z<U;z++){const w=W[z],v=typeof w=="string"?this.#d(w,!1):-1;this.#n[z]=v<0?0:v}this.#r=U}append(W,H,U){const z=(H|0)+(U|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=H|0;w<z;w++){const v=W[w],g=typeof v=="string"?this.#d(v,!0):-1;this.#n[w]=g<0?0:g}this.#r=Math.max(this.#r,z)}ranks(W){const H=W||"";if(this.#a&&this.#u===this.#o&&this.#c===H)return this.#a;const U=F(this.#e,this.#e.length,W);return this.#a=U,this.#u=this.#o,this.#c=H,U}usable(W,H,U){if(this.#l||this.#e.length===0)return!1;const z=this.#n,w=this.#e,v=this.#r;for(let g=0;g<W.length;g++){const l=W[g];if(l>=v||w[z[l]]!==H[l])return!1}return!0}sort(W,H){const U=this.ranks(H.locale),z=this.#e.length,w=W.length,v=new Uint32Array(w),g=this.#n;for(let l=0;l<w;l++)v[l]=g[W[l]];return B(W,v,U,z,!!H.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 r}}),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"),F=Q.warnOnce,B=Q.isFunction,$=Q.pathGetter,X=K("packages/core/src/store/bitset.js").Bitset,H=K("packages/core/src/store/dictionary.js").Dictionary,z=K("packages/core/src/store/multivalue.js").MultiValue,v=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,l=1024,d=5e3,a=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function r(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const s=Number(h);return Number.isNaN(s)&&typeof h=="string"?Date.parse(h):s}function i(h){const s=r(h);return Number.isFinite(s)?s|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function u(h,s){switch(h.kind){case"float64":case"int32":return h.buf[s];case"bitset":return h.bits.get(s)===1;case"dictionary":return h.dict.valueOf(h.buf[s]);case"multi":{const p=h.mv.at(s),b=new Array(p.length);for(let A=0;A<p.length;A++)b[A]=h.dict.valueOf(p[A]);return b}default:return h.buf[s]}}function o(h,s){switch(h.kind){case"float64":case"int32":return h.values[s];case"bitset":return(h.values[s>>3]&1<<(s&7))!==0;case"dictionary":return(h.table||[])[h.values[s]];case"multi":{const p=h.offsets[s],b=h.offsets[s+1],A=h.table||[],k=new Array(b-p);for(let y=p;y<b;y++)k[y-p]=A[h.values[y]];return k}default:return h.values[s]}}class m{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#b=0;#w=0;#O=null;#y=null;#j=!1;constructor(s,p){this.#e=s.id;const b=n.has(s.kind)?s.kind:"object";s.kind&&!n.has(s.kind)&&F(`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:$(s.field||s.id),this.#h=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.#j?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#P().values}get presence(){return this.#j||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#j||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#j||!this.#h||this.kind!=="object")return null;const s=this.values,p=this.#i.physical();if(!s||p===0)return null;if(this.#f===null){if(typeof s[0]!="string")return null;const b=new v(this.#k());return b.build(s,p),b.version=this.#w,this.#f=b,this.#m=this.#w,b.capped?null:b}return this.#f.length<p&&this.#f.append(s,this.#f.length,p-this.#f.length),this.#f.version=this.#w,this.#m=this.#w,this.#f.capped?null:this.#f}#k(){return this.#p}#C(){this.#f=null,this.#m=-1}get offsets(){return this.#j||!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.#j&&!(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.#j||(this.#l?this.#E(s,p):this.#O.set(s,p===void 0?null:p),this.#f&&this.#C(),this.#w++)}read(s){return this.#o(s)}appendColumn(s,p,b){if(this.#j||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 j=0;j<b;j++){const x=A(s[j]);if(typeof x=="number"){k&&y.set(p+j),R[p+j]=x;continue}const E=x==null;k?y.assign(p+j,!E):E&&(S=!0),R[p+j]=E?NaN:r(x)}break}case"int32":{const R=this.#a;for(let j=0;j<b;j++){const x=A(s[j]),E=x==null;k?y.assign(p+j,!E):E&&(S=!0),R[p+j]=E?0:i(x)}break}case"bitset":{const R=this.#u;for(let j=0;j<b;j++){const x=A(s[j]),E=x==null;k?y.assign(p+j,!E):E&&(S=!0),R.assign(p+j,!E&&!!x)}break}case"dictionary":{const R=this.#a,j=this.#d;for(let x=0;x<b;x++){const E=A(s[x]),T=E==null;k?y.assign(p+x,!T):T&&(S=!0),R[p+x]=T?0:j.codeOf(E)}break}case"multi":{const R=this.#c,j=this.#d;for(let x=0;x<b;x++){const E=A(s[x]),T=E==null;k?y.assign(p+x,!T):T&&(S=!0);const L=f(E),P=new Array(L.length);for(let D=0;D<L.length;D++)P[D]=j.codeOf(L[D]);R.write(p+x,P)}break}default:{const R=this.#a;for(let j=0;j<b;j++){const x=A(s[j]),E=x==null;k?y.assign(p+j,!E):E&&(S=!0),R[p+j]=E?null:x}break}}S&&F(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,p,b),this.#f.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(s,p,b){if(this.#j||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 j=s.values,x=this.#a,E=A;for(let T=0;T<b;T++){if(E&&(k&&(k[T>>3]&1<<(T&7))===0)){x[p+T]=0;continue}x[p+T]=R[j[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 j=s.values,x=s.offsets;for(let E=0;E<b;E++){const T=x[E],L=x[E+1],P=new Array(L-T);for(let D=T;D<L;D++)P[D-T]=R[j[D]]??0;this.#c.write(p+E,P)}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:o(s,S))}this.#w++}touch(){this.#w++}columnarise(s,p){if(this.#l||this.#j)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.#j||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.#j||!n.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:u(p,k))}return this.#C(),this.#w++,!0}compact(s,p,b){if(!this.#j){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.#j||(this.#j=!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.#f=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 H(this.#s??[]);break;case"multi":this.#c=new z({rows:p,values:p}),this.#d=this.#d??new H(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&&F(`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:r(p);break;case"int32":this.#a[s]=b?0:i(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=f(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;#f;#h;#p=!1;constructor(s,p={}){this.#e=Array.isArray(s)?s:[],this.#f=Math.max(1,p.initialCapacity??l),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??d:0,this.#h=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)){F(`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){F(`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.#h)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.#f;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.#f;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 $}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const Q=64,F=8;function B(W){let H=Q;for(;H<W;)H*=2;return H}class ${#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(H={}){this.#n=H.limit??F}get bytes(){return this.#r}mask(H){const U=new Uint8Array(this.#i(H),0,H);return U.fill(0),U}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const U=H.buffer;if(!this.#t.has(U))return!1;this.#t.delete(U),this.#o.released++;const z=U.byteLength;let w=this.#e.get(z);return w||this.#e.set(z,w=[]),w.length>=this.#n||(w.push(U),this.#r+=z),!0}releaseAll(H){for(const U of H)this.release(U)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const U=B(H),z=this.#e.get(U);this.#o.acquired++;let w;return z&&z.length?(w=z.pop(),this.#r-=U,this.#o.reused++):w=new ArrayBuffer(U),this.#t.add(w),w}}function _(){return X??=new $,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 F}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return $}}),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 F(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!F(X[W]))return!1;return!0}function $(X,W){const H=X.col!==void 0?X.col:X.handle&&X.handle.id,U=X.locale!==void 0?X.locale:W;return{col:H,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(U)}}function _(X,W){const H=X||[],U=new Array(H.length);for(let z=0;z<H.length;z++)U[z]=$(H[z],W);return U}}),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 H}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return U}}),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 v}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),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"),F=Q.presenceReader,B=Q.valueReader,$=Q.dictSize,_=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),W=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,U=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 v(k){const y=k.values,S=k.kind;if((S==="float64"||S==="int32")&&y)return j=>y[j];const R=B(k);return j=>g(R(j))}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 l(k,y,S,R=U){if(!k)return{cardinality:0,exact:!0};if(k.dict)return{cardinality:$(k.dict),exact:!0};if(k.kind==="bitset")return{cardinality:2,exact:!0};const j=B(k),x=y?y.length:S,E=new Set;for(let T=0;T<x;T++){const L=j(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 d=36e5,a=864e5;function n(k,y=H){const S=Number.isFinite(k)&&k>0?k:0,R=Math.max(1,y)*2;return S/d<=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 r(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 i(k,y,S){const R=v(k),j=F(k),x=y?y.length:S;let E=1/0,T=-1/0,L=0,P=0;for(let D=0;D<x;D++){const I=y?y[D]:D;if(j&&!j(I)){L++;continue}const C=R(I);if(!Number.isFinite(C)){L++;continue}C<E&&(E=C),C>T&&(T=C),P++}return{min:E,max:T,nulls:L,finite:P}}function f(k,y,S,R){const j=v(k),x=F(k),E=y?y.length:S,T=E>R?E/R:1,L=[];for(let D=0;D<E;D+=T){const I=y?y[Math.floor(D)]:Math.floor(D);if(x&&!x(I))continue;const C=j(I);Number.isFinite(C)&&L.push(C)}const P=Float64Array.from(L);return P.sort(),P}function u(k,y,S,R={}){const j=R.kind||w(k,R.type);return j==="none"||!k?{kind:"none",buckets:[],suppressed:"type"}:j==="boolean"?o(k,y,S):j==="category"?m(k,y,S,R):c(k,y,S,j,R)}function o(k,y,S){const R=F(k);let j=0;if(R){const E=y?y.length:S;for(let T=0;T<E;T++)R(y?y[T]:T)||j++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return j>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function m(k,y,S,R){const j=R.cardinalityLimit??U,{cardinality:x}=l(k,y,S,j);if(x>j&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const E=B(k),T=y?y.length:S,L=new Map;let P=0;for(let N=0;N<T;N++){const G=E(y?y[N]:N);if(G==null||G===""){P++;continue}if(Array.isArray(G)){if(!G.length){P++;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 I=0,C=0;if(D.length>j){C=D.length-j;for(let N=j;N<D.length;N++)I+=D[N][1];D=D.slice(0,j)}const O=D.map(([N])=>({value:N,label:String(N)}));return I>0&&O.push({remainder:!0,label:`Other (${C} values)`}),P>0&&O.push({null:!0,label:"Empty"}),{kind:"category",buckets:O,cardinality:x}}function c(k,y,S,R,j){const{min:x,max:E,nulls:T,finite:L}=i(k,y,S);if(!L)return{kind:R,buckets:T?[{null:!0,label:"Empty"}]:[],empty:!0};const P=Math.max(1,Math.floor(j.buckets||H));let D=[];if(R==="date"){const C=W.includes(j.granularity)?j.granularity:n(E-x,P);let O=t(x,C);for(;O<=E&&D.length<4096;){const N=r(O,C);if(!(N>O))break;D.push({from:O,to:N}),O=N}return{kind:R,buckets:h(D,T),granularity:C}}const I=X.includes(j.strategy)?j.strategy:"equal";if(I==="quantile"){const C=f(k,y,S,z);if(C.length){const O=[C[0]];for(let N=1;N<P;N++){const G=C[Math.min(C.length-1,Math.floor(N/P*C.length))];G>O[O.length-1]&&O.push(G)}O.push(E);for(let N=0;N<O.length-1;N++)D.push({from:O[N],to:O[N+1]})}}else if(I==="log"&&x>0){const C=Math.log10(x),N=(Math.log10(E)-C)/P||1;for(let G=0;G<P;G++)D.push({from:10**(C+G*N),to:10**(C+(G+1)*N)})}if(!D.length){const C=(E-x)/P||1;for(let O=0;O<P;O++)D.push({from:x+O*C,to:x+(O+1)*C})}return D[D.length-1].to=E,{kind:R,buckets:h(D,T),strategy:I,min:x,max:E}}function h(k,y){return y>0?[...k,{null:!0,label:"Empty"}]:k}function s(k,y,S,R,j){const x=R&&R.buckets||[],E=j&&j.length>=x.length?j.subarray(0,x.length):new Uint32Array(x.length);if(E.fill(0),!k||!x.length)return E;const T=x.length-1,L=!!x[T]&&x[T].null===!0,P=y?y.length:S;if(R.kind==="boolean"){const N=B(k);for(let G=0;G<P;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<x.length;Z++)!x[Z].null&&!x[Z].remainder&&N.set(x[Z].value,Z);const G=x.findIndex(Z=>Z.remainder),q=B(k);for(let Z=0;Z<P;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 oe=N.get(ne);oe!==void 0?E[oe]++:G>=0&&E[G]++}continue}const te=N.get(J);te!==void 0?E[te]++:G>=0&&E[G]++}return E}const D=L?x.length-1:x.length,I=new Float64Array(D+1);for(let N=0;N<D;N++)I[N]=x[N].from;I[D]=D?x[D-1].to:0;const C=v(k),O=F(k);for(let N=0;N<P;N++){const G=y?y[N]:N;if(O&&!O(G)){L&&E[T]++;continue}const q=C(G);if(!Number.isFinite(q)){L&&E[T]++;continue}const Z=p(I,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,j=y-1;for(;R<j;){const x=R+j+1>>>1;S>=k[x]?R=x:j=x-1}return R}function b(k,y,S,R={}){const j=R.bounds||u(k,R.boundsIndices??y,S,R);return{bounds:j,counts:s(k,y,S,j)}}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 v}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const F=K("packages/core/src/compute/handle.js").valueComparator,$=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"),H=W.joinPath,U=W.DEFAULT_PATH_SEPARATOR,z=W.DEFAULT_MAX_COLUMNS,w="";function v(r,i,f={}){const u=f.separator||U,o=r||[],m=i instanceof Uint32Array?i:Uint32Array.from(i||[]),c=m.length;if(o.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:h,readers:s}=X(o,m,0),p=new Map,b=[],A=[],k=[];for(let E=0;E<c;E++){const T=m[E],L=h(T);let P=p.get(L);if(P===void 0){P=b.length,p.set(L,P),A.push(L);const D=new Array(s.length);for(let I=0;I<s.length;I++)D[I]=s[I](T);b.push(D),k.push([])}k[P].push(T)}const y=F(f.locale),S=b.map((E,T)=>T);S.sort((E,T)=>{const L=b[E],P=b[T];for(let D=0;D<L.length;D++){const I=g(L[D],P[D],y);if(I!==0)return I}return E-T});const R=new Array(S.length),j=new Array(S.length),x=new Array(S.length);for(let E=0;E<S.length;E++){const T=S[E];R[E]=b[T],j[E]=H(b[T],u),x[E]=Uint32Array.from(k[T])}return{tuples:R,paths:j,buckets:x}}function g(r,i,f){const u=r==null,o=i==null;return u||o?u&&o?0:u?1:-1:f(r,i)}function l(r,i,f){const u=[];for(let o=0;o<r.length;o++)f.has(r[o])&&u.push(r[o]);return Uint32Array.from(u)}function d(r,i,f,u){return{value:i.length?$(r,i,f,u):null,leaves:i,count:i.length}}function a(r){const i=r&&r.opts||{},f=i.separator||U,u=i.totalContext||{locale:i.locale},o=(r.measures||[]).filter(j=>j&&j.handle),m=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),c=v(r.rowHandles||[],m,{...i,separator:f}),h=v(r.columnHandles||[],m,{...i,separator:f}),s=i.maxColumns===void 0?z:i.maxColumns,p=h.paths.length*Math.max(1,o.length),b=new Map;if(s&&p>s)return{rowAxis:c,columnAxis:h,measures:o.map(j=>({colId:j.colId,fn:j.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=h.buckets.map(j=>new Set(j));for(let j=0;j<h.paths.length;j++){const x=h.buckets[j],E=h.paths[j];for(const T of o)y.set(t(E,T.colId),d(T.handle,x,T.fn,u))}for(let j=0;j<c.paths.length;j++){const x=c.buckets[j],E=c.paths[j];for(const T of o)k.set(t(E,T.colId),d(T.handle,x,T.fn,u));for(let T=0;T<h.paths.length;T++){const L=l(x,h.buckets[T],R[T]);if(L.length===0)continue;const P=h.paths[T];for(const D of o)A.set(n(E,P,D.colId),d(D.handle,L,D.fn,u))}}for(const j of o)S.set(j.colId,d(j.handle,m,j.fn,u));return{rowAxis:c,columnAxis:h,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:A,rowMargin:k,columnMargin:y,grand:S,columns:p,error:null}}function n(r,i,f){return`${r}\0${i}\0${f}`}function t(r,i){return`${r}\0${i}`}}),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 l}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const F=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),$=B.isMissing,_=B.valueComparator,W=K("packages/core/src/compute/filter.js").testValue,H="",U="\0";function z(r,i){const f=i.includes(".")?F(r,i):r?.[i];return f===void 0?null:f}function w(r,i,f={}){const u=i||[];let o=r.map((m,c)=>c);if(u.length===0)return o;for(let m=u.length-1;m>=0;m--)o=v(r,o,u[m],f);return o}function v(r,i,f,u){const o=f.locale!==void 0?f.locale:u.locale,m=_(o),c=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],s=[];for(const A of i){const k=z(r[A],f.col);$(k)?s.push(A):h.push(A)}const p=new Map;for(let A=0;A<h.length;A++)p.set(h[A],A);const b=(A,k)=>{const y=z(r[A],f.col),S=z(r[k],f.col);let R;return typeof f.compare=="function"?(R=f.compare(y,S,r[A],r[k],c),c&&(R=-R)):R=c?m(S,y):m(y,S),R!==0?R:p.get(A)-p.get(k)};return h.sort(b),f.nullsFirst?s.concat(h):h.concat(s)}function g(r,i,f={}){const u=[];for(let o=0;o<r.length;o++)l(r[o],i,f,o)&&u.push(o);return u}function l(r,i,f,u){if(!i)return!0;if(Array.isArray(i.conditions)){const o=i.conditions.filter(c=>c!=null);if(o.length===0)return!0;if(i.op==="or")return o.some(c=>l(r,c,f,u));const m=o.every(c=>l(r,c,f,u));return i.op==="not"?!m:m}return i.col===void 0&&typeof f.custom=="function"?!!f.custom(i,r,u):W(z(r,i.col),i,f.locale)}function d(r,i,f,u){const o=f||r.map((s,p)=>p),m=new Map,c=[],h=[];for(const s of o){const p=i.map((k,y)=>{const S=z(r[s],k);return u&&u[y]?u[y](S):S}),b=p.map(k=>k==null?U:String(k)).join(H);let A=m.get(b);A===void 0&&(A=c.length,m.set(b,A),c.push(p),h.push([])),h[A].push(s)}return{keys:c,buckets:h}}function a(r,i,f={}){const u=_(f.locale),o=r.filter(c=>!$(c)),m=o.map(n).filter(c=>c!==null);switch(i){case"count":return r.length;case"countValues":return o.length;case"sum":return m.reduce((c,h)=>c+h,0);case"avg":return o.length===0?null:m.reduce((c,h)=>c+h,0)/o.length;case"min":return o.length===0?null:o.reduce((c,h)=>u(h,c)<0?h:c);case"max":return o.length===0?null:o.reduce((c,h)=>u(h,c)>0?h:c);case"first":return r.length===0?null:t(r[0]);case"last":return r.length===0?null:t(r[r.length-1]);default:return null}}function n(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 i=Number(r);return Number.isNaN(i)?null:i}function t(r){return r===void 0?null:r}}),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 F=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return F.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return F.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return F.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return F.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return F.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 $=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return $.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return $.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 H=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const U=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return U.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return U.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return U.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return U.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return U.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U.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 v=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return v.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return v.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return v.openWindow}});const 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 l=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return l.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return l.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return l.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return l.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return l.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l.anomalyCondition}});const d=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),Le("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return $}}),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 H}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),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 l}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.isFunction,$=32,_="\0";function X(d){return new W(d)}class W{#e;#t;constructor(a){this.#e=B(a&&a.rowKey)?a.rowKey:null;const n=a&&a.config?a.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:$}get keyed(){return this.#e!==null}keyOf(a,n){if(this.#e){const t=this.#e(a);if(t!=null)return String(t)}else F("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${n}`}heightOf(a){return B(this.#t)?Number(this.#t(a))||$:this.#t}leaf(a,n,t=0,r=null){const i={key:this.keyOf(a,n),data:a,level:t,parent:r,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:n};return i.height=this.heightOf(i),i}group(a){const n={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&&(n.totals=a.totals),n.height=this.heightOf(n),n}footer(a){const n={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 n.height=this.heightOf(n),n}detail(a,n){return{key:`${a.key}${_}detail`,data:a.data,level:a.level+1,parent:a,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:a.key}}grandTotal(a,n){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:n,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:a};return t.height=this.heightOf(t),t}skeleton(a,n=0,t=!1){const r={key:`${_}pending${_}${a}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:a,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function H(d,a,n,t){return{key:`${_}pinned${_}${n}${_}${a}`,data:d,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function U(d,a){return new Proxy([],{get(n,t,r){if(t==="length")return d();if(typeof t=="string"){const i=Number(t);if(Number.isInteger(i)&&i>=0)return a(i)}return Reflect.get(n,t,r)},has(n,t){if(typeof t=="string"){const r=Number(t);if(Number.isInteger(r)&&r>=0)return r<d()}return Reflect.has(n,t)}})}function z(d){return d==null?"":String(d)}const w="";function v(d){if(d==null)return w;const a=String(d);return a.startsWith(w)?w+a:a}function g(d){const a=d||[];let n="g";for(let t=0;t<a.length;t++)n+=_+v(a[t]);return n}function l(d){const a=new Array(d.length),n=[];for(let t=0;t<d.length;t++)n.push(d[t]),a[t]=g(n);return a}}),Le("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce;class ${#e;#t;#n;#r=new Map;#o=0;constructor(W,H,U){this.#e=W,this.#t=H,this.#n=F(U)?U:()=>!1}get store(){const W=this.#e.store;return W&&F(W.column)?W:null}invalidate(){this.#o++}handle(W){const H=this.store;if(H){const v=H.column(W);if(v)return v}const U=this.#r.get(W);if(U&&U.builtAt===this.#o)return U.handle;const z=this.#i(W);if(!z)return;if(H&&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 H=this.#e.columns;return H&&F(H.get)?H.get(W):void 0}#s(W){const H=this.#t()||[],U=H.length,z=new Array(U),w=F(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<U;g++)z[g]=H[g]===void 0?void 0:w(H[g]);const v=this.#o;return{id:W.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(g){return z[g]},version:v}}}function _(X,W,H){return new $(X,W,H)}}),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 $}}),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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),$=Object.freeze(["float64"]),_=1e15;function X(z,w){return typeof z!="string"||!B.includes(z)?!1:!!w&&$.includes(w.kind)}function W(z){if(z==null)return null;const w=F(z);return Number.isNaN(w)?null:w}class H{#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 v=0;v<w.length;v++){const g=W(w[v]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,v,g){this.#a();for(let l=0;l<g.length;l++){const d=g[l];if(v&&v(d)===0)continue;const a=w[d];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 v=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-v+w:w-v+this.#t,this.#t=v,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const v=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-v-w:-w-v+this.#t,this.#t=v,this.#r--}update(w,v){if(!this.#s)return!1;const g=W(w),l=W(v);return g===null&&l===null?!0:g!==null&&!Number.isFinite(g)||l!==null&&!Number.isFinite(l)?!1:this.#e==="min"||this.#e==="max"?g===null||l===null?!1:this.#e==="min"?l<this.#o?(this.#o=l,!0):g>this.#o:l>this.#i?(this.#i=l,!0):g<this.#i:Math.abs(this.#t)>_?!1:(g!==null&&this.#c(g),l!==null&&this.#u(l),!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 U=H}),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 $}}),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 H}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return U}}),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 r}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),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 h}}),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 F=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",$="source.where.pageRelative";function _(j,x){!Array.isArray(j)||!j.length||F($,`filters.where (${j.join(", ")}) runs over the rows the ${x} 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(j){const x=(j||{}).config;!x||!x.hostFilter||F(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 H(j,x){F(`${W}:${j}`,`filters.where("${j}") is registered but the ${x} 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 U="source.where.overThreshold";function z(j,x,E,T){!Array.isArray(j)||!j.length||F(`${U}:${x}`,`filters.where (${j.join(", ")}) is not applied to the ${x} 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 v(j){let x=w.get(j);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:j,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(j,x)),x}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function l(j,x){const E=v(x).formatToParts(new Date(j)),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 d(j,x){const E=l(j,x);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(j/1e3)*1e3}function a(j,x,E,T){const L=Date.UTC(j,x-1,E),P=L-d(L,T);return L-d(P,T)}function n(j,x,E){const T=new Date(Date.UTC(j.y,j.m-1,j.d+x));return a(T.getUTCFullYear(),T.getUTCMonth()+1,T.getUTCDate(),E)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(j,x){if(typeof j!="string")return null;const E=j.trim().toLowerCase().replace(/[\s_-]+/g,""),T=/^last(\d*|n)days?$/.exec(E);if(T){const L=T[1]==="n"?"":T[1],P=Number(L||x);return!Number.isFinite(P)||P<=0?null:{kind:"lastNDays",n:Math.floor(P)}}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 i(j,x={}){const E=r(j,x.n);if(!E)return null;const T=x.tz||g(),L=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),P=l(L,T),D=a(P.y,P.m,P.d,T),I=n(P,1,T);let C=D,O=I;switch(E.kind){case"today":break;case"yesterday":C=n(P,-1,T),O=D;break;case"lastNDays":O=x.includeToday?I:D,C=n(P,x.includeToday?-(E.n-1):-E.n,T);break;case"thisWeek":{const N=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,q=(new Date(Date.UTC(P.y,P.m-1,P.d)).getUTCDay()-N+7)%7;C=n(P,-q,T),O=n(P,-q+7,T);break}case"thisMonth":C=a(P.y,P.m,1,T),O=a(P.m===12?P.y+1:P.y,P.m===12?1:P.m+1,1,T);break;case"thisQuarter":case"quarterToDate":{const N=Math.floor((P.m-1)/3)*3+1;C=a(P.y,N,1,T),O=E.kind==="quarterToDate"?I:N===10?a(P.y+1,1,1,T):a(P.y,N+3,1,T);break}case"thisYear":case"yearToDate":C=a(P.y,1,1,T),O=E.kind==="yearToDate"?I:a(P.y+1,1,1,T);break;default:return null}return{from:new Date(C).toISOString(),to:new Date(O).toISOString(),bounds:"[)",tz:T,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function f(j){if(!j||typeof j!="object")return null;const x=j.value;if(x&&typeof x=="object"&&!Array.isArray(x)&&"relative"in x)return{token:String(x.relative),n:typeof x.n=="number"?x.n:void 0};if(j.op==="relative"&&typeof j.value=="string")return{token:j.value,n:void 0};const E=j.meta;return E&&typeof E.relative=="string"&&j.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.n:void 0}:null}function u(){return`Known tokens: ${t.filter(x=>x!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function o(j){const x=f(j);return x?r(x.token,x.n)!==null:!1}function m(j,x={}){const E=f(j);if(!E)return j;const T=i(E.token,{...x,n:E.n});return T?{...j,type:j.type||"date",op:"between",value:[T.from,T.to],bounds:j.bounds||T.bounds,meta:{...j.meta||{},relative:T.relative,tz:T.tz}}:(F(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,u()),j)}function c(j){return!!j&&typeof j=="object"&&Array.isArray(j.conditions)}function h(j,x){if(j){if(c(j)){for(const E of j.conditions)h(E,x);return}x(j)}}function s(j,x){if(!j)return null;if(!c(j))return x(j);const E=j;let T=!1;const L=[];for(const P of E.conditions){const D=s(P,x);D!==P&&(T=!0),D&&L.push(D)}return!T&&L.length===E.conditions.length?j:L.length?{...E,conditions:L}:null}function p(j){if(!j)return null;if(!c(j))return j;const x=j,E=[];for(const T of x.conditions){const L=p(T);L&&E.push(L)}return E.length?{op:x.op,conditions:E}:null}function b(j){const x=p(j);return x?c(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function A(j){const x=(j||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function k(j,x={}){const E=s(j,T=>m(T,x));return b(E)}function y(j){const x=S(j.filters??null);return JSON.stringify([x,j.sort??null,j.quick??"",j.groupBy??null,j.pivotBy??null,R(j.context)])}function S(j){if(!j)return null;if(c(j)){const T=j;return{op:T.op,conditions:T.conditions.map(S)}}const x=j,E=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:f(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:E?`rel:${E}`:x.value??null}}function R(j){if(j==null)return null;try{return JSON.parse(JSON.stringify(j))}catch{return F("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 H}}),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 v}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,$="",_="\0tree:";function X(l,d){return{physical:l,key:d,level:0,children:[],value:void 0}}function W(l,d){const a=[],n=new Map;for(let t=0;t<l.length;t++){const r=l[t],i=d.pathOf(r),f=Array.isArray(i)?i.map(o=>String(o)):[];if(!f.length){const o=X(r,d.keyOf(r));a.push(o);continue}let u=null;for(let o=0;o<f.length;o++){const m=f.slice(0,o+1).join($),c=o===f.length-1;let h=n.get(m);h&&c&&h.physical===-1&&(h.physical=r,h.key=d.keyOf(r)),h||(h=X(c?r:-1,c?d.keyOf(r):_+m),h.level=o,h.value=f[o],n.set(m,h),u?u.children.push(h):a.push(h)),u=h}}return{roots:a,nodes:n}}function H(l,d){const a=new Map,n=[];for(let f=0;f<l.length;f++){const u=l[f],o=d.keyOf(u),m=X(u,o);a.set(o,m);const c=d.parentOf(u);c!=null&&c!==""&&n.push({node:m,parent:String(c)})}let t=null;const r=new Map;for(const{node:f,parent:u}of n){const o=a.get(u);if(o){r.set(f.key,o);continue}d.orphans&&d.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=d.orphans),r.set(f.key,t))}const i=[];for(const f of a.values()){const u=r.get(f.key);u?u.children.push(f):i.push(f)}return t&&t.children.length&&i.push(t),{roots:U(i,a,d.orphans,t),nodes:a}}function U(l,d,a,n){const t=new Set,r=[...l];for(;r.length;){const m=r.pop();if(!t.has(m.key)){t.add(m.key);for(const c of m.children)r.push(c)}}const i=[];for(const m of d.values())t.has(m.key)||i.push(m);if(!i.length)return l;const f=!!a&&a!=="root";B("tree.cycle",`tree.parentKey produced ${i.length} row(s) inside a parent cycle; `+(f?`they are shown under "${a}".`:"they are shown at the root."));for(const m of i)m.children=m.children.filter(c=>t.has(c.key));if(!f)return[...l,...i];let u=n;const o=[...l];return u||(u=X(-1,`${_}orphans`),u.value=a,o.push(u)),u.children.push(...i),o}function z(l){let d=0;const a=(n,t)=>{for(const r of n)r.level=t,t>d&&(d=t),r.children.length&&a(r.children,t+1)};return a(l,0),d}function w(l,d){if(!l||typeof l!="object")return null;const a=l.path,n=l.parentKey,t=F(l.hasChildren)?r=>!!l.hasChildren(d.dataAt(r)):null;if(F(a))return{mode:"path",pathOf:r=>a(d.dataAt(r)),keyOf:d.keyOf,declaresChildren:t};if(n!=null){const r=F(n)?n:i=>i?.[n];return{mode:"parentKey",parentOf:i=>r(d.dataAt(i)),keyOf:d.keyOf,orphans:l.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function v(l,d){const a=d.mode==="path"?W(l,d):H(l,d),n=z(a.roots);return{...a,depth:n}}function g(l,d){const a=new Map,n=t=>{for(let r=0;r<t.length;r++){const i=t[r];if(i.physical>=0){const f=d?d(i.physical):!1,u=f&&i.children.length===0;a.set(i.physical,{level:i.level,posinset:r+1,setsize:t.length,hasChildren:i.children.length>0||f,lazy:u})}i.children.length&&n(i.children)}};return n(l),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 P}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),F=Q.Lru,B=Q.warnOnce,$=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,H=K("packages/core/src/source/rows.js"),U=H.createRowFactory,z=H.groupKey,w=H.groupPathElement,v=H.groupPrefixKeys,g=H.lazyRowView,d=K("packages/core/src/source/handles.js").createHandleProvider,a=K("packages/core/src/compute/incremental.js"),n=a.RunningTotal,t=a.isIncremental,i=K("packages/core/src/compute/handle.js").presenceReader,f=K("packages/core/src/source/filterwire.js"),u=f.querySignature,o=f.mapConditions,m=f.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),h=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(C){const O=C&&typeof C=="object"?C.reason:null;return typeof O=="string"&&A.includes(O)}const y=Object.freeze([]);function S(C,O){if(!C)return null;const N=O==="grand"?C.grandTotal:C.groupTotal;return N??C.total}function R(C){return!!C&&!C.running}function j(C){if(C)return C.value&&_(C.value.compare)?C.value.compare:_(C.compare)?C.compare:void 0}function x(C){const O=C&&C.dataType;return!O||!_(O.items)?null:{items:O.items,type:C.itemType&&C.itemType.name||"text"}}function E(C){return!!C&&(typeof C=="object"||typeof C=="function")&&_(C.then)}const T=new Uint32Array(0),L=4096;function P(C,O){return new I(C,O)}function D(C,O){if(O==="regex")try{const N=new RegExp(C,"iu");return G=>N.test(G)}catch{return N=>N.includes(C)}if(O==="fuzzy"){const N=[...C].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(O==="words"){const N=C.split(/\s+/).filter(Boolean);return N.length?G=>N.every(q=>G.includes(q)):()=>!0}return N=>N.includes(C)}class I{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#f=new Map;#h;#p=null;#m=I.#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;#j=[];#k=new Map;#C=-1;#S=[];#E=null;#T=null;#P=null;#M=null;#N=null;#$=null;#z=null;#V=null;#B=Symbol("unset");#L=new Map;#I=null;get#D(){return this.#m.slots}set#D(O){this.#m.slots=O}get#_(){return this.#m.inlineLeaves}set#_(O){this.#m.inlineLeaves=O}get#X(){return this.#m.groupHeadings}set#X(O){this.#m.groupHeadings=O}get#ue(){return this.#m.unnumbered}set#ue(O){this.#m.unnumbered=O}get#se(){return this.#m.pivot}set#se(O){this.#m.pivot=O}constructor(O,N){this.#t=O||{mode:"memory"},this.#e=N||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=U(this.#e),this.#s=d(this.#e,()=>this.#n,()=>this.#r),this.#h=new F(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 O=this.#ae();return O?O.length:this.#D.length}#ae(){const O=Number(this.#G("pageSize",0))||0;if(O<=0)return null;const N=this.#D.length,G=Math.max(1,Math.ceil(N/O)),Z=Math.min(Math.max(0,Number(this.#G("page",0))||0),G-1)*O;return{offset:Z,length:Math.max(0,Math.min(O,N-Z))}}pageInfo(){this.#Z();const O=Number(this.#G("pageSize",0))||0,N=this.#D.length;if(O<=0)return{page:0,pageSize:0,total:N,pageCount:1};const G=Math.max(1,Math.ceil(N/O));return{page:Math.min(Math.max(0,Number(this.#G("page",0))||0),G-1),pageSize:O,total:N,pageCount:G}}totalCount(){return this.#Ie().length}matchCount(){return this.#Z(),this.#m.matchCount}at(O){this.#Z();const N=this.#ae();if(N)return O<0||O>=N.length?void 0:this.#qe(N.offset+O,O);if(!(O<0||O>=this.#D.length))return this.#qe(O,O)}byKey(O){this.#Z(),this.#p||this.#J();const N=this.#p.get(O);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===O)return this.#qe(G)}}loaded(O){return O>=0&&O<this.count()}hint(O,N){}display(){return this.#Z(),this.#I||(this.#I=this.#Lt()),this.#I}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(O){const N=b.indexOf(O);N<0&&$(`unknown pipeline stage "${O}"; 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(O){const N=[],G={added:[],updated:[],removed:[],rejected:N};if(!O)return G;let q=!1;const Z=new Set;if(O.remove&&O.remove.length)for(const J of O.remove){const te=this.#Y(J);if(te===void 0){N.push({operation:"remove",id:this.#me(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#Ne(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#h.delete(te),this.#L.delete(te),q=!0}if(O.update&&O.update.length){const J=this.#O.size||this.#ot()?this.#ut():null,te=this.#k.size?this.#ht():null,ne=te&&te.length?this.#ut():null;for(const oe of O.update){const le=this.#Y(oe);if(le===void 0){N.push({operation:"update",id:this.#te(oe),reason:"unknown-id"});continue}const ae=this.#r?this.#o&&this.#o.has(le)?this.#o.get(le):this.#Ne(le):this.#n[le],se=W(ae,oe);for(const ee of this.#q(ae,se))Z.add(ee);if(this.#r||(this.#n[le]=se),J&&this.#Ct(J,le,ae,se),ne&&this.#et(te,ne,le,ae,se),this.#p){const ee=this.#i.keyOf(ae,le),ie=this.#i.keyOf(se,le);ee!==ie&&(this.#p.delete(ee),this.#p.set(ie,le))}this.#h.delete(le),this.#L.delete(le),G.updated.push(this.#Ee(le))}}if(O.add&&O.add.length&&this.#r){typeof O.at=="number"&&O.at<this.#at()&&(this.#h.clear(),this.#L.clear()),this.#p=null;for(const J of O.add){const te=this.#H(this.#te(J));te!==void 0&&G.added.push(this.#Ee(te))}q=!0}else if(O.add&&O.add.length){const J=typeof O.at=="number"?O.at:this.#n.length,te=this.#n.length;let ne=O.add===this.#n?O.add.slice():O.add;if(this.#i.keyed){const oe=[];for(const le of ne){const ae=this.#te(le);if(this.#Y(ae)!==void 0){N.push({operation:"add",id:ae,reason:"duplicate-id"});continue}oe.push(le)}oe.length!==ne.length&&(ne=oe)}if(!ne.length)return G;if(J>=te)for(let oe=0;oe<ne.length;oe++)this.#n.push(ne[oe]);else this.#n.splice(J,0,...ne),this.#h.clear(),this.#L.clear();for(let oe=0;oe<ne.length;oe++)G.added.push(this.#Ee(J>=te?te+oe:J+oe));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.#He("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(O){this.#Z();const N=this.#X;if(!N.length||!Number.isInteger(O)||O<0)return y;let G=0,q=N.length-1,Z=-1;for(;G<=q;){const te=G+q>>1;N[te].at<=O?(Z=te,G=te+1):q=te-1}if(Z<0)return y;const J=[];for(let te=N[Z].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(O){this.#Z();const N=this.#ue;if(!N.length||!Number.isInteger(O)||O<0)return 0;let G=0,q=N.length-1,Z=-1;for(;G<=q;){const J=G+q>>1;N[J].at<=O?(Z=J,G=J+1):q=J-1}return Z+1}moveRow(O,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(O)||!Number.isInteger(N)||O<0||O>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,N));if(q===O)return!1;const[Z]=G.splice(O,1);return G.splice(q,0,Z),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#L.clear(),this.#xe(),this.#s.invalidate(),this.#I=null,this.invalidate("filter"),this.#He("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(O){this.#ge(),this.#u++,this.#c++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter"),this.#He("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#h.clear(),this.#L.clear(),this.#p=null,this.#D=[],this.#_=null,this.#I=null,this.#xe();for(const O of b)this.#l.set(O,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:O}of this.#b.values())try{O.abort()}catch{}this.#b.clear()}setRows(O){this.#n=O||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#L.clear(),this.#h.clear(),this.#xe(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(O){this.#o=O||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#L.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const O=this.#e.store;if(!O||!_(O.source))return this.#n;const N=O.physical||0,G=new Array(N);for(let q=0;q<N;q++)G[q]=O.live&&!O.live(q)?void 0:O.source(q);return G}#Te(){const O=this.#G("detail",null);return!O||!_(O.isOpen)||O.inline===!1?null:O}#Se(){const O=(this.#e.config||{}).tree;return this.#B!==O&&(this.#B=O,this.#V=s(O,{dataAt:N=>this.#Ne(N),keyOf:N=>this.#i.keyOf(this.#Ne(N),N)})),this.#V}#re(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#re())return null;this.#Z();const O=this.#m.grand;return O?this.#i.grandTotal(O,this.#tt(this.#m.grandLeaves)):null}pivot(){return this.#Z(),this.#se}pivotMatrix(){this.#Z();const O=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(te=>({colId:te.id,handle:this.#s.handle(te.id),fn:S(te,"group")})).filter(te=>te.handle&&te.fn),J=this.#e.config||{};return N({rowHandles:G.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Z,leaves:O||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(O){const N=[];if(!O)return N;for(let G=0;G<O.length;G++){const q=this.#Ee(O[G]);q&&q.key!=null&&N.push(String(q.key))}return N}leavesOf(O){this.#Z();const N=this.#l.get("group"),G=N&&N.result;if(!G||!G.nodes)return[];const q=G.nodes.get(O);if(!q)return[];const Z=[],J=te=>{const ne=te.row&&te.row.children;if(ne&&ne.length){for(const oe of ne){const le=G.nodes.get(oe.key);le&&J(le)}return}if(te.leaves)for(let oe=0;oe<te.leaves.length;oe++)Z.push(this.#Ee(te.leaves[oe]))};return J(q),Z}#me(O){return typeof O=="string"?O:this.#te(O)}#te(O){try{return this.#i.keyOf(O,-1)}catch{return"(unkeyed)"}}#Y(O){if(typeof O=="string")return this.#H(O);if(this.#i.keyed){const G=this.#i.keyOf(O,-1),q=this.#H(G);if(q!==void 0)return q}if(this.#r)return;const N=this.#n.indexOf(O);return N>=0?N:void 0}#H(O){return this.#p||this.#J(),this.#p.get(O)}#J(){this.#p=new Map;const O=this.#at(),N=this.#e.store,G=N&&_(N.live)?q=>N.live(q):null;for(let q=0;q<O;q++){if(G&&!G(q))continue;const Z=this.#Ne(q);Z!==void 0&&this.#p.set(this.#i.keyOf(Z,q),q)}}#q(O,N){const G=[];for(const q of this.#ie())this.#ze(q)&&this.#je(q,O,N,new Set)&&G.push(q);return G}#je(O,N,G,q){if(q.has(O))return!1;q.add(O);const Z=this.#ze(O);if(!Z)return!1;const J=Z.value&&Z.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#je(String(te),N,G,q)):_(Z.getValue)?!Object.is(Z.getValue(N),Z.getValue(G)):!1}#ie(){const O=new Set;for(const G of this.#G("sort",[]))O.add(G.col);for(const G of this.#G("groupBy",[]))O.add(G);const N=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(N);return}G.col&&O.add(G.col)}};return N(this.#G("filters",null)),[...O]}#ne(O){if(!O.size)return!1;if(this.#G("quick",""))return!0;for(const N of this.#ie())if(O.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 O=this.#ce("filter",()=>this.#K(),()=>this.#ye()),N=this.#pe(O),G=this.#ce("group",()=>this.#Be(),()=>this.#We(N)),q=this.#ce("total",()=>this.#Ge(),()=>this.#Fe(G));this.#ce("pivot",()=>this.#Ke(),()=>this.#Ve(G)),this.#ce("flatten",()=>this.#Ae(),()=>this.#st(G)),this.#de(G,q)}#pe(O){const N=this.#l.get("sort"),G=this.#he();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(O)?(this.#le(O,G),N.result):this.#ce("sort",()=>G,()=>this.#Pe(O))}#fe(){if(this.#w===null){const O=this.#e.pipelineWorker,N=_(O)?O():null;this.#w=N||!1}return this.#w||null}#oe(){const O=this.#G("sort",[]);if(!Array.isArray(O)||!O.length)return null;const N=(this.#e.config||{}).locale,G=[],q=[];for(const Z of O){const J=this.#ze(Z.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const te=this.#s.handle(Z.col);if(!te)return null;G.push({col:Z.col,descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:N}),q.push(te)}return G.length?{entries:G,handles:q,locale:N}:null}#we(O){if(this.#v())return!1;const N=this.#fe();if(!N)return!1;const G=Number(N.threshold);return Number.isFinite(G)&&O.length<G?!1:!!this.#oe()}#le(O,N){const G=this.#fe(),q=G&&this.#oe();if(!q){this.#ce("sort",()=>N,()=>this.#Pe(O));return}const Z=new AbortController;this.#b.set("sort",{key:N,controller:Z});const J=q.entries.length===1?G.sortColumn(q.handles[0],O,{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((te,ne)=>({...te,handle:q.handles[ne]})),O,{signal:Z.signal,key:"sort"});if(!E(J)){this.#b.delete("sort"),this.#ce("sort",()=>N,()=>J);return}J.then(te=>this.#U(N,te),te=>this.#F("sort",N,te))}#U(O,N){const G=this.#b.get("sort");if(!(!G||G.key!==O)){if(this.#he()!==O){this.#b.delete("sort");return}this.#b.delete("sort"),this.#ce("sort",()=>O,()=>N),this.#I=null,this.#Z(),this.#He("model:changed",{reason:A[0]})}}#F(O,N,G){const q=this.#b.get(O);if(!(!q||q.key!==N)&&(this.#b.delete(O),!(G&&G.name==="AbortError")&&O==="sort"&&this.#he()===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.#He("model:changed",{reason:A[1]})}}#de(O,N){const G=O&&O.leaves?O.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=N&&N.grand||null,this.#m.grandLeaves=O&&O.leaves?O.leaves.length:0,this.#m.groupLeaves=O&&O.leaves?O.leaves:null}#ce(O,N,G){const q=this.#l.get(O),Z=N();return q.computed&&q.key===Z||(q.result=G(),q.key=Z,q.computed=!0,q.id++,O==="flatten"&&(this.#I=null)),q.result}#R(O){return this.#l.get(O).id}#K(){const O=(this.#e.config||{}).hostFilter,N=O&&_(O.active)&&O.active()?1:0,G=this.#G("where",null),q=G?G.version:0,Z=this.#bt("filter.sig",`${this.#ct()}`,()=>u({filters:this.#G("filters",null),quick:this.#G("quick",""),quickMode:this.#G("quickMode","contains")}));return`${this.#c}|${Z}|${N}|${q}`}#he(){const O=this.#v();return`${this.#R("filter")}|${JSON.stringify(this.#G("sort",[]))}`+(O?`|manual:${O.version}`:"")}#v(){const O=this.#G("rowOrder",null);return O&&Array.isArray(O.keys)?O:null}#ve(O,N){this.#p||this.#J();const G=this.#p,q=this.#at(),Z=N.keys.length,J=new Float64Array(q);for(let te=0;te<q;te++)J[te]=Z+te;for(let te=0;te<Z;te++){const ne=G.get(N.keys[te]);ne!==void 0&&(J[ne]=te)}return Uint32Array.from(O).sort((te,ne)=>J[te]-J[ne])}orderedKeys(){this.#p||this.#J();const O=this.#p,N=new Map;for(const[te,ne]of O)N.set(ne,te);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 te=0;te<Z.length;te++)J[te]=N.get(Z[te]);return J}#Be(){const O=this.#G("pivotBy",[]).length>0?"p":"u";return`${this.#R("sort")}|${JSON.stringify(this.#G("groupBy",[]))}|${O}`}#Ge(){const O=this.#Ue()?"f":"a",N=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#R("group")}|${JSON.stringify(this.#G("totals",[]))}|${O}${N}|${this.#u}`}#Ke(){return`${this.#R("group")}|${JSON.stringify(this.#G("pivotBy",[]))}`}#Ae(){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 O=this.#G("groupBy",[]);return Array.isArray(O)&&O.length>0}stageState(){const O=[];for(const[N,G]of this.#l){const q=G.result;O.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 O}facetIndices(O){return this.#ye(O||null)}facetRows(O){const N=this.facetIndices(O),G=[];for(let q=0;q<N.length;q++){const Z=this.#Ee(N[q]);Z&&G.push(Z)}return G}invalidateRows(){this.#h.clear(),this.#L.clear(),this.#I=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ie()}filteredIndices(){const O=this.#l.get("filter");if(O&&O.computed&&O.key===this.#K())return O.result||this.#Ie();this.#Z();const N=this.#l.get("filter");return(N&&N.computed?N.result:null)||this.#Ie()}unfilteredRows(){const O=this.#Ie(),N=[];for(let G=0;G<O.length;G++){const q=this.#Ee(O[G]);q&&N.push(q)}return N}#ye(O=null){const N=this.#Ie(),G=this.#G("filters",null),q=O?this.#De("pruneColumn")(G,O):G,Z=this.#Ft(q),J=String(this.#G("quick","")||"").trim().toLowerCase(),te=J?D(J,String(this.#G("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,oe=!!(ne&&_(ne.active)&&ne.active()),le=this.#G("where",null),ae=!!(le&&le.active);if(!Z&&!J&&!oe&&!ae)return N;let se=null;Z&&(se=this.#De("evaluateFilters")(Z,{handle:he=>this.#s.handle(he),count:this.#at(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:he=>x(this.#ze(he))}));const ee=new Uint32Array(N.length);let ie=0;for(let ce=0;ce<N.length;ce++){const he=N[ce];if(!(se&&!se[he])&&!(te&&!this.#nt(he,te))){if(oe||ae){const ge=this.#Ee(he);if(oe&&!ne.passes(ge)||ae&&!le.passes(ge.data,ge.key))continue}ee[ie++]=he}}if(se){const ce=(this.#e.compute||{}).releaseMask;_(ce)&&ce({pool:this.#e.pool},se)}return ee.subarray(0,ie)}handleFor(O){return this.#s.handle(O)}#Pe(O){const N=this.#v();if(N)return this.#ve(O,N);const G=this.#G("sort",[]).filter(J=>{const te=this.#ze(J.col);return!te||!te.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 O;const q=(this.#e.config||{}).locale;if(G.length===1){const J=G[0],te=this.#s.handle(J.col);if(!te)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),O;const ne=this.#ze(J.col);return this.#De("sortColumn")(te,O,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:j(ne)})}const Z=[];for(const J of G){const te=this.#s.handle(J.col);if(!te){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}Z.push({handle:te,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:j(this.#ze(J.col))})}return Z.length?this.#De("sortMulti")(Z.map(J=>J.handle),Z,O):O}#We(O){const N=this.#G("groupBy",[]),G=this.#Se();if(G&&!N.length){const ce=h(O,G);return this.#$=p(ce.roots,G.declaresChildren),{roots:null,leaves:O,nodes:new Map,tree:ce}}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:O,nodes:new Map};const q=(this.#e.config||{}).timeZone,Z=[],J=[];let te=!1;for(const ce of N){const he=this.#s.handle(ce);if(!he){B(`source.group.${ce}`,`grouping ignores unknown column "${ce}".`);continue}Z.push(he);const ge=this.#ze(ce),Ee=ge&&ge.dataType;if(Ee&&_(Ee.groupProjector)){const ye=ge.typeOptions&&ge.typeOptions.timeZone||q||void 0,Ae=Ee.groupProjector(ge,ye);J.push(Ae||null),Ae&&(te=!0)}else J.push(null)}if(!Z.length)return{roots:null,leaves:O,nodes:new Map};const{keys:ne,buckets:oe}=this.#De("groupByColumns")(Z,O,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),le=this.#G("pivotBy",[]).length>0,ae=[],se=new Map;for(let ce=0;ce<oe.length;ce++){const he=ne[ce];let ge=null;const Ee=[];for(let ye=0;ye<he.length;ye++){Ee.push(w(he[ye]));const Ae=z(Ee),pe=ye===he.length-1;let we=se.get(Ae);if(!we){const be=this.#i.group({path:[...Ee],column:N[ye],value:he[ye],level:ye,parent:ge,expanded:le&&pe?!1:this.#gt(Ae,{key:Ae,column:N[ye],value:he[ye],level:ye,path:[...Ee]}),hasChildren:!(le&&pe)});we={row:be,leaves:null},se.set(Ae,we),ge?ge.children.push(be):ae.push(be)}we.row.leafCount+=oe[ce].length,ye===he.length-1&&(we.leaves=oe[ce]),ge=we.row}}const ee=this.#G("sort",[])||[],ie=(ce,he)=>{if(!ce||ce.length<2){if(ce)for(const Ae of ce)ie(Ae.children,he+1);return}const ge=N[he],Ee=ee.find(Ae=>Ae.col===ge),ye=Ee&&Ee.dir==="desc"?-1:1;ce.sort((Ae,pe)=>ye*X(Ae.groupValue,pe.groupValue));for(const Ae of ce)ie(Ae.children,he+1)};return ie(ae,0),{roots:ae,leaves:O,nodes:se,keys:ne,buckets:oe}}#_e(O,N){const G=new Map,q=new Map,Z=J=>{const te=J.physical>=0?[J.physical]:[];for(const ne of J.children)te.push(...Z(ne));if(J.children.length){const ne=this.#Ze(N,Uint32Array.from(te),null);J.physical>=0?G.set(J.physical,ne):q.set(J.key,ne)}return te};for(const J of O.roots)Z(J);return{byPhysical:G,byKey:q}}#Fe(O){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(ee=>ee.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(ee=>Z.has(ee.id)):N,te=q?this.#P:null,ne=this.#Ue()?null:this.#A(),oe=this.#be(N),le=ee=>{const ie=O.nodes.get(ee.key);let ce=ie&&ie.leaves?ie.leaves:null;if(ee.children&&ee.children.length){const Ee=ee.children.map(le);let ye=0;for(const we of Ee)ye+=we.length;const Ae=new Uint32Array(ye);let pe=0;for(const we of Ee)Ae.set(we,pe),pe+=we.length;ce=Ae}ce=ce||new Uint32Array(0);const he=ne?ne.get(ee.key)||T:ce,ge=this.#ft(ee,Z?J:N,he,oe);return ee.totals=Z?{...ee.totals,...ge}:ge,ce};if(O.roots&&J.length)for(const ee of O.roots)le(ee);if(this.#z=O.tree?this.#_e(O.tree,N):null,this.#T=G,this.#E=this.#ot()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#j.length=0,this.#P=null,{grand:null};const se=ne?this.#mt():O.leaves;return this.#P=this.#Je(N,se,Z,te),{grand:this.#P}}#Je(O,N,G,q){const Z={},J=this.#R("group");J!==this.#y&&(this.#$e(),this.#y=J);const te=this.#j;this.#j=[];for(const ne of O){if(!R(ne))continue;const oe=this.#s.handle(ne.id);if(!oe)continue;const le=S(ne,"grand");if(!t(le,oe)){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 ae=this.#O.get(ne.id);if((!ae||ae.fn!==le)&&(ae=new n(le),this.#O.set(ne.id,ae)),ae.valid){let se=!0;for(const ee of te)if(ee.colId===ne.id&&!ae.update(ee.before,ee.after)){se=!1;break}if(se){Z[ne.id]=ae.value();continue}ae.invalidate()}ae.seedColumn(oe.values,i(oe),N),Z[ne.id]=ae.valid?ae.value():this.#Ze([ne],N,null,"grand")[ne.id]}return Z}#be(O){const N=this.#R("group");N!==this.#C&&(this.#k.clear(),this.#C=N);const G=new Map;for(const Z of O){if(!R(Z))continue;const J=this.#s.handle(Z.id),te=S(Z,"group");t(te,J)&&G.set(Z.id,{fn:te})}if(!G.size)return this.#S.length=0,G;const q=this.#S;this.#S=[];for(const Z of q){const{beforeKeys:J,afterKeys:te,colDeltas:ne}=Z,oe=J.length?new Set(J):null,le=te.length?new Set(te):null;for(const{colId:ae,before:se,after:ee}of ne)if(G.has(ae)){for(const ie of J)le&&le.has(ie)||this.#W(ie,ae,se,null);for(const ie of te)oe&&oe.has(ie)||this.#W(ie,ae,null,ee);for(const ie of J)le&&!le.has(ie)||this.#W(ie,ae,se,ee)}}return G}#W(O,N,G,q){const Z=this.#k.get(O),J=Z&&Z.get(N);!J||!J.valid||J.update(G,q)||J.invalidate()}#ft(O,N,G,q){if(!q||!q.size)return this.#Ze(N,G,O);const Z={};let J=null,te=this.#k.get(O.key);for(const ne of N){const oe=q.get(ne.id);if(!oe){(J||(J=[])).push(ne);continue}const le=this.#s.handle(ne.id);if(!le)continue;te||(te=new Map,this.#k.set(O.key,te));let ae=te.get(ne.id);if((!ae||ae.fn!==oe.fn)&&(ae=new n(oe.fn),te.set(ne.id,ae)),ae.valid||ae.seedColumn(le.values,i(le),G),ae.valid){Z[ne.id]=ae.value();continue}(J||(J=[])).push(ne)}return J&&Object.assign(Z,this.#Ze(J,G,O)),Z}#Ct(O,N,G,q){const Z=!this.#Ue()||this.#it(N);for(const J of O){const te=J.getValue;if(!_(te))continue;const ne=te(G),oe=te(q);Object.is(ne,oe)||(this.#E&&this.#E.add(J.id),Z&&this.#O.has(J.id)&&this.#j.push({colId:J.id,before:ne,after:oe}))}}#ht(){const O=this.#G("groupBy",[]),N=[];for(const G of O){const q=this.#ze(G);q&&N.push(q)}return N}#pt(O,N){const G=new Array(O.length);for(let q=0;q<O.length;q++){const Z=O[q].getValue;G[q]=w(_(Z)?Z(N):void 0)}return G}#et(O,N,G,q,Z){if(this.#Ue()&&!this.#it(G))return;const J=v(this.#pt(O,q)),te=v(this.#pt(O,Z)),ne=J.length!==te.length||J.some((le,ae)=>le!==te[ae]),oe=[];for(const le of N){const ae=le.getValue;if(!_(ae))continue;const se=ae(q),ee=ae(Z);!ne&&Object.is(se,ee)||oe.push({colId:le.id,before:se,after:ee})}!oe.length&&!ne||this.#S.push({beforeKeys:J,afterKeys:te,colDeltas:oe})}#it(O){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,te=G[J];if(te===O)return!0;te<O?q=J+1:Z=J-1}return!1}#Ue(){return(this.#e.config||{}).totalFilteredOnly!==!1}#tt(O){return this.#Ue()?O:this.#mt().length}#mt(){return(!this.#M||this.#M.version!==this.#c)&&(this.#M={version:this.#c,indices:this.#Ie()}),this.#M.indices}#A(){const O=this.#G("groupBy",[]),N=`${this.#c}|${JSON.stringify(O)}`;if(this.#N&&this.#N.key===N)return this.#N.map;const G=new Map,q=[];for(const Z of O){const J=this.#s.handle(Z);J&&q.push(J)}if(q.length){const Z=this.#mt(),{keys:J,buckets:te}=this.#De("groupByColumns")(q,Z,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let oe=0;oe<te.length;oe++){const le=J[oe],ae=[];for(let se=0;se<le.length;se++){ae.push(w(le[se]));const ee=z(ae);let ie=ne.get(ee);ie||(ie=[],ne.set(ee,ie));for(let ce=0;ce<te[oe].length;ce++)ie.push(te[oe][ce])}}for(const[oe,le]of ne)G.set(oe,Uint32Array.from(le))}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.#j.length=0,this.#y=-1}#Ce(){this.#k.clear(),this.#S.length=0,this.#C=-1}#Ve(O){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,O.leaves,{groups:O.keys&&O.buckets?{keys:O.keys,buckets:O.buckets}:null,totals:Z.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>S(Z.find(te=>te.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#se}#st(O){const N=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Te();if(O.tree)return this.#lt(O,N,q);if(!O.roots&&!q){if(N&&N.grand&&!this.#re()){const le=this.#i.grandTotal(N.grand,this.#tt(O.leaves.length));if(this.#_===O.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=le;else{const ae=Array.from(O.leaves);ae.push(le),this.#D=ae,this.#_=O.leaves}this.#ue=[{at:this.#D.length-1}]}else this.#_=null,this.#D=O.leaves,this.#ue=y;return this.#X=y,this.#D}const Z=[],J=[],te=[],ne=le=>{if(Z.push(le),!q)return;const ae=this.#Ee(le);!ae||!q.isOpen(ae.key)||(ae.master=!0,ae.expanded=!0,te.push({at:Z.length}),Z.push(this.#i.detail(ae,q.heightOf(ae))))};if(!O.roots){for(let le=0;le<O.leaves.length;le++)ne(O.leaves[le]);return N&&N.grand&&!this.#re()&&(te.push({at:Z.length}),Z.push(this.#i.grandTotal(N.grand,this.#tt(O.leaves.length)))),this.#_=null,this.#X=y,this.#ue=te.length?te:y,this.#D=Z,Z}const oe=(le,ae,se)=>{if(le.expanded=le.hasChildren===!1?!1:this.#gt(le.key,{key:le.key,column:le.groupColumn,value:le.groupValue,level:le.level,path:le.groupPath}),le.posinset=ae+1,le.setsize=se,J.push({at:Z.length,row:le}),te.push({at:Z.length}),Z.push(le),!!le.expanded){if(le.children&&le.children.length)for(let ee=0;ee<le.children.length;ee++)oe(le.children[ee],ee,le.children.length);else{const ee=O.nodes.get(le.key),ie=ee&&ee.leaves?ee.leaves:null;if(ie)for(let ce=0;ce<ie.length;ce++)ne(ie[ce])}G&&le.totals&&(te.push({at:Z.length}),Z.push(this.#i.footer(le)))}};for(let le=0;le<O.roots.length;le++)oe(O.roots[le],le,O.roots.length);return N&&N.grand&&!this.#re()&&(te.push({at:Z.length}),Z.push(this.#i.grandTotal(N.grand,this.#tt(O.leaves.length)))),this.#X=J,this.#ue=te,this.#D=Z,Z}#Ie(){const O=this.#e.store;if(O&&_(O.liveIndices))return O.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 O=this.#e.store;return O&&typeof O.physical=="number"?O.physical:this.#n.length}#Ne(O){const N=this.#e.store;return N&&_(N.source)?N.source(O):this.#n[O]}#qe(O,N=O){const G=this.#D[O];if(typeof G!="number")return G.index=N,G;const q=this.#Ee(G);return q.index=N,q}#Ee(O){let N=this.#h.get(O);N||(N=this.#i.leaf(this.#Ne(O),O),this.#h.set(O,N));const G=this.#$?this.#$.get(O):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(O):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(O,N,G){const q=[],Z=[],J=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let oe=ne.physical>=0?1:0;for(const le of ne.children)oe+=J(le);return ne.leafCount=oe,oe},te=ne=>{const oe=this.#gt(ne.key);if(ne.physical>=0){if(q.push(ne.physical),G&&G.isOpen(this.#Ee(ne.physical).key)){const le=this.#Ee(ne.physical);Z.push({at:q.length}),q.push(this.#i.detail(le,G.heightOf(le)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:oe,hasChildren:ne.children.length>0,leafCount:J(ne),totals:this.#z?this.#z.byKey.get(ne.key):void 0}));if(oe)for(const le of ne.children)te(le)};for(const ne of O.tree.roots)te(ne);return N&&N.grand&&!this.#re()&&(Z.push({at:q.length}),q.push(this.#i.grandTotal(N.grand,this.#tt(O.leaves.length)))),this.#_=null,this.#X=y,this.#ue=Z.length?Z:y,this.#D=q,q}#Lt(){return g(()=>this.count(),O=>this.at(O))}#nt(O,N){let G=this.#L.get(O);if(G===void 0){const q=this.#Ne(O),Z=this.#rt(),J=[],te=this.#e.columnHidden;for(const ne of Z){if(ne.quickFilter===!1||_(te)&&te(ne.id))continue;const oe=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,le=oe??(_(ne.formatValue)?ne.formatValue(_(ne.getValue)?ne.getValue(q):void 0):"");le!=null&&le!==""&&J.push(String(le))}G=J.join(" ").toLowerCase(),this.#L.set(O,G)}return N(G)}#ut(){const O=this.#G("totals",[]),N=O&&O.length?new Set(O):null;return this.#rt().filter(G=>N?N.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#Ze(O,N,G,q="group"){const Z={},J=(this.#e.compute||{}).total;for(const te of O){if(!R(te))continue;const ne=this.#s.handle(te.id);if(!ne)continue;const oe=S(te,q);if(oe)if(_(oe)){const le=new Array(N.length);for(let ae=0;ae<N.length;ae++)le[ae]=ne.get(N[ae]);Z[te.id]=oe(le,{row:G,column:te,grid:this.#e.grid||null,context:this.#G("context",null),valueAt:(ae,se)=>{const ee=this.#s.handle(ae);return ee&&se>=0&&se<N.length?ee.get(N[se]):null}})}else _(J)&&(Z[te.id]=J(ne,N,oe))}return Z}#Ft(O){if(!O)return O;const N=this.#e.config||{},G={tz:N.timeZone,weekStartsOn:N.weekStartsOn};return o(O,q=>{const Z=m(q,G),J=this.#ze(Z&&Z.col),te=J&&J.type==="datetime";if(Z&&Z.type)return Z.type==="datetime"&&!Z.timeZone&&J?{...Z,timeZone:N.timeZone||void 0}:Z;if(te)return{...Z,type:"datetime",timeZone:N.timeZone||void 0};const ne=J&&(J.dataType?.base||J.type);return ne?{...Z,type:ne}:Z})}#gt(O,N){const G=this.#G("expanded",null);return G?_(G.has)?G.has(O,N):Array.prototype.includes.call(G,O):!0}#G(O,N){if(O==="context"||!_(this.#e.stateVersion))return this.#Et(O,N);const G=this.#yt(O),q=this.#d.get(O);if(q&&q.version===G)return q.value;const Z=this.#Et(O,N);return this.#d.set(O,{version:G,value:Z}),Z}#Et(O,N){const G=this.#e.state;if(G&&_(G[O])){const q=G[O]();return q??N}return N}#ct(){const O=this.#e.stateVersion;return _(O)?O():0}#St(){const O=this.#e.columnsVersion,N=this.#e.permissionsVersion;return`${_(O)?O():0}|${_(N)?N():0}`}#yt(O){return O==="totals"?this.#St():`${this.#ct()}`}#bt(O,N,G){if(!_(this.#e.stateVersion))return G();const q=this.#f.get(O);if(q&&q.version===N)return q.key;const Z=G();return this.#f.set(O,{version:N,key:Z}),Z}#De(O){const N=(this.#e.compute||{})[O];return _(N)||$(`ctx.compute.${O} is required by the memory source pipeline`),N}#rt(){const O=this.#e.columns;return O&&_(O.all)?O.all():[]}#ze(O){const N=this.#e.columns;return N&&_(N.get)?N.get(O):void 0}#He(O,N){const G=this.#e.emit;_(G)&&G(O,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 F}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class Q extends Error{constructor(W,H="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class F{#e;constructor(W,H,U,z){this.#e=W,this.key=H,this.controller=U,this.signal=U.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="",H="superseded"){const U=this.#e.get(W);U&&!U.signal.aborted&&U.controller.abort(new Q(W,H));const z=new F(this,W,new AbortController,++this.#t);return this.#e.set(W,z),z}tokenFor(W){return this.#e.get(W)}pending(W=""){const H=this.#e.get(W);return!!H&&!H.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",H="superseded"){const U=this.#e.get(W);U&&U.abort(H)}abortAll(W="superseded"){for(const H of[...this.#e.values()])H.abort(W);this.#e.clear()}}function $(){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 F}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return $}});const Q=100,F=32;class B{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class ${#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)||F))}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 H=this.#e.get(X);return H||(H=new B(X)),H.state="pending",H.token=W,H.error=null,this.#i(X,H),H}fill(X,W){const H=this.#e.get(X)||new B(X);H.rows=W,H.state="loaded",H.token=null,this.#i(X,H)}failed(X,W){const H=this.#e.get(X)||new B(X);H.state="error",H.error=W,H.token=null,this.#i(X,H)}delete(X){return this.#e.delete(X)}rowAt(X){const W=this.blockOf(X),H=this.#e.get(W);if(!(!H||H.state!=="loaded"||!H.rows))return this.#i(W,H),H.rows[X-W*this.#t]}rowLoaded(X){const W=this.blockOf(X),H=this.#e.get(W);return!!H&&H.state==="loaded"&&!!H.rows&&X-W*this.#t<H.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 H=W.id*this.#t+W.rows.length;H>X&&(X=H)}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,H]of this.#e){if(this.#e.size-X.length<=this.#n)break;W>=this.#r&&W<=this.#o||H.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(F,B,$,_){const X=Math.floor(Number(F)||0);if(X<=0)return null;const W=Math.max(0,Math.floor(Number(B)||0)),H=Math.max(0,Math.floor(Number($)||0));if(_){const U=Math.max(1,Math.ceil(H/X)),z=Math.min(W,U-1),w=z*X;return{page:z,pageSize:X,offset:w,length:Math.max(0,Math.min(X,H-w)),pageCount:U,total:H}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(H/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 f}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),F=Q.Lru,B=Q.isFunction,$=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,w=U.DEFAULT_PAGE_SIZE,v=U.DEFAULT_MAX_CACHED_PAGES,l=K("packages/core/src/source/rows.js").createRowFactory,d=K("packages/core/src/source/filterwire.js"),a=d.wireFilters,n=d.querySignature,t=d.warnHostFilterNotApplied,i=K("packages/core/src/source/pagewindow.js").pageWindow,f=120;function u(m,c){return new o(m,c)}class o{mode="paged";#e;#t;#n;#r=W();#o;#i;#s=new Map;#l=null;#a=null;#u=!1;#c=0;#d="";#f={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(c,h){this.#e=c||{mode:"paged"},this.#t=h||{},this.#n=new z({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||v}),this.#o=l(this.#t),this.#i=new F(this.#n.pageSize*4),this.#h=_((s,p)=>this.#y(s,p),f),this.#d=this.#E(),B(this.#e.fetch)||$("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 h=this.#b();return{page:0,pageSize:0,total:this.exact()?h: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(),h=i(this.#P("pageSize",0),this.#P("page",0),c,this.exact());if(!h)return this.#g="",null;const s=`${this.#m}:${h.offset}:${h.length}`;if(s!==this.#g&&!this.#p&&(this.#g=s,h.length>0)){const p=h.offset+h.length-1;this.#f={start:h.offset,end:p},this.#y(h.offset,p)}return h}at(c){const h=this.#w();if(h){if(c<0||c>=h.length)return;const s=this.#O(h.offset+c);return s&&(s.index=c),s}return this.#O(c)}#O(c){if(c<0||c>=this.#b())return;const h=this.#i.get(c);if(h&&(h.data!==null||!this.#n.rowLoaded(c)))return h;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 h=this.#s.get(c);return h===void 0?void 0:this.#O(h)}loaded(c){const h=this.#w();return h?c>=0&&c<h.length&&this.#n.rowLoaded(h.offset+c):this.#n.rowLoaded(c)}loadedCount(){this.#C();let c=0;for(const h of this.#n.ids()){if(!this.#n.loaded(h))continue;const s=this.#n.fillOf(h);typeof s=="number"&&(c+=s)}return c}residentRows(){this.#C();const c=this.#w(),h=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<h||S>=s)continue;const R=this.#i.peek(S);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const j=this.#n.rowAt(S);if(j===void 0)continue;const x=this.#o.leaf(j,S);x.index=S,this.#i.set(S,x),this.#s.set(x.key,S),p.push(x)}}return p}hint(c,h){if(this.#p)return;const s=this.#C();let p=Math.max(0,Math.floor(c)),b=Math.max(p,Math.floor(h));const A=this.#w();if(A){if(A.length===0)return;p=A.offset,b=A.offset+A.length-1}this.#f={start:p,end:b},this.#n.protect(p,b);for(const k of this.#n.evict())this.#k(k);this.#h(p,b),s&&this.#h.flush()}#y(c,h){if(this.#p)return;this.#n.protect(c,h);const s=this.#n.blockOf(c),p=this.#n.blockOf(h);for(let b=s;b<=p&&!(this.#l!==null&&b*this.#n.pageSize>=this.#l);b++)this.#n.has(b)||this.#j(b)}apply(c){const h={added:[],updated:[],removed:[]};if(!c)return h;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),h.updated.push(A)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),h}reload(c){this.#S("reload"),this.#h.cancel(),this.hint(this.#f.start,this.#f.end)}destroy(){this.#p=!0,this.#h.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#j(c){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${c}`);this.#n.begin(c,h);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:h.signal});if(!h.current||b!==this.#d||this.#p)return;h.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(h.settle(),H(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:h,end:s}=this.#n.rangeOf(c);for(let p=h;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 n({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,h){const s=this.#t.state;if(s&&B(s[c])){const p=s[c]();return p??h}return h}#M(c,h){const s=this.#t.emit;B(s)&&s(c,h)}}}),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 F}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return $}}),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 H}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});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 F(){const z=new Set;for(const[w,v]of Object.entries(Q))v.pushable&&z.add(w);return z}function B(z,w,v){let g=z.split("%c").join(w);return v!==void 0&&(g=g.split("%w").join(v)),g}function $(z){const w=z||{},v=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[l,d]of Object.entries(w.overrides))(d==="engine"||d==="client")&&(g[l]=d);return{default:v,overrides:g}}function _(z,w){const v=Q[z];if(!v||!v.pushable)return"client";const g=w.overrides[z];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?v.class==="identical"?"engine":"client":"engine"}function X(z,w){const v=$(w),g=[],l=[];for(const d of z||[]){const a=Q[d.fn],n=_(d.fn,v),t={id:d.id,col:d.col,fn:d.fn,class:a?a.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),n==="engine"?g.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",l.push(t))}return{engine:g,client:l,config:v}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(z,w=[]){return(z||[]).every(g=>{if(typeof g=="string")return W.test(g);if(!g||typeof g!="object")return!1;const l=g;return Array.isArray(w)&&w.includes(l.bucket)&&typeof l.col=="string"&&W.test(l.col)&&typeof l.size=="number"&&Number.isFinite(l.size)&&l.size>0})}function U(){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 r}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return u}}),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 x}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/internal/util.js"),F=Q.defaultCompare,B=Q.isFunction,$=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,H=X.warnWherePageRelative,U=X.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),w=z.resolveAggregatePlan,v=z.groupKeysPushable,g=z.STAT_PUSHDOWN,d=K("packages/core/src/source/abort.js").SupersededError,a=1e3;function n(N){const G=N&&N.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new d("","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 r(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 i(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 f(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 u(N){const G={...t,...N||{}};return G.operators=new Set(G.operators||[]),G.mutate=r(G.mutate),G}function o(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 te=N.conditions||[];if(String(N.op)!=="and")return{pushed:null,residual:N};const ne=te.findIndex(le=>!W(le)&&o(le,G));if(ne<0)return{pushed:null,residual:N};const oe=te.filter((le,ae)=>ae!==ne);return{pushed:te[ne],residual:oe.length?{op:"and",conditions:oe}:null}}return o(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N}}if(!W(N))return o(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:o(ne,G))?{pushed:N,residual:null}:{pushed:null,residual:N};const q=[],Z=[];for(const te of N.conditions||[]){if(W(te)){if(G.filter==="flat"){Z.push(te);continue}const ne=m(te,G);ne.pushed&&q.push(ne.pushed),ne.residual&&Z.push(ne.residual);continue}(o(te,G)?q:Z).push(te)}const J=te=>te.length===0?null:te.length===1?te[0]:{op:"and",conditions:te};return{pushed:J(q),residual:J(Z)}}const c="__lattice_leaves";function h(N){return N.aggregates?N.aggregates instanceof Set?N.aggregates:new Set($(N.aggregates)):new Set}function s(N){const G=h(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,te,ne){const oe=Array.isArray(N.groupBy)?N.groupBy:[],le=Array.isArray(N.groupPath)?N.groupPath:[],ae=Array.isArray(N.groupValues)?N.groupValues:null;if(!G.group){const se=s(G);if(se)return se}return v(oe)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Z?J?te?"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":!ae||ae.length!==le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const b="pushdown:pivot-unsupported",A="pushdown:group-unsupported",k=Symbol("lattice.remote.ungroupedLevel");function y(N,G,q,Z,J,te){const ne=Array.isArray(N.pivotBy)?N.pivotBy:[],oe=Array.isArray(N.groupBy)?N.groupBy:[],le=Array.isArray(N.groupPath)?N.groupPath:[],ae=Array.isArray(N.groupValues)?N.groupValues:null;return G.pivot?v(ne)?oe.length&&!v(oe)?"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?te?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ae||ae.length!==le.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function S(N,G,q=!1){const Z=m(N.filters||null,G),J=[];Z.residual&&J.push("filter");const te=N.sort||[],ne=te.length===0||G.sort==="multi"&&te.length>=1||G.sort==="single"&&te.length===1;!ne&&te.length&&J.push("sort");const oe=N.quick?String(N.quick):"",le=!oe||!!G.quick;le||J.push("quick");const ae=N.where&&N.where.active?N.where:null;ae&&J.push("where");const se={filters:Z.residual,sort:ne?null:te,quick:le?"":oe,where:ae},ee=!!q,ie=Array.isArray(N.groupBy)&&N.groupBy.length>0,ce=ie?p(N,G,Z,ne,le,ae,ee):"",he=N.pivotMode!==!1&&Array.isArray(N.pivotBy)&&N.pivotBy.length>0,ge=he?y(N,G,Z,ne,le,ae):"",Ee=he&&ge==="";he&&!Ee&&J.push("pivot");const ye=he?Ee&&ie:ie&&ce==="";ie&&!he&&!ye&&J.push("group");const Ae=(ye||Ee)&&Array.isArray(N.groupValues)?N.groupValues.length:0,pe=ye||he?!1:ee||!!(se.filters||se.sort||se.quick||se.where)||!G.range;return{pushed:{...N,filters:Z.pushed,sort:ne?te:[],quick:le?oe:"",range:pe?null:N.range},residual:se,needsAll:pe,unpushed:J,full:ee,grouped:ye,groupLevel:Ae,groupReason:he?"":ce,pivoted:Ee,pivotReason:ge}}function R(N){const G=Array.isArray(N.totals)?N.totals:[],q=N.totalFns&&typeof N.totalFns=="object"?N.totalFns:{},Z=[],J=[];for(const te of G){const ne=String(te),oe=typeof q[ne]=="string"?q[ne]:null,le=oe?g[oe]:null;oe?!le||!le.pushable||!le.sql?J.push({id:ne,fn:oe,class:le?le.class:"fallback",reason:le&&le.note?le.note:`the pushdown map cannot express "${oe}"`}):le.twoColumn?J.push({id:ne,fn:oe,class:le.class,reason:`"${oe}" reduces two columns, and a grouped request carries no weight column`}):Z.push({id:ne,col:ne,fn:oe,class:le.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 j=Object.freeze({items:N=>N==null?[]:Array.isArray(N)?N:[N]});function x(N,G,q){if(!G)return N;let Z=N;if(G.filters&&B(q.evaluateFilters)){const J=Z,te={count:Z.length,handle:le=>({id:le,get:ae=>i(J[ae],le)}),itemwise:le=>J.some(ae=>Array.isArray(i(ae,le)))?j:null},ne=q.evaluateFilters(G.filters,te),oe=[];for(let le=0;le<Z.length;le++)ne[le]&&oe.push(Z[le]);Z=oe}if(G.where&&G.where.active&&(G.whole||H(G.where.names,"pushdown"),Z=Z.filter(J=>G.where.passes(J))),G.quick){const J=G.quick.toLowerCase();Z=Z.filter(te=>{if(!te||typeof te!="object")return!1;for(const ne of Object.values(te))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(le=>le.col))],te=Z,ne=J.map(le=>({id:le,get:ae=>i(te[ae],le)})),oe=q.sortMulti(ne,G.sort.map(le=>({col:le.col,dir:le.dir})),Uint32Array.from({length:Z.length},(le,ae)=>ae),{});Z=Array.from(oe,le=>te[le])}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 P=5e4;function D(N){return Number.isFinite(N)&&N>=0?N:P}function I(N){return!!N&&B(N.then)}async function C(N){if(!N||N.total!==void 0||!I(N.pendingTotal))return N;const G=await N.pendingTotal,{pendingTotal:q,...Z}=N;return typeof G=="number"?{...Z,total:G}:Z}function O(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=u(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 te=null;const ne=()=>B(G.ready)?(te||(te=Promise.resolve(G.ready()).then(()=>{Object.assign(q,u(G.capabilities))},Ie=>{throw te=null,Ie})),te):null,oe=L(N.fullDataset),le=!!N.allowPartialResults,ae=D(N.whereRowLimit);let se=null;const ee=N.aggregates;let ie=null,ce=null,he=null,ge=null,Ee=null,ye,Ae=null,pe=0,we=null;const be=()=>!oe.enabled||!ie?null:(we!==ie.key&&(pe++,we=ie.key),{rows:ie.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:ve,...Se}=Ie,me=S(Se,q,oe.enabled);if(me.needsAll)return{request:Ie,probe:null};const Pe=E(me.pushed);let Me=null;return(!se||se.key!==Pe)&&(q.total?(n(Ie),Me=await C(await G.execute(me.pushed,Ie)),se={key:Pe,size:Me&&typeof Me.total=="number"?Me.total:null}):se={key:Pe,size:null}),se.size!==null&&se.size<ae?{request:Ie,probe:null}:(U(qe.names,J,se.size,ae),{request:Se,probe:Me})},$e=async(Ie,qe)=>{Ae=null;const ve=R(Ie.pushed);he={engine:ve.engine,client:ve.client,groupBy:Ie.pushed.groupBy},ve.client.length&&_(`source.pushdown.group.totals.${J}.${ve.client.map(Pe=>Pe.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${ve.client.map(Pe=>`"${Pe.id}" (${Pe.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 Se=await G.executeGroupLevel(Ie.pushed,ve.engine,qe)||{};let me=Se.rows||[];return!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),Ge(Se),Se.total===void 0?{rows:me}:{rows:me,total:Se.total}},Ve=new Map,Ye=64,je=async(Ie,qe)=>{Ae=null;const ve=Ie.pushed,Se=ve.groupBy,me=Array.isArray(ve.groupValues)?ve.groupValues:[],Pe=me.length,Me=[...ve.filters?[ve.filters]:[],...Se.slice(0,Pe).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(Pe>=Se.length){const ot={...ve,filters:ze,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},St=await C(await G.execute(ot,qe))||{};let jt=St.rows||[];return!q.range&&qe.range&&(jt=jt.slice(qe.range.start,qe.range.end)),typeof St.total=="number"?{rows:jt,total:St.total}:{rows:jt}}const De=Se[Pe],Oe=R(ve),xe=h(q),Be=Oe.engine.filter(ot=>xe.has(ot.fn)),Je=[...Oe.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}"`})),...Oe.client];he={engine:Be,client:Je,groupBy:Se},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={...ve,filters:ze,range:null},it=JSON.stringify([E(at),me,De,Qe]);let gt=_e>0?Ve.get(it):void 0;if(!gt){for(gt=Promise.resolve(G.executeGroupedAggregates(at,[De],Qe)),Ve.delete(it),Ve.set(it,gt);Ve.size>Ye;)Ve.delete(Ve.keys().next().value);gt.catch(()=>{Ve.get(it)===gt&&Ve.delete(it)})}const wt=await gt||[];n(qe);const dt=ot=>{const St={};for(const jt of Be)St[jt.id]=ot?ot[jt.id]:void 0;return St},At=(ve.sort||[]).find(ot=>ot&&ot.col===De),He=At&&At.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)=>He*F(ot[De],St[De]));if(Pe===0){const ot=wt.find(jt=>jt&&jt.level===0),St=ot?Number(ot.values&&ot.values[c]):NaN;Ge({matchCount:Number.isFinite(St)?St:pt.reduce((jt,ht)=>jt+ht.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"&&(ge=Ie.matchCount,Ee=Ie.grand?{totals:Ie.grand,leafCount:Ie.matchCount}:null,ye===void 0&&B(G.unfilteredCount)&&(ye=null,Promise.resolve(G.unfilteredCount()).then(qe=>{ye=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)=>{Ae=null;const ve=R(Ie.pushed);he={engine:ve.engine,client:ve.client,groupBy:Ie.pushed.groupBy,pivotBy:Ie.pushed.pivotBy},ve.client.length&&_(`source.pushdown.pivot.totals.${J}.${ve.client.map(ze=>ze.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${ve.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 Se=await G.executePivotLevel(Ie.pushed,ve.engine,qe)||{};let me=Se.rows||[];!q.range&&qe.range&&(me=me.slice(qe.range.start,qe.range.end)),Ge(Se);const Pe=Se.pivot&&typeof Se.pivot=="object"?Se.pivot:{},Me={cells:Array.isArray(Pe.cells)?Pe.cells:[],...Array.isArray(Pe.axis)?{axis:Pe.axis}:{}};return Se.total===void 0?{rows:me,pivot:Me}:{rows:me,total:Se.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 ve={key:qe,state:"pending",value:null};return Ae=ve,Ie.then(Se=>(Ae===ve&&(Ae={key:qe,state:"settled",value:typeof Se=="number"?Se:null}),Se),Se=>{throw Ae===ve&&(Ae={key:qe,state:"failed",value:null}),Se})};let ft=0,yt=[];const Ot=()=>ft===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 Se=Ie&&Ie.pivotMode!==!1&&Array.isArray(Ie.pivotBy)&&Ie.pivotBy.length>0?{request:Ie,probe:null}:await Ne(Ie);n(Ie);let me=S(Se.request,q,oe.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(Se.request,{...q,group:!1,aggregates:null},oe.enabled)),me.pivoted&&!B(G.executePivotLevel)&&(me=S(Se.request,{...q,pivot:!1},oe.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(Se.request,{...q,aggregates:null},oe.enabled)),ce=me,me.pivoted)return Ze(me,Ie);if(me.pivotReason&&rt(me.pivotReason),me.grouped)return q.group?$e(me,Ie):je(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=Se.probe||await G.execute(me.pushed,Ie),at=Qe.rows||[];return I(Qe.pendingTotal)&&Qe.total===void 0?ze({rows:at,pendingTotal:st(Qe.pendingTotal,E(me.pushed))}):(Ae=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(!ie||ie.key!==_e){const Qe=await C(await G.execute(me.pushed,Ie));Ae=null;const at=Qe.rows||[];if(me.full){const it=typeof Qe.total=="number"?Math.max(Qe.total,at.length):at.length;if(it>oe.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${it.toLocaleString()} rows, past the configured maxRows of ${oe.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const gt=at.length*T(at[0]);if(gt>oe.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(oe.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Qe.total=="number"&&at.length<Qe.total){const it=!!(me.residual.filters||me.residual.quick||me.residual.sort&&me.residual.sort.length);if(it&&!le)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.`)}ie={key:_e,rows:at,total:typeof Qe.total=="number"?Qe.total:null}}let De=me;if(me.residual.where){const Qe=ie.total??ie.rows.length;if(Qe>=ae){U(me.residual.where.names,J,Qe,ae);const{where:at,...it}=Se.request;De=S(it,q,oe.enabled),ce=De}}const Oe=ie.total!==null&&ie.rows.length>=ie.total,xe=x(ie.rows,{...De.residual,whole:Oe},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,ve)=>{const me=ve&&ve.waitForPage&&Ct&&B(Ct.pageForegroundIdle)?Ct.pageForegroundIdle():Ot();me&&await me;const Pe=ne();Pe&&await Pe;const Me=S(Ie,q,oe.enabled);ce=Me;const ze=w(qe,ee),_e=Array.isArray(Ie.groupBy)?Ie.groupBy:[],De=_e.length>0,Oe=!Me.residual.filters&&!Me.residual.quick,xe=!De||v(_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($(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&&!Oe?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`))),he={engine:Be,client:Je,...De?{groupBy:_e}:{}},{values:at,engine:Be,client:Je,...it!==void 0?{groups:it}:{}}},zt=async Ie=>{ft++;try{return await Tt(Ie)}finally{if(ft--,ft===0&&yt.length){const qe=yt;yt=[];for(const ve of qe)ve()}}},It=f(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 ve={kind:"update",key:String(qe.key),patch:{[qe.colId]:qe.value}};return G.mutate(ve,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 de=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,ke=async Ie=>{const qe=ne();qe&&await qe;const{range:ve,signal:Se,export:me,...Pe}=Ie||{},Me={...Pe,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:S(Me,q,oe.enabled),signal:Se}};async function*Re(Ie,qe={}){const{plan:ve,signal:Se}=await ke(Ie),me=Math.max(1,Math.floor(Number(qe.pageSize))||5e3),Pe={signal:Se,stream:!0};if(!ve.needsAll)for(let _e=0;;_e+=me){n(Pe);const De=await G.execute({...ve.pushed,range:{start:_e,end:_e+me}},Pe);De&&I(De.pendingTotal)&&De.pendingTotal.then(null,()=>{});const Oe=De&&De.rows||[];if(Oe.length&&(yield Oe),Oe.length<me)return}n(Pe);const Me=await C(await G.execute({...ve.pushed,range:void 0},Pe)),ze=x(Me&&Me.rows||[],{...ve.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:de,mode:"remote",fetch:zt,foregroundIdle:Ot,aggregate:Et,countMatching:async Ie=>{const{plan:qe,signal:ve}=await ke(Ie);if(!qe.needsAll&&q.total){n({signal:ve});const me=await C(await G.execute({...qe.pushed,range:{start:0,end:0}},{signal:ve}));if(me&&typeof me.total=="number")return me.total}let Se=0;for await(const me of Re(Ie))Se+=me.length;return Se},streamMatching:Re,lastPlan:()=>ce?{...ce,...he?{aggregates:he}:{},...Ae?{total:{deferred:!0,state:Ae.state,value:Ae.value}}:{}}:null,fullFrame:be,counts:()=>({match:ge,total:ye??null,pending:!!Ae&&Ae.state==="pending"}),grandTotals:()=>Ee},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 x}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),F=Q.Lru,B=Q.isFunction,$=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,H=X.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,w=U.DEFAULT_PAGE_SIZE,v=U.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),l=g.createRowFactory,d=g.groupKey,a=K("packages/core/src/source/filterwire.js"),n=a.wireFilters,t=a.querySignature,r=a.warnHostFilterNotApplied,f=K("packages/core/src/source/pagewindow.js").pageWindow,o=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,h=K("packages/core/src/compute/pivot.js"),s=h.pivotKey,p=h.joinPath,b=h.DEFAULT_PATH_SEPARATOR,k=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,S=120,R=1e3;function j(L,P,D){for(let I=0;I<Math.max(L.length,P.length);I++){const C=L[I],O=P[I],N=C==null,G=O==null;if(N||G){if(N&&G)continue;return N?1:-1}const q=D(C,O);if(q!==0)return q}return 0}function x(L,P){return new T(L,P)}class E{constructor(P,D,I,C){this.path=P,this.keyPath=C||P,this.values=[],this.level=D,this.key=d(this.keyPath),this.cache=new z(I),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;#f="";#h;#p=!1;#m=!1;#g=[];#b=!1;#w=0;#O="";#y=null;#j=-1;constructor(P,D){this.#e=P||{mode:"remote"},this.#t=D||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#z(),this.unfilteredIndices=()=>this.#V(),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 I=this.#e.counts;B(I)&&(this.matchCount=()=>this.#_("match"),this.totalCount=()=>this.#_("total"));const C=this.#e.grandTotals;B(C)&&(this.grandTotalRow=()=>this.#X());const O=this.#e.foregroundIdle;B(O)&&(this.foregroundIdle=()=>this.#me(O),this.#e.pageForegroundIdle=()=>this.#b?this.#me(O):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||v},this.#l=l(this.#t),this.#a=new F(this.#n.pageSize*4),this.#h=_((G,q)=>this.#P(G,q),S),this.#r=new E([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#oe(),B(this.#e.fetch)||$("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#de()}count(){const P=this.#S();return P?P.length:this.#k()}#k(){const P=this.#N();return P?P.count():(this.#pe(),this.#q(this.#r))}#C(){if(this.#N())return!0;const P=D=>{if(D.count===null&&!D.complete)return!1;for(const I of D.children.values())if(this.#we(I.key)&&!P(I))return!1;return!0};return P(this.#r)}pageInfo(){const P=this.#S(),D=this.totalPending();if(!P){const I=this.#k();return{page:0,pageSize:0,total:this.#C()?I:null,pageCount:1,counting:D}}return{page:P.page,pageSize:P.pageSize,total:P.total,pageCount:P.pageCount,counting:D||P.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const P=this.#k(),D=f(this.#R("pageSize",0),this.#R("page",0),P,this.#C());if(!D)return this.#O="",null;const I=`${this.#w}:${D.offset}:${D.length}`;return I!==this.#O&&!this.#p&&(this.#O=I,D.length>0&&!this.#N()&&this.#P(D.offset,D.offset+D.length-1)),D}at(P){const D=this.#S();if(D){if(P<0||P>=D.length)return;const I=this.#E(D.offset+P);return I&&(I.index=P),I}return this.#E(P)}#E(P){const D=this.#N();if(D)return D.at(P);if(this.#pe(),P<0||P>=this.#k())return;const I=this.#ie(this.#r,P);if(!I)return;const C=this.#ne(I.node,I.local);return C&&(C.index=P),C||this.#l.skeleton(P,I.node.level,I.node.cache.erroredAt(I.local))}byKey(P){const D=this.#N();if(D)return D.byKey(P);const I=this.#u.get(P);if(!I)return;const C=I.lastIndexOf(":"),O=this.#o.get(I.slice(0,C));return O&&this.#ne(O,Number(I.slice(C+1)))||void 0}loaded(P){const D=this.#S();if(D){if(P<0||P>=D.length)return!1;P+=D.offset}const I=this.#N();if(I)return I.loaded(P);if(P<0||P>=this.#k())return!1;const C=this.#ie(this.#r,P);return!!C&&C.node.cache.rowLoaded(C.local)}hint(P,D){if(this.#p)return;this.#b=!0;const I=this.#pe();let C=Math.max(0,Math.floor(P)),O=Math.max(C,Math.floor(D));const N=this.#S();if(N){if(N.length===0)return;C=N.offset,O=N.offset+N.length-1}for(const[G,q]of this.#T(C,O)){G.cache.protect(q.min,q.max);for(const Z of G.cache.evict())this.#Me(G,Z)}this.#h(C,O),I&&this.#h.flush()}#T(P,D){const I=this.#k(),C=new Map;for(let O=P;O<=D&&O<I;O++){const N=this.#ie(this.#r,O);if(!N)continue;const G=C.get(N.node);G?(G.min=Math.min(G.min,N.local),G.max=Math.max(G.max,N.local)):C.set(N.node,{min:N.local,max:N.local})}return C.size||C.set(this.#r,{min:P,max:P}),C}#P(P,D){if(!this.#p)for(const[I,C]of this.#T(P,D)){I.cache.protect(C.min,C.max);const O=I.cache.blockOf(C.min),N=I.cache.blockOf(C.max);for(let G=O;G<=N&&!(I.count!==null&&G*I.cache.pageSize>=I.count);G++)I.cache.has(G)||this.#Te(I,G)}}apply(P){const D={added:[],updated:[],removed:[]};if(!P)return D;if(P.update)for(const I of P.update){const C=this.#u.get(this.#l.keyOf(I,-1));if(!C)continue;this.#a.delete(C);const O=C.lastIndexOf(":"),N=this.#o.get(C.slice(0,O));if(!N)continue;const G=Number(C.slice(O+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 oe=N.cache.rowAt(ne);if(oe===void 0)break;J.push(ne===G?I:oe)}N.cache.fill(q,J);const te=this.#ne(N,G);te&&D.updated.push(te)}return(P.add&&P.add.length||P.remove&&P.remove.length)&&this.reload({keepExpanded:!0}),D}reload(P){this.#s.abortAll("reload"),this.#h.cancel(),P&&P.keepExpanded===!1&&this.#i.clear(),this.#fe(),this.#K("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#fe(),this.#o.clear(),this.#i.clear(),this.#y&&B(this.#y.destroy)&&this.#y.destroy(),this.#y=null}expand(P){this.#i.has(P)||(this.#i.add(P),this.#K("group:toggled",{key:P,expanded:!0}),this.#K("model:changed",{reason:"expand",key:P}))}collapse(P){this.#i.delete(P)&&(this.#K("group:toggled",{key:P,expanded:!1}),this.#K("model:changed",{reason:"collapse",key:P}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#pe();const P=this.#d;if(!P||!P.keys.size||!this.#R("pivotBy",[]).length)return null;if(!P.result){const D=c((this.#t.config||{}).locale),I=[...P.keys.entries()].sort((O,N)=>j(O[1],N[1],D)),C=I.map(([O])=>O);P.result={keys:I.map(([,O])=>O),paths:C,fields:this.#H(C),groupPaths:[],columns:C.length*Math.max(1,this.#le().length),values:P.cells,cells:P.cells,error:null}}return P.result}invalidateHandles(){this.#y&&(B(this.#y.invalidateHandles)&&this.#y.invalidateHandles(),B(this.#y.invalidate)&&this.#y.invalidate("filter"))}#M(){const P=this.#e.fullFrame;return B(P)?P():null}#N(){const P=this.#M();return P?(this.#y||(this.#y=new o({mode:"memory"},this.#$())),P.version!==this.#j&&(this.#y.setRows(P.rows),this.#j=P.version),this.#y):null}#$(){const P=this.#t,D=P.state||{};return{...P,state:{...D,page:()=>0,pageSize:()=>0}}}#z(){const P=this.#N();return P?P.filteredIndices():new Uint32Array(0)}#V(){const P=this.#N();return P?P.unfilteredIndices():new Uint32Array(0)}#B(P){const D=this.#N();return D?D.handleFor(P):void 0}#L(){const P=this.#N();return P?P.display():[]}#I(P){const D=this.#N();return D&&B(D.facetIndices)?D.facetIndices(P):new Uint32Array(0)}#D(){const P=this.#N();return P&&B(P.grandTotalRow)?P.grandTotalRow():null}#_(P){const D=this.#N();if(D){const N=P==="match"?D.matchCount:D.totalCount;if(B(N))return N.call(D)}const I=this.#e.counts,C=B(I)?I():null,O=C?C[P]:null;return typeof O=="number"?O:this.#k()}#X(){const P=this.#N();if(P&&B(P.grandTotalRow))return P.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const I=this.#e.grandTotals,C=B(I)?I():null;return!C||!C.totals?null:this.#l.grandTotal(C.totals,C.leafCount||0)}#ue(){const P=this.#N();if(P&&B(P.unfilteredRows))return P.unfilteredRows();const D=[],I=this.count();for(let C=0;C<I;C++){const O=this.at(C);O&&D.push(O)}return D}#se(){const P=this.#R("quick",""),D={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#R("filters",null),this.#ce()),sort:this.#R("sort",[]),context:this.#R("context",null)};P&&(D.quick=P);const I=this.#R("where",null);return I&&I.active&&(D.where=I),D}#ae(){const P=this.#R("groupBy",[]).length,D=[];for(const I of this.#o.values())if(!(I.level!==P&&!I.flat))for(const C of I.cache.ids()){if(!I.cache.loaded(C))continue;const{start:O,end:N}=I.cache.rangeOf(C);for(let G=O;G<N&&I.cache.rowLoaded(G);G++){const q=this.#ne(I,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const P=this.#N();if(P){const C=P.matchCount();return typeof C=="number"?C:P.count()}this.#pe();const D=this.#R("groupBy",[]).length;let I=0;for(const C of this.#o.values())if(!(C.level!==D&&!C.flat))for(const O of C.cache.ids()){if(!C.cache.loaded(O))continue;const N=C.cache.fillOf(O);typeof N=="number"&&(I+=N)}return I}residentRows(){const P=this.#N();return P?P.display():this.#R("groupBy",[]).length>0?null:(this.#pe(),this.#ae())}#ge(P,D,I){const{start:C,end:O}=P.cache.rangeOf(D),N=this.#R("groupBy",[]),G=this.#R("pivotBy",[]),q=this.#R("quick",""),Z=this.#le(),J={protocol:y,range:{start:C,end:O},groupPath:P.path,groupValues:P.values,groupBy:N,totals:Z,totalFns:this.#U(Z),pivotBy:G,pivotMode:G.length>0,filters:n(this.#R("filters",null),this.#ce()),sort:this.#R("sort",[]),context:this.#R("context",null),signal:I};q&&(J.quick=q);const te=this.#R("where",null);return te&&te.active&&(J.where=te),J}async#Te(P,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 I=this.#s.begin(`${P.key}:${D}`);P.cache.begin(D,I);const C=this.#f,{start:O}=P.cache.rangeOf(D);try{const N=await this.#e.fetch(this.#ge(P,D,I.signal));if(!I.current||C!==this.#f||this.#p)return;I.settle();const G=N&&N.rows||[];if(!!(N&&N[k])&&!P.flat){P.flat=!0,P.children.clear();for(const[te,ne]of[...this.#u])ne.startsWith(`${P.key}:`)&&(this.#a.delete(ne),this.#u.delete(te))}P.cache.fill(D,G),P.failed=!1;for(let te=0;te<G.length;te++)this.#a.delete(`${P.key}:${O+te}`);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?(P.count=Z,P.complete=!0):G.length<P.cache.pageSize?(P.count=O+G.length,P.complete=!0):J&&(P.counting=!0,P.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:P.path,block:D}),this.#K("rows:changed",{companion:!0,reason:"page",groupPath:P.path,block:D}),this.#re(P),J&&this.#Se(P,J,C)}catch(N){if(I.settle(),H(N))return;P.cache.failed(D,N),P.failed=!0;const{end:G}=P.cache.rangeOf(D);for(let q=O;q<G;q++)this.#a.delete(`${P.key}:${q}`);this.#K("model:changed",{reason:"page-error",groupPath:P.path,block:D}),this.#K("source:error",{error:N,groupPath:P.path,block:D})}}async#Se(P,D,I){let C;try{C=await D}catch(O){if(I!==this.#f||this.#p)return;P.counting=!1,H(O)||(P.failed=!0),H(O)||this.#K("source:error",{error:O,groupPath:P.path});return}I!==this.#f||this.#p||(P.counting=!1,typeof C=="number"&&(P.count=C,P.complete=!0,this.#re(P),this.#K("model:changed",{reason:"total",count:C,groupPath:P.path})))}#re(P){typeof P.count!="number"||!P.complete||P.announced!==P.count&&(P.announced=P.count,this.#K("source:total",{total:P.count,groupPath:P.path}))}#me(P){if(this.#p)return null;this.#pe();const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),I=P();if(!D&&!I)return null;const C=(async()=>{D&&await D;for(let G=P();G;G=P())await G})();let O;const N=new Promise(G=>{O=setTimeout(G,R)});return Promise.race([C,N]).then(()=>clearTimeout(O))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#pe();const P=this.#r;return P.count===null&&!P.complete&&P.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#te(P){P.length===this.#c.length&&P.every((D,I)=>D===this.#c[I])||(this.#c=P,this.#K("column:pivoted",{pivotFields:P,remote:!0}))}#Y(){const P=this.#t.config||{};return P.pivot&&P.pivot.separator||b}#H(P){const D=this.#Y(),I=this.#le();if(!I.length)return P.slice();const C=[];for(const O of P)for(const N of I)C.push(`${O}${D}${N}`);return C}#J(P){const D=this.#Y();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const I=this.#d;let C=!1;const O=G=>{const q=Array.isArray(G)?G:[G],Z=p(q,D);return I.keys.has(Z)||(I.keys.set(Z,q),C=!0),Z},N=this.#R("groupBy",[]).length>0;for(const G of Array.isArray(P.axis)?P.axis:[])O(G);for(const G of Array.isArray(P.cells)?P.cells:[]){if(!G||typeof G!="object")continue;const q=O(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,te]of Object.entries(G.values||{}))I.cells.set(s(Z,q,J),te)}I.result=null,C&&this.#te((this.pivot()||{fields:[]}).fields)}#q(P){let D=this.#je(P);for(const I of P.children.values())this.#we(I.key)&&(D+=this.#q(I));return D}#je(P){if(P.count!==null)return P.count;const D=P.cache.loadedExtent();return P.complete?D:P.row&&P.row.leafCount>0?P.level>=this.#R("groupBy",[]).length?Math.max(D,P.row.leafCount):D===0?1:Math.min(D+P.cache.pageSize,Math.max(D,P.row.leafCount)):D+P.cache.pageSize}#ie(P,D){let I=D,C=0;const O=[...P.children.entries()].filter(([,G])=>this.#we(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of O){const Z=G-C+1;if(I<Z)return{node:P,local:C+I};I-=Z,C=G+1;const J=this.#q(q);if(I<J)return this.#ie(q,I);I-=J}const N=this.#je(P);return C+I<N?{node:P,local:C+I}:null}#ne(P,D){const I=`${P.key}:${D}`,C=this.#a.get(I);if(C)return C;const O=P.cache.rowAt(D);if(O===void 0)return null;const N=this.#R("groupBy",[]);let G;if(P.level<N.length&&!P.flat){const q=N[P.level],Z=this.#d!==null&&P.level===N.length-1&&this.#R("pivotBy",[]).length>0,J=this.#F(O,q),te=J==null,ne=[...P.path,te?"":String(J)],oe=[...P.keyPath,te?null:String(J)];if(G=this.#l.group({path:ne,keyPath:oe,column:q,value:J,level:P.level,parent:P.row,leafCount:Number(O.leafCount)||0,expanded:Z?!1:this.#we(d(oe)),...Z?{hasChildren:!1}:{}}),G.totals=this.#Z(O),G.data=O,!Z){let le=this.#o.get(G.key);le?le.row=G:(le=new E(ne,P.level+1,this.#n,oe),le.row=G,this.#o.set(le.key,le)),le.values=[...P.values,J],P.children.set(D,le)}}else G=this.#l.leaf(O,D,P.level,P.row);return this.#a.set(I,G),this.#u.set(G.key,I),G}#Z(P){const D=P||{};if(D.totals&&typeof D.totals=="object")return D.totals;const I={};for(const C of this.#le())Object.hasOwn(D,C)&&(I[C]=D[C]);return I}#Me(P,D){const{start:I,end:C}=P.cache.rangeOf(D);for(let O=I;O<C;O++){const N=`${P.key}:${O}`,G=this.#a.peek(N);G&&this.#u.delete(G.key),this.#a.delete(N)}}#pe(){const P=this.#oe();return P===this.#f?!1:(this.#f=P,this.#s.abortAll("query"),this.#fe(),this.#m=!1,this.#K("model:changed",{reason:"query"}),!0)}#fe(){for(const P of this.#o.values())P.cache.clear(),P.count=null,P.complete=!1,P.announced=null,P.counting=!1,P.failed=!1,P.children.clear(),P.flat=!1;this.#a.clear(),this.#u.clear(),this.#w++,this.#d=null}#oe(){const P=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)})}|${P?P.version:0}`}#we(P){const D=this.#R("expanded",null);return D?B(D.has)?D.has(P):Array.prototype.includes.call(D,P):this.#i.has(P)}#le(){const P=this.#R("totals",[]);if(P&&P.length)return[...P];const D=this.#t.columns;return!D||!B(D.all)?[]:D.all().filter(I=>!!I.total).map(I=>I.id)}#U(P){const D=this.#t.columns,I={};if(!D||!B(D.get))return I;for(const C of P){const O=D.get(C);if(!O)continue;const N=O.groupTotal!=null?O.groupTotal:O.total;typeof N=="string"&&(I[C]=N)}return I}#F(P,D){const I=this.#t.columns,C=I&&B(I.get)?I.get(D):void 0;return C&&B(C.getValue)?C.getValue(P):P?.[D]}#de(){r(this.#t)}#ce(){const P=this.#t.config||{};return{tz:P.timeZone,weekStartsOn:P.weekStartsOn}}#R(P,D){const I=this.#t.state;if(I&&B(I[P])){const C=I[P]();return C??D}return D}#K(P,D){const I=this.#t.emit;B(I)&&I(P,D)}}}),Le("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return F}});const Q=64;class F{#e;#t=0;#n=0;constructor($=Q){this.#e=new Uint32Array(Math.max(1,$)),this.#n=this.#e.length}static from($,_=Q){const X=new F($.length+Math.max(1,_));return X.#e.set($,0),X.#t=$.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at($){return $<0||$>=this.length?0:$<this.#t?this.#e[$]:this.#e[$+(this.#n-this.#t)]}insert($,_){const X=$<0?0:$>this.length?this.length:$;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push($){this.insert(this.length,$)}removeAt($){return!Number.isInteger($)||$<0||$>=this.length?!1:(this.#r($),this.#n++,!0)}toArray(){const $=new Uint32Array(this.length);return $.set(this.#e.subarray(0,this.#t),0),$.set(this.#e.subarray(this.#n),this.#t),$}clear(){this.#t=0,this.#n=this.#e.length}#r($){if($!==this.#t)if($<this.#t){const _=this.#t-$;this.#e.copyWithin(this.#n-_,$,this.#t),this.#t=$,this.#n-=_}else{const _=$-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=$,this.#n+=_}}#o(){const $=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-$),this.#e=_,this.#n=_.length-$}}}),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 v}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const Q=K("packages/core/src/internal/util.js"),F=Q.now,B=Q.nextFrame,$=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,U=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,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let i=0,f=0,u=0,o=0,m=0;for(let h=0;h<t.length;h++){const s=t[h];typeof s=="number"?i++:typeof s=="boolean"?f++:typeof s=="string"?u++:s instanceof Date?o++:Array.isArray(s)&&m++}const c=t.length;return i===c?"float64":f===c?"bitset":o===c?"float64":u===c?"text":m===c?"multi":"object"}function v(t,r,i){return r<=0||t<i*r?"dictionary":"object"}function g(t,r,i){const f=new Map,u=new Map;for(const y of t){if(y.computed)continue;const S=X(y.read)?y.read:W(y.field||y.id);u.set(y.id,S),f.set(y.id,S)}const o=r?.order??[],m=r?.fns??{},c=r?.deps??{},h=r?.wrapDeps??null,s=o.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,j]of u)S[R]=j(y);for(const R of s){const j=c[R];let x;if(j==="*")x=S;else{x={};const E=j||[];for(let T=0;T<E.length;T++){const L=E[T];x[L]=L in S?S[L]:u.get(L)?.(y)}}S[R]=m[R](h?h(x,R):x,{data:y,row:null,column:null,grid:null,context:i})}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)f.set(y,S=>k(S)[y]);return{readers:f,reset(){b=new WeakMap}}}class l{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(r,i){this.spec=r,this.read=i,this.kind="object",this.inferred=!1,this.nullable=r.nullable!==!1}}class d{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,i={},f={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...z,...f};const u=i.columns??[];this.#r=g(u,i.computed??null,i.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,i.computed??null),this.#n=new U(this.#t.map(o=>({id:o.spec.id,kind:o.kind,nullable:o.nullable,read:o.read,dictionary:o.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 r=F(),{chunkMs:i,chunkRows:f}=this.#i,u=this.#e.length;do{const o=Math.min(this.#o+f,u);this.#n.append(this.#e.slice(this.#o,o)),this.#d(this.#o,o),this.#o=o,this.#r.reset(),this.#h(!1)}while(this.#o<u&&F()-r<i);return this.#a+=F()-r,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#h(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,read:r.read,dictionary:r.spec.dictionary})),decisions:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,inferred:r.inferred,distinct:r.candidate||r.change?this.#f(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,i){const f=this.#e,u=Math.min(this.#i.sampleSize,f.length),o=this.#i.dictionaryRatio,m=i?.pure instanceof Set?i.pure:new Set(i?.pure??i?.order??[]);for(const c of r){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||i&&!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 h=this.#r.readers.get(c.id)??(X(c.read)?c.read:W(c.field||c.id)),s=new l(c,h);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<u&&p.length<this.#i.sampleSize;A++){const k=h(f[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=v(A,p.length,o),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&&$(`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(r,i){const f=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const o=u.distinct;for(let m=r;m<i;m++){const c=u.read(f[m]);c!=null&&o.add(c)}}}#f(r){if(r.distinct)return r.distinct.size;const i=this.#n.column(r.spec.id);return i?.dict?i.dict.size:0}#h(r){const i=this.#i.dictionaryRatio,f=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const o=this.#f(u);if(u.kind==="dictionary"&&o>=i*f){const m=this.#n.column(u.spec.id);u.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${o} distinct values is at or above ${i*100}% of ${f} rows`;continue}if(u.kind==="object"&&o>=i*f){u.candidate=!1,u.distinct=null,u.reason=`${o} distinct values is at or above ${i*100}% of ${f} rows`;continue}r&&u.kind==="object"&&o<i*f&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${o} distinct values is below ${i*100}% of ${f} rows`,u.distinct=null),r&&(u.candidate=!1)}}}async function a(t,r={},i={}){const f=new d(t,r,i),u=i.scheduler?.frame??B;for(;f.slice();)await new Promise(o=>{u(o)});return f.result()}function n(t,r={},i={}){const f=new d(t,r,{...i,chunkMs:1/0});for(;f.slice(););return f.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 l}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return d}});const F=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),$=B.inferKind,_=B.decideText,X=B.INGEST_DEFAULTS,H=K("packages/core/src/store/columnstore.js").toFloat,U=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(a){if(!Array.isArray(a)||a.length===0)return!1;for(const n of a)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!U.has(n.kind))return!1;return!0}function w(a){const n=H(a);return Number.isFinite(n)?n|0:0}function v(a){return a==null?[]:Array.isArray(a)?a:[a]}function g(a,n,t,r){if(a.kind)return a.kind;const i=[];for(let o=0;o<n.length&&i.length<X.sampleSize;o++){const m=n[o];m!=null&&i.push(m)}const f=$(i,{multi:a.multi});if(f!=="text")return f;const u=new Set(i).size;return _(u,i.length,r)}function l(a,n,t={}){const r=n.length|0,i=t.dictionaryRatio??X.dictionaryRatio,f=[];for(const u of a){const o=F(u.field||u.id),m=u.nullable!==!1,c=new Array(r);for(let A=0;A<r;A++){const k=o(n[A]);c[A]=k===void 0?null:k}const h=g(u,c,r,i),s=m?new Uint8Array(r+7>>3):null,p=A=>{s&&(s[A>>3]|=1<<(A&7))};let b;switch(h){case"float64":{const A=new Float64Array(r);for(let k=0;k<r;k++){const y=c[k],S=y===null;S||p(k),A[k]=S?NaN:H(y)}b={id:u.id,kind:h,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"int32":{const A=new Int32Array(r);for(let k=0;k<r;k++){const y=c[k],S=y===null;S||p(k),A[k]=S?0:w(y)}b={id:u.id,kind:h,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"bitset":{const A=new Uint8Array(r+7>>3);for(let k=0;k<r;k++){const y=c[k],S=y===null;S||p(k),!S&&y&&(A[k>>3]|=1<<(k&7))}b={id:u.id,kind:h,nullable:m,values:A,presence:s,offsets:null,table:null};break}case"dictionary":{const A=new Uint32Array(r),k=[],y=new Map;for(let S=0;S<r;S++){const R=c[S];if(R===null){A[S]=0;continue}p(S);let j=y.get(R);j===void 0&&(j=k.length,k.push(R),y.set(R,j)),A[S]=j}b={id:u.id,kind:h,nullable:m,values:A,presence:s,offsets:null,table:k};break}case"multi":{const A=[],k=new Map,y=new Uint32Array(r+1),S=[];for(let R=0;R<r;R++){const j=c[R];y[R]=S.length,j===null||p(R);const E=v(j);for(let T=0;T<E.length;T++){const L=E[T];let P=k.get(L);P===void 0&&(P=A.length,A.push(L),k.set(L,P)),S.push(P)}}y[r]=S.length,b={id:u.id,kind:h,nullable:m,values:Int32Array.from(S),presence:s,offsets:y,table:A};break}default:{const A=new Array(r);for(let k=0;k<r;k++){const y=c[k];y!==null&&p(k),A[k]=y}b={id:u.id,kind:"object",nullable:m,values:A,presence:s,offsets:null,table:null};break}}f.push(b)}return{count:r,columns:f}}function d(a){const n=[];if(!a||!Array.isArray(a.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of a.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),Le("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return j}});const Q=K("packages/core/src/internal/util.js"),F=Q.Lru,B=Q.isFunction,$=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,H=Q.defaultCompare,U=Q.warnOnce,z=Q.infoOnce,w=Q.getPath,v=K("packages/core/src/source/abort.js"),g=v.createAbortScope,l=v.isAbortError,d=K("packages/core/src/source/rows.js"),a=d.createRowFactory,n=d.lazyRowView,r=K("packages/core/src/source/gapbuffer.js").GapBuffer,f=K("packages/core/src/source/memory.js").createMemorySource,o=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,s=Symbol("lattice.stream.storeBacked"),p=8,b=.1,A=1e3,k=50;function y(x){return Math.min(A,Math.max(k,Math.floor(x/4)))}function S(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const E=x.trim();if(!E)return NaN;const T=Date.parse(E);return Number.isNaN(T)?Number(E):T}return NaN}function R(x,E){return new j(x,E)}class j{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;#f=0;#h=0;#p=0;#m=0;#g=null;#b=null;#w=null;#O=!1;#y=!1;#j=!1;#k=!1;#C="";#S=0;#E=0;#T=0;#P=null;#M=1/0;#N=!1;#$=null;#z=null;#V=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 F(4096),this.#C=this.#Je();const L=(this.#t.config||{}).ingest;this.#L=!!L&&L.retainSource===!1,B(this.#e.open)||U("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const P=Number(this.#e.poll);Number.isFinite(P)&&P>0&&(this.#B=setInterval(()=>{this.#k||this.reload()},P),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=f({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.#Ae(L),get physical(){return E.#n.length}};return this.#L&&(T.column=L=>{const P=E.#t.store;return P&&B(P.column)?P.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 P=this.#ye(L);P&&T.push(P)}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,P=this.#ye(L);return P.index=E,P}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():n(()=>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 P of E.update){const D=this.#a.get(this.#s.keyOf(P,-1));if(D===void 0)continue;const I=this.#de(D);this.#L?this.#Qe(D,P):this.#n[D]=P,this.#l.delete(D),this.#ce(D,I),this.#P&&(this.#ae(D,P),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 P of L)T.added.push(this.#ye(P))}return E.remove&&E.remove.length&&U("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.#j=!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.#j||this.#k||!B(this.#e.open))return;this.#j=!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(P){this.#W("source:error",{error:P});return}const L=B(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#V=L;try{for(;;){const P=await L.next();if(!E.current||this.#k)return;if(P.done){this.#he();return}if(await this.#Y(P.value,E),!E.current||this.#k)return;if(P.value&&P.value.done){this.#he();return}if(await this.#ve(),!E.current||this.#k)return}}catch(P){if(l(P))return;this.#W("source:error",{error:P})}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.#f}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.#je(E,T);const P=$();L&&L.length&&(this.#Z(L),this.#D++),this.#H(E),this.#h+=$()-P,this.#v()}#H(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 P=this.#ne();return!P||!c(P)?(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 P=this.#s.keyOf(E[L],this.#n.length+L);if(P!=null){if(T.has(P)||this.#a.has(P))return!0;T.add(P)}}return!1}async#je(E,T){const L=E.rows,P=this.#ie(),D=this.#ne();let I;try{I=await P.columnize(D,L,{key:"ingest:stream",signal:T&&T.signal})}catch(q){if(l(q)||(U("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.#H(E),this.#v();return}if(T&&(!T.current||this.#k))return;const C=this.#t.store,O=this.#L?void 0:L,{from:N}=C.appendPacked(I,O),G=I.count|0;for(let q=0;q<G;q++){const Z=N+q,J=L[q],te=this.#s.keyed?this.#s.keyOf(J,Z):null;if(this.#n[Z]=this.#L?s:J,this.#S++,this.#ae(Z,J),te!==null&&this.#a.set(te,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.#H(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,P=new Array(E.length),D=[],I=new Set;for(let O=0;O<E.length;O++){const N=this.#s.keyed?this.#s.keyOf(E[O],this.#n.length+D.length):null;P[O]=N,!(N!==null&&(this.#a.has(N)||I.has(N)))&&(N!==null&&I.add(N),D.push(E[O]))}let C=D.length&&L&&B(L.append)?L.append(D).from:this.#n.length;for(let O=0;O<E.length;O++){const N=E[O],G=P[O];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),te=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,te);continue}const q=C++;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 C=this.#we(E);C>=0&&C<=this.#p&&(L=!0)}else E<=this.#p&&(L=!0);const P=T===s?this.#Ae(E):T,D=this.#s.keyed?this.#s.keyOf(P,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 I=this.#t.store;return I&&B(I.remove)&&I.remove(E),this.#S--,L}#pe(){let E=0,T=0;const L=this.#oe();E+=L.dropped,T+=L.aboveAnchor;const P=this.#fe();E+=P.dropped,T+=P.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}))}#fe(){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,P=0;for(;this.#S>T&&this.#T<this.#n.length;){const D=this.#T++;this.#n[D]!==void 0&&(this.#Me(D)&&P++,L++)}return{dropped:L,aboveAnchor:P}}#oe(){const E=this.#X();if(!E||!this.#P||!this.#se())return{dropped:0,aboveAnchor:0};const T=Date.now()-E;let L=0,P=0,D=1/0;for(let I=this.#T;I<this.#n.length;I++){if(this.#n[I]===void 0)continue;const C=this.#P[I];if(!(Number.isNaN(C)||C===void 0)){if(C>=T){C<D&&(D=C);continue}this.#Me(I)&&P++,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:P}}#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,P=!!(T&&T.active)||!!(L&&B(L.active)&&L.active());if(!(E||this.#o.length>0||!!this.#i||!!this.#be("quick","")||P)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let I=0;I<this.#n.length;I++)this.#n[I]!==void 0&&this.#U(I)&&this.#r.insert(this.#R(I),I)}#U(E){const T=this.#Ae(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 P=(this.#t.config||{}).hostFilter;if(P&&B(P.active)&&P.active()&&!P.passes(this.#ye(E)))return!1;const D=this.#be("where",null);if(D&&D.active){const I=this.#ye(E);if(!D.passes(I.data,I.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(I=>this.#F(I,T)):L.op==="not"?!L.conditions.some(I=>this.#F(I,T)):L.conditions.every(I=>this.#F(I,T));const P=E,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#Pe(T,P.col),P,(this.#t.config||{}).locale):(U("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 P=T+L>>>1;this.#K(this.#r.at(P),E)<0?T=P+1:L=P}for(let P=T;P<this.#r.length;P++){const D=this.#r.at(P);if(D===E)return P;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 P=this.#R(E);this.#r.insert(P,E),P<=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 P=T+L>>>1;this.#K(E,this.#r.at(P))<0?L=P:T=P+1}return T}#K(E,T){const L=this.#Ae(E),P=this.#Ae(T);for(const D of this.#o){const I=this.#_e(D.col),C=this.#Pe(L,D.col),O=this.#Pe(P,D.col),G=(I&&I.value&&B(I.value.compare)?I.value.compare:H)(C,O);if(G!==0)return D.dir==="desc"?-G:G}return 0}#he(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const E=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#L&&this.#n.length<E&&(this.#g=f({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.#f++;const E=this.#m;this.#m=0,this.#h=0,this.#W("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#W("model:changed",{reason:"stream",shiftAboveViewport:E,anchor:this.#p}),this.#W("rows:changed",{companion:!0,reason:"stream"})}))}#ve(){return this.#f===0||this.#h<this.#Be()?Promise.resolve():(this.#h=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)}#Ae(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 P=this.#ne();if(Array.isArray(P))for(const D of P){if(!D||!D.id)continue;const I=B(D.read)?D.read:C=>w(C,D.field||D.id);L.set(D.id,E,I(T))}}#ye(E){let T=this.#l.get(E);return T||(T=this.#s.leaf(this.#Ae(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():[],P=[];for(const D of L){const I=B(D.getValue)?D.getValue(E):void 0;I!=null&&I!==""&&P.push(String(I))}return P.join(" ").toLowerCase()}#_e(E){const T=this.#t.columns;return T&&B(T.get)?T.get(E):void 0}#Fe(){const E=this.#V;if(this.#V=null,E&&B(E.return))try{E.return()}catch{}}#Je(){return o({context:this.#be("context",null)})}#be(E,T){const L=this.#t.state;if(L&&B(L[E])){const P=L[E]();return P??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 H}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.isObject,$=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,H=500,U=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,h={}){const s=B(h)?h:{},p=$(s.fetch)?s.fetch:typeof globalThis<"u"&&$(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=$(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):H,R=s.lenient===!0,j=Number.isFinite(s.poll)&&s.poll>0?Math.floor(s.poll):void 0,x=typeof c=="string"&&c.length>0;x||F("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(L={}){if(!x)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const P=L&&L.signal;let D;try{D=await p(c,y?{signal:P,headers:y}:{signal:P})}catch(O){throw W(O)?O:new Error(`[lattice] createUrlSource: request to ${c} failed — ${O&&O.message||O}`)}if(!D||!D.ok){const O=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${O} for ${c}`)}const I=v(c,b,D),C=D.body&&$(D.body.getReader)?D.body.getReader():null;try{if(!C){const G=await D.text();(I||d(G,c))==="ndjson"?yield*f(null,null,G,0,D,c,S,R):yield*i(G,c,A,k);return}const O=new TextDecoder("utf-8");if(I==="json"){yield*i(await r(C,O,""),c,A,k);return}if(I==="ndjson"){yield*f(C,O,"",0,D,c,S,R);return}const N=await a(C,O,c);N.format==="json"?yield*i(await r(C,O,N.seed),c,A,k):yield*f(C,O,N.seed,N.bytes,D,c,S,R)}finally{if(C&&$(C.cancel))try{await C.cancel()}catch{}}}const T={mode:"stream",open:E,autoStart:s.autoStart!==!1};return j!==void 0&&(T.poll=j),Number.isFinite(s.maxRows)&&(T.maxRows=s.maxRows),Number.isFinite(s.maxAge)&&(T.maxAge=s.maxAge),(typeof s.ageBy=="string"||$(s.ageBy))&&(T.ageBy=s.ageBy),Number.isFinite(s.coalesceMs)&&(T.coalesceMs=s.coalesceMs),Number.isFinite(s.promoteToMemoryBelow)&&(T.promoteToMemoryBelow=s.promoteToMemoryBelow),T}function v(c,h,s){if(h)return h;const p=g(c);if(p)return p;const b=s&&s.headers&&$(s.headers.get)?s.headers.get("content-type"):null;return l(b)}function g(c){const h=String(c).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function l(c){if(!c)return;const h=c.split(";")[0].trim().toLowerCase();if(U.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function d(c,h){const s=c.replace(/^\s+/,""),p=n(s);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return p}async function a(c,h,s){let p="",b=0;for(;;){const{value:k,done:y}=await c.read();if(k&&(b+=k.byteLength,p+=h.decode(k,{stream:!0})),y){p+=h.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=n(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 n(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const h=c.indexOf(`
|
|
9
9
|
`);if(h===-1)return"json";let s=c.slice(0,h);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 r(c,h,s){let p=s;for(;;){const{value:b,done:A}=await c.read();if(b&&(p+=h.decode(b,{stream:!0})),A)break}return p+=h.decode(),p}function*i(c,h,s,p){let b;try{b=JSON.parse(c)}catch(k){throw new Error(`[lattice] createUrlSource: ${h} 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: ${h} did not resolve to an array${k}.`)}yield{rows:A,progress:{loaded:A.length,estimated:A.length}}}async function*f(c,h,s,p,b,A,k,y){const S=m(b);let R=s||"",j=p||0,x=0,E=0,T=[];function*L(){let D;for(;(D=R.indexOf(`
|
|
@@ -54,8 +54,8 @@ ${te}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
54
54
|
`,b),R=s.slice(y,S),j=R.split(`
|
|
55
55
|
`);let x=0;const E=j.map(T=>{if(!c)return x+=A.length,A+T;if(T.startsWith(A))return x-=A.length,T.slice(A.length);const L=T.replace(/^[ \t]/,"");return x-=T.length-L.length,L}).join(`
|
|
56
56
|
`);return E===R?!1:(h.value=s.slice(0,y)+E+s.slice(S),this.#r(Math.max(y,p+(c?-A.length:A.length)),Math.max(y,b+x)),this.revalidate(),!0)}#r(c,h){const s=this.input;s&&(s.selectionStart=c,s.selectionEnd=h===void 0?c:h,W(s.setSelectionRange)&&s.setSelectionRange(s.selectionStart,s.selectionEnd))}format(c){const h=this.input;if(!h||this.language!=="json")return!1;const s=a(h.value);if(!s.ok)return this.revalidate(),!1;if(s.value===null&&h.value.trim()==="")return!1;try{const p=JSON.stringify(s.value,null,c===void 0?this.indent:c);return p===void 0?!1:(h.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",h=i(c,this.language);this.lastResult=h;const s=this.errorNode;return s&&(s.textContent=h.ok?"":f(h),s.classList.toggle(w.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!s?this.input.removeAttribute("aria-errormessage"):(s.id||(s.id=H("lat-err")),this.input.setAttribute("aria-errormessage",s.id))),h}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 h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(c){const h=c==null?"":String(c);return this.input&&(this.input.value=h),this.revalidate(),h.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:h}:{ok:!0,value:z(h)}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const o=u}),Le("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/unit.js"),U=H.parseUnit,z=H.formatUnit,w=H.findUnit;function v(d,a){return z(d,a)}class g extends F{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.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 n=this.symbol(),t=`${this.id}-unit`,r=$(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":n?t:null}});r.value=v(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const i=typeof a.step=="number"?a.step:0;return i>0&&this.#e.push(_(r,"keydown",f=>{f.key==="ArrowUp"?(W(f.preventDefault)&&f.preventDefault(),this.nudge(i)):f.key==="ArrowDown"&&(W(f.preventDefault)&&f.preventDefault(),this.nudge(-i))})),this.hint=$(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),$(this.doc,"div",{class:`${B.editor}__unit`,children:[r,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 n=U(this.input?this.input.value:"",this.opts);let t=(n??0)+a;const{min:r,max:i}=this.props;typeof r=="number"&&t<r&&(t=r),typeof i=="number"&&t>i&&(t=i),this.input&&(this.input.value=v(t,this.opts))}readValue(){const a=this.input?this.input.value:"";if(String(a).trim()==="")return null;const n=U(a,this.opts);if(n===null)return NaN;if(this.mode()!=="clamp")return n;const{min:t,max:r}=this.props;let i=n;return typeof t=="number"&&i<t&&(i=t),typeof r=="number"&&i>r&&(i=r),i}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 n=this.symbol();return n?`Enter a value such as 10 ${n}`:"Enter a value"}if(this.mode()==="reject"){const{min:n,max:t}=this.props;if(typeof n=="number"&&a<n)return`Must be ${this.describe(n)} 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 n=a==null?"":String(a);if(n.trim()==="")return{ok:!0,value:null};const t=U(n,this.opts),r=t===null?NaN:t,i=this.checkValue(r);return i!==!0?{ok:!1,message:i}:{ok:!0,value:r}}destroy(){for(const a of this.#e)a();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const l=g}),Le("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.uid,U=K("packages/core/src/columns/types/radix.js"),z=U.compileRadixFormat,w=U.compileRadixParse,v=U.normaliseRadixOptions,g=U.radixRange,l=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),d=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),a=new Map;function n(f){const u=f||"";let o=a.get(u);if(o)return o;try{o=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{o={format:m=>String(m)}}return a.set(u,o),o}function t(f,u){const o=u||{},m={};if(f){for(const h of d)f[h]!==void 0&&(m[h]=f[h]);const c=g(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>c.min&&(m.min=f.min),typeof f.max=="number"&&f.max<c.max&&(m.max=f.max)}for(const c of d)o[c]!==void 0&&(m[c]=o[c]);return typeof o.min=="number"&&(m.min=o.min),typeof o.max=="number"&&(m.max=o.max),v(m)}class r extends F{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const u=this.params.column&&this.params.column.dataType;this.options=t(u&&u.radix||null,this.props),this.format=z(this.options),this.parse=w(this.options);const o=$(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}});o.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(o.value=this.params.key),this.input=o;const m=$(this.doc,"span",{class:l.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(o,"input",()=>this.refresh())),this.#e.push(_(o,"keydown",h=>this.#n(h)));const c=$(this.doc,"div",{class:l.root,children:[o,m]});return this.refresh(),c}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&W(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const o=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(o)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-o))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:o,max:m}=this.options;return u<o?o:u>m?m:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const o=this.parse(u);return o.ok?{value:this.mode()==="clamp"?this.clamp(o.value):o.value,message:null}:this.mode()==="clamp"&&typeof o.value=="number"&&(o.reason==="range"||o.reason==="negative")?{value:this.clamp(o.value),message:null}:{value:NaN,message:this.messageFor(o.reason)}}messageFor(u){const o=this.options;return u==="negative"?`This column holds an unsigned ${o.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(o.min)} and ${this.format(o.max)}`:`Enter a ${o.name} value, e.g. ${this.format(o.radix===2?5:26)}`}refresh(){const{value:u,message:o}=this.evaluate();if(this.input&&this.input.classList&&(o?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",o?"true":"false"),o&&this.hint?(this.hint.id||(this.hint.id=H("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(o){this.hint.textContent=o,this.hint.classList&&this.hint.classList.add(l.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(l.hintInvalid),this.hint.textContent=u===null?"":`= ${n(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const o=this.parse(this.input.value);let m;typeof o.value=="number"?m=o.value:typeof this.params.value=="number"?m=this.params.value:m=0,this.input.value=this.format(this.clamp(m+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const o=u==null?"":String(u);if(o.trim()==="")return{ok:!0,value:null};const m=this.parse(o);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 h=this.checkValue(c);return h!==!0?{ok:!1,message:h}:{ok:!0,value:c}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const i=r}),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 n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,H=Q.documentFor,U=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,d=K("packages/dom/src/cell/icons.js").createIcon,a=6;class n extends F{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const u=f||{},o=t(u),m=U(u,o,{colId:u.column&&(u.column.id||u.column.field)}),c=Number(o.max??a),h=m.options().length;if(Number.isFinite(c)&&h>c){const s=new w;s.init(u),this.#e=s,this.params=u,this.doc=H(u),this.props=o,this.lookup=m,this.popup=s.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=m)}usesFallback(){return this.#e!==null}build(){const f=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=$(f,"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 o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(_(u,"keydown",o=>this.onKeyDown(o))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(f,u){const o=this.doc,m=$(o,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":f.variant??null,"aria-disabled":f.disabled===!0?"true":null}});return f.icon&&m.appendChild(d(o,f.icon,{className:B.icon})),m.appendChild($(o,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(_(m,"mousedown",c=>{c&&g(c.preventDefault)&&c.preventDefault(),f.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(m),m}buildClear(){const f=$(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(f,"mousedown",u=>{u&&g(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),f}indexOf(f){if(f==null)return-1;const u=X(f);for(let o=0;o<this.options.length;o++)if(X(this.options[o].id)===u)return o;return-1}paint(){for(let f=0;f<this.segments.length;f++){const u=f===this.indexOf(this.selected),o=this.segments[f];o.setAttribute("aria-checked",u?"true":"false"),o.setAttribute("tabindex",f===this.focused?"0":"-1"),o.classList.toggle(`${B.editor}__segment--active`,u),o.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,u){const o=this.options[f];!o||o.disabled===!0||(this.selected=o.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(f){const u=this.segments.length;if(!u)return;let o=this.focused;for(let m=0;m<u;m++)if(o=(o+f+u)%u,this.options[o].disabled!==!0){this.focusAt(o);return}}focusAt(f){if(f<0||f>=this.segments.length)return;this.focused=f,this.paint();const u=this.segments[f];u&&g(u.focus)&&u.focus()}edgeIndex(f){const u=this.options.length;for(let o=0;o<u;o++){const m=f===1?o:u-1-o;if(this.options[m].disabled!==!0)return m}return-1}onKeyDown(f){const u=()=>{g(f.preventDefault)&&f.preventDefault()};switch(f.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(f)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(f)}" 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 f=this.indexOf(this.selected);return this.segments[f>=0?f:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const f=this.lookup.ready();!f||!g(f.then)||f.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let o=0;o<this.options.length;o++)u.appendChild(this.buildSegment(this.options[o],o));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(f){return this.#e?this.#e.validate(f):super.validate(f)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(f){return this.#e?this.#e.fromClipboard(f):super.fromClipboard(f)}destroy(){for(const f of this.#t)f();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(i){return{...i.column&&i.column.edit&&i.column.edit.props||{},...i.props||{}}}const r=n}),Le("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,W=K("packages/dom/src/cell/icons.js").createIcon,H=K("packages/dom/src/cell/renderers/rating.js"),U=H.ratingFills,z=H.fillState,w=H.ratingText,v=H.clampRating,g=H.DEFAULT_RATING_ICON,l=H.DEFAULT_RATING_MAX,a=K("packages/core/src/internal/util.js").isFunction;class n extends F{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const f=Math.floor(Number(this.props.max??l));return Number.isFinite(f)&&f>0?f:l}step(){return this.props.allowHalf===!0?.5:1}build(){const f=this.doc,u=this.max();this.rating=t(this.params.value,u,this.props.allowHalf===!0);const o=$(f,"div",{class:`${B.editor}__rating`}),m=$(f,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let h=0;h<u;h++)m.appendChild(this.buildItem(h));o.appendChild(m),this.slider=m;const c=$(f,"span",{class:`${B.editor}__rating-value`});return o.appendChild(c),this.readout=c,this.props.allowClear===!0&&o.appendChild(this.buildClear()),this.#e.push(_(m,"keydown",h=>this.onKeyDown(h))),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),u)),this.paint(),o}buildItem(f){const u=this.doc,o=String(this.props.icon??g),m=$(u,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(u,o,{className:B.icon})]}),c=$(u,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":o,"aria-hidden":"true"},children:[W(u,o,{className:B.icon}),m]});return this.fills.push(m),this.#e.push(_(c,"mousedown",h=>{h&&a(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",h=>{const s=this.ratingAt(f,h);s!==this.preview&&(this.preview=s,this.paint())})),this.items.push(c),c}buildClear(){const f=$(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(f,"mousedown",u=>{u&&a(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),f}ratingAt(f,u){if(this.props.allowHalf!==!0)return f+1;const o=this.items[f],m=o&&Number(o.offsetWidth),c=u&&Number(u.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(c)?f+1:c*2<m?f+.5:f+1}focusTarget(){return this.slider}setRating(f,u){this.rating=f===null?null:v(f,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(f){const u=this.rating===null?0:this.rating;this.setRating(u+f)}paint(){const f=this.max(),u=this.props.allowHalf===!0,o=this.preview===null?this.rating:this.preview,m=U(o===null?0:o,f,{allowHalf:u});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=o===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(o),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",o===null?"0":String(o)),h.setAttribute("aria-valuetext",c),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(f){const u=()=>{a(f.preventDefault)&&f.preventDefault()},o=this.step();if(/^[0-9]$/.test(f.key)){u(),this.setRating(Math.min(Number(f.key),this.max()));return}switch(f.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(o);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-o);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(f){if(f==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof f!="number"||!Number.isFinite(f))return"Enter a rating";const u=this.max();return f<0?"Must be 0 or more":f>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(f)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":w(this.rating)}fromClipboard(f){const u=String(f??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const o=Number(u);if(!Number.isFinite(o))return{ok:!1,message:`"${u}" is not a rating`};const m=this.checkValue(o);return m!==!0?{ok:!1,message:m}:{ok:!0,value:o}}destroy(){for(const f of this.#e)f();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(i,f,u){if(i==null||i==="")return null;const o=Number(i);return Number.isFinite(o)?v(o,f,u,!1):null}const r=n}),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 v}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,X=K("packages/dom/src/editors/number.js"),W=X.parseNumberText,H=X.presentNumber,z=K("packages/core/src/internal/util.js").isFunction,w=0,v=100;class g extends F{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??w);return Number.isFinite(r)?r:w}max(){const r=Number(this.props.max??v);return Number.isFinite(r)?r:v}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,i=this.min(),f=this.max(),u=this.step(),o=a(this.props.marks);this.marks=o,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=$(r,"div",{class:`${B.editor}__slider`});this.root=m;const c=$(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(i),max:String(f),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:o.length?`${this.id}-marks`:null}});if(this.range=c,m.appendChild(c),o.length){const s=$(r,"datalist",{attrs:{id:`${this.id}-marks`}}),p=$(r,"div",{class:`${B.editor}__slider-marks`});for(const b of o){s.appendChild($(r,"option",{attrs:{value:String(b.value),label:b.label}}));const A=$(r,"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",`${(l(b.value,i,f)*100).toFixed(2)}%`),p.appendChild(A)}m.appendChild(s),m.appendChild(p)}const h=$(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=h,m.appendChild(h),this.props.showValue!==!1){const s=$(r,"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(_(h,"input",()=>this.onFieldInput())),this.#e.push(_(h,"change",()=>this.paint())),this.#e.push(_(h,"keydown",s=>this.onKeyDown(s))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(h.value=this.params.key,this.onFieldInput()),this.paint(),m}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&z(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const i=this.min(),f=this.max(),u=this.step(),o=Math.min(Math.max(r,i),f),m=i+Math.round((o-i)/u)*u,c=d(u),h=c>0?Number(m.toFixed(c)):Math.round(m);return Math.min(Math.max(h,i),f)}setAmount(r,i){this.amount=r===null?null:this.snap(r),this.paint(i)}onFieldInput(){const r=this.field?String(this.field.value):"";if(r.trim()===""){this.amount=null,this.paint("field");return}const i=W(r,this.params.locale);if(i===null||Number.isNaN(i)){this.paint("field");return}this.setAmount(i,"field")}paint(r){const i=this.min(),f=this.max(),u=this.amount,o=u===null?i:u;this.range&&r!=="range"&&(this.range.value=String(o)),this.field&&r!=="field"&&(this.field.value=u===null?"":H(u,this.props));const m=this.root;m&&m.style&&z(m.style.setProperty)&&m.style.setProperty("--lat-slider-pos",`${(l(o,i,f)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",u===null?"true":"false");const c=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const i=this.marks.find(u=>u.value===r),f=H(r,this.props);return i&&i.label!==f?`${f} (${i.label})`:f}onKeyDown(r){if(r.key==="Escape"){z(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){z(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.field?String(this.field.value):"";if(r.trim()==="")return null;const i=W(r,this.params.locale);return i===null||Number.isNaN(i)?NaN:this.snap(i)}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof r!="number"||Number.isNaN(r)?"Enter a number":r<this.min()?`Must be ${this.min()} or more`:r>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(r){const i=String(r??"").trim();if(i==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const f=W(i,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const u=this.snap(f),o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function l(t,r,i){const f=i-r;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-r)/f))}function d(t){if(!Number.isFinite(t))return 0;const r=String(t),i=r.indexOf("e");if(i>=0){const u=r.slice(0,i),o=u.indexOf("."),m=o<0?0:u.length-o-1;return Math.min(15,Math.max(0,m-Number(r.slice(i+1))))}const f=r.indexOf(".");return f<0?0:Math.min(15,r.length-f-1)}function a(t){if(!t)return[];const r=[];if(Array.isArray(t)){for(const i of t){if(i&&typeof i=="object"){const u=Number(i.value);Number.isFinite(u)&&r.push({value:u,label:String(i.label??u)});continue}const f=Number(i);Number.isFinite(f)&&r.push({value:f,label:String(f)})}return r}if(typeof t=="object")for(const[i,f]of Object.entries(t)){const u=Number(i);Number.isFinite(u)&&r.push({value:u,label:String(f)})}return r}const n=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 v}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return d}}),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"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,X=K("packages/dom/src/cell/renderers/colour.js"),W=X.normaliseColour,H=X.parseColour,z=K("packages/core/src/internal/util.js").isFunction,w=Object.freeze(["neutral","info","success","warning","danger","accent"]),v=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(r){if(r==null)return null;if(typeof r=="object"){const u=r,o=g(u.token??u.value??u.colour??u.color);return o?{...o,label:u.label==null?o.label:String(u.label)}:null}const i=String(r).trim();if(i==="")return null;const f=W(i);return f?{token:null,hex:f,label:f}:Object.hasOwn(v,i)?{token:i,hex:v[i],label:i}:null}function l(r,i){const f=r&&r.ownerDocument,u=f&&f.defaultView;if(!u||!z(u.getComputedStyle))return null;try{const o=u.getComputedStyle(r);return!o||!z(o.getPropertyValue)?null:W(String(o.getPropertyValue(`--lattice-variant-${i}-solid`)).trim())}catch{return null}}class d extends F{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const i=this.doc;this.swatches=a(this.props.swatches);const f=$(i,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=$(i,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const o=$(i,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)o.appendChild(this.buildSwatch(this.swatches[m],m));f.appendChild(o)}this.native=$(i,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=$(i,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),f.appendChild(this.hex),this.props.allowClear===!0&&f.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",o=>this.onKeyDown(o))),this.#e.push(_(f,"keydown",o=>this.onKeyDown(o)));const u=W(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),f}buildSwatch(i,f){const u=$(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":i.label,"data-index":f,"data-variant":i.token}});return i.token||n(u,i.hex),this.#e.push(_(u,"mousedown",o=>{o&&z(o.preventDefault)&&o.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(u),u}buildClear(){const i=$(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(i,"mousedown",f=>{f&&z(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),i}focusTarget(){return this.hex}attached(){super.attached();for(let i=0;i<this.swatches.length;i++){const f=this.swatches[i];if(!f.token)continue;const u=l(this.buttons[i]||this.element(),f.token);u&&(f.hex=u)}this.paint()}setColour(i){const f=i===null?null:W(i,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const i=this.hex?String(this.hex.value).trim():"";return i===""?null:W(i,{alpha:this.alpha()})}paint(){const i=this.current(),f=i===null?null:i.slice(0,7);n(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",i===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let u=0;u<this.buttons.length;u++){const o=i!==null&&this.swatches[u].hex.toLowerCase()===i.toLowerCase();this.buttons[u].setAttribute("aria-checked",o?"true":"false"),this.buttons[u].classList.toggle(`${B.editor}__colour-swatch--selected`,o),this.swatches[u].token||n(this.buttons[u],this.swatches[u].hex)}}onKeyDown(i){if(i.key==="Escape"){z(i.preventDefault)&&i.preventDefault(),this.cancel();return}if(i.key==="Enter"){z(i.preventDefault)&&i.preventDefault(),this.commit();return}i.key==="Tab"&&this.commit()}readValue(){const i=this.hex?String(this.hex.value).trim():"";if(i==="")return null;const f=W(i,{alpha:this.alpha()});return f===null?i:f}checkValue(i){if(i==null||i==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=H(i);return f?!this.alpha()&&f.a<1?"This column does not accept transparency":!0:`"${String(i)}" is not a colour`}toClipboard(){const i=this.current();return i===null?"":i}fromClipboard(i){const f=String(i??"").trim();if(f==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=W(f,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${f}" is not a colour`};const o=this.checkValue(u);return o!==!0?{ok:!1,message:o}:{ok:!0,value:u}}destroy(){for(const i of this.#e)i();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function a(r){const i=Array.isArray(r)&&r.length?r:r===!1?[]:w,f=[];for(const u of i){const o=g(u);o&&f.push(o)}return f}function n(r,i){const f=r&&r.style;if(f){if(i===null){z(f.removeProperty)&&f.removeProperty("--lat-swatch");return}z(f.setProperty)&&f.setProperty("--lat-swatch",i)}}const t=d}),Le("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const F=K("packages/dom/src/editors/select.js").SelectEditorBase,$=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),X=_.CLS,W=_.el,H=_.on,U=_.clear,z=_.keyOf,w=_.rawOptions,v=_.lookupKey,g=K("packages/core/src/internal/util.js"),l=g.isFunction,d=g.isObject,a="\0";class n extends F{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 i=super.build();return i.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),i}initSelection(){this.rebuild(),this.selected=this.params.value??null;const i=this.nodeById(this.selected);if(i)for(let f=i.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const i=w(this.params,this.props),f=this.props.keys||{},u=f.value||v(this.params,"valueKey")||"id",o=f.label||v(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of i){if(!d(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,u,o):this.addByChildren(m,null,u,o)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(i,f,u,o){const m=i?`${i.key}${a}${f}`:f;let c=this.nodes.get(m);return c?c.id===void 0&&u!==void 0&&(c.id=u):(c={id:u,label:f,key:m,parent:i,children:[],depth:i?i.depth+1:0,disabled:!1},this.nodes.set(m,c),(i?i.children:this.roots).push(c)),o&&(o.disabled===!0&&(c.disabled=!0),o.icon!==void 0&&(c.icon=o.icon),o.variant!==void 0&&(c.variant=o.variant)),c}addByPath(i,f,u){const o=i.path;let m=null;for(let c=0;c<o.length;c++){const h=c===o.length-1,s=String(o[c]),p=h&&i[u]!=null?String(i[u]):s,b=this.addNode(m,s,h?i[f]:void 0,h?i:null);h&&(b.label=p),m=b}}addByChildren(i,f,u,o){const m=i[u],c=i[o]!=null?String(i[o]):String(m??""),h=this.addNode(f,c,m,i),s=Array.isArray(i.children)?i.children:[];for(const p of s)d(p)?this.addByChildren(p,h,u,o):this.addNode(h,String(p??""),p,null)}nodeById(i){if(i==null)return;const f=z(i);for(const u of this.nodes.values())if(u.id!==void 0&&z(u.id)===f)return u}filterOptions(i){const f=String(i||"").trim().toLowerCase(),u=f!=="";this.matched=u?this.computeMatches(f):new Set;const o=[],m=c=>{for(const h of c)u&&!this.matched.has(h.key)||(o.push(h),h.children.length&&(u||this.expanded.has(h.key))&&m(h.children))};return m(this.roots),o}computeMatches(i){const f=new Set,u=o=>{let m=o.label.toLowerCase().includes(i);for(const c of o.children)u(c)&&(m=!0);return m&&f.add(o.key),m};for(const o of this.roots)u(o);return f}repaint(i){if(this.refreshOptions(),!i||!this.list)return;const f=this.visible.findIndex(u=>u.key===i);f>=0&&this.list.setActive(f)}isBranch(i){return!!i&&i.children.length>0}isSelectable(i){return!i||i.disabled||i.id===void 0||i.id===null?!1:!(this.leavesOnly&&this.isBranch(i))}setExpanded(i,f){this.isBranch(i)&&(f?this.expanded.add(i.key):this.expanded.delete(i.key),this.repaint(i.key))}choose(i){if(i){if(!this.isSelectable(i)){this.isBranch(i)&&this.setExpanded(i,!this.expanded.has(i.key));return}this.selected=i.id,this.input&&(this.input.value=""),this.query="",this.repaint(i.key),this.paintDisplay(),this.commit()}}isSelected(i){return this.selected!=null&&i&&i.id!==void 0&&z(i.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(i){if(i==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const f=this.nodeById(i);return f&&this.isSelectable(f)?!0:f?`"${f.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(i)}" is not a valid option`}renderOption(i,f,u){U(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(i.depth+1)),f.setAttribute("data-depth",String(i.depth));const o=W(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<i.depth;b++)o.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(o);const m=this.isBranch(i),c=m&&(this.expanded.has(i.key)||this.query.trim()!==""),h=m?c?"chevronDown":"chevronRight":"blank",s=W(this.doc,"span",{class:m?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[$(this.doc,h,{className:X.icon})],attrs:{"data-icon":m?h:null,"aria-hidden":"true"}});m&&H(s,"mousedown",b=>{l(b.preventDefault)&&b.preventDefault(),l(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(i,!this.expanded.has(i.key))}),f.appendChild(s),i.icon&&f.appendChild($(this.doc,i.icon,{className:X.icon})),f.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:i.label})),i.variant?f.setAttribute("data-variant",i.variant):f.removeAttribute("data-variant"),m?f.setAttribute("aria-expanded",c?"true":"false"):f.removeAttribute("aria-expanded");const p=this.isSelected(i);f.classList.toggle(X.optionSelected,p),f.classList.toggle(X.optionDisabled,!this.isSelectable(i)),f.classList.toggle("lat-tree__row--branch",m),f.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(i)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const i=this.display;if(!i)return;if(U(i),this.selected==null){i.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){i.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}f.icon&&i.appendChild($(this.doc,f.icon,{className:X.icon})),i.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?i.setAttribute("data-variant",f.variant):i.removeAttribute("data-variant")}pathLabel(i){const f=[];for(let u=i;u;u=u.parent)f.unshift(u.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(i){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;switch(i.key){case"ArrowRight":{if(l(i.preventDefault)&&i.preventDefault(),!u)return;this.isBranch(u)&&!this.expanded.has(u.key)?this.setExpanded(u,!0):this.isBranch(u)&&f&&f.setActive(Math.min(this.visible.length-1,f.active+1));return}case"ArrowLeft":{if(l(i.preventDefault)&&i.preventDefault(),!u)return;this.isBranch(u)&&this.expanded.has(u.key)?this.setExpanded(u,!1):u.parent&&this.focusNode(u.parent.key);return}case"Home":l(i.preventDefault)&&i.preventDefault(),f&&this.visible.length&&f.setActive(0);return;case"End":l(i.preventDefault)&&i.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(i)}}focusNode(i){if(!this.list)return;const f=this.visible.findIndex(u=>u.key===i);f>=0&&this.list.setActive(f)}acceptHighlight(i){const f=this.list,u=f&&f.active>=0?this.visible[f.active]:null;if(!u){i&&i.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):i&&i.commit&&this.commit()}moveHighlight(i){const f=this.list;if(!f)return;let u=f.active;for(let o=0;o<this.visible.length;o++){if(u+=i,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){f.setActive(u);return}}}}const t=n}),Le("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const F=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),$=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.keyOf,U=B.debounce,z=B.rawOptions,w=B.optionSource,v=B.lookupSearch,g=B.lookupKey,l=K("packages/core/src/internal/util.js"),d=l.isFunction,a=l.isObject,n=l.getPath,r=K("packages/dom/src/cell/icons.js").createIcon;class i extends F{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),d(this.props.search)&&!(this.lookup&&this.lookup.search)){const s=Number(this.props.searchDebounce)||200;this.#n=U(p=>this.runRemoteSearch(String(p)),s)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=z(this.params,this.props).map(s=>this.toOption(s));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!a(h)){const y=h==null?"":String(h);return{id:h,label:y,secondary:"",avatar:"",initials:u(y),disabled:!1,raw:{}}}const s=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",b=f(h,this.props.template??p,""),A=f(h,this.props.secondary,""),k=f(h,this.props.avatar,"");return{id:h[s],label:b||String(h[s]??""),secondary:A,avatar:k,initials:u(b||String(h[s]??"")),disabled:h.disabled===!0,icon:h.icon,variant:h.variant,raw:h}}attached(){if(super.attached(),this.#t||this.all.length)return;const h=w(this.params,this.props);d(h)&&(this.#t=!0,Promise.resolve(h()).then(s=>{!this.element()||!Array.isArray(s)||(this.all=s.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const s=String(h||"").trim().toLowerCase();if(s==="")return this.all;const p=o(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=d(A)?A(b.raw):n(b.raw,A);if(k!=null&&String(k).toLowerCase().includes(s))return!0}return!1})}async runRemoteSearch(h){const s=v(this.params,this.props);if(!s)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const b=await s(h,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(h){!h||h.disabled||(this.selected=h.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(h){return this.selected!=null&&h!=null&&H(h.id)===H(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(h){if(h==null)return;const s=H(h);return this.all.find(p=>H(p.id)===s)}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(h)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(h)}" is not a valid option`}renderOption(h,s,p){W(s),s.appendChild(this.buildAvatar(h));const b=_(this.doc,"span",{class:"lat-object__text"});b.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&b.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),s.appendChild(b),h.icon&&s.appendChild(r(this.doc,h.icon,{className:$.icon})),h.variant?s.setAttribute("data-variant",h.variant):s.removeAttribute("data-variant");const A=this.isSelected(h);s.classList.add("lat-object__row"),s.classList.toggle($.optionSelected,A),s.classList.toggle($.optionDisabled,h.disabled===!0),s.setAttribute("aria-selected",A?"true":"false"),h.disabled?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled")}buildAvatar(h){const s=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),s.setAttribute("data-fallback","initials"),s;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.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:h.initials})),s.setAttribute("data-fallback","initials"))}),s.appendChild(p),s}paintDisplay(){const h=this.display;if(!h)return;if(W(h),this.selected==null){h.removeAttribute("data-variant");return}const s=this.optionById(this.selected);if(!s){h.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(s)),h.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:s.label})),s.variant?h.setAttribute("data-variant",s.variant):h.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 f(c,h,s){if(h==null)return s;const p=d(h)?h(c):n(c,String(h));return p==null?s:String(p)}function u(c){const h=String(c||"").trim().split(/\s+/).filter(b=>b!=="");if(!h.length)return"";const s=[...h[0]][0]||"";if(h.length===1)return s.toUpperCase();const p=[...h[h.length-1]][0]||"";return(s+p).toUpperCase()}function o(c){if(c==null)return null;const s=(Array.isArray(c)?c:[c]).filter(p=>typeof p=="string"||d(p));return s.length?s:null}const m=i}),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 l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/dom/src/cell/icons.js"),U=H.createIcon,z=H.iconNames,v=K("packages/core/src/internal/util.js").isFunction;class g extends F{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const n=this.props;this.columns=Math.max(1,Math.floor(Number(n.columns)||8)),this.names=l(n.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:n.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new $({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,i,f)=>this.renderRow(r,i,f)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.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",r=>this.onKeyDown(r))),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 n=_(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(n,"mousedown",t=>{v(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),n}focusTarget(){return this.input}onQuery(n){this.query=n,this.refreshIcons()}refreshIcons(){const n=this.query.trim().toLowerCase();this.matches=n===""?this.names.slice():this.names.filter(r=>r.toLowerCase().includes(n)),this.rows=[];for(let r=0;r<this.matches.length;r+=this.columns)this.rows.push(this.matches.slice(r,r+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(n){return n<0?-1:Math.floor(n/this.columns)}moveCursor(n){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+n));return this.setCursor(t)}setCursor(n){return this.cursor=n,this.list&&this.list.setActive(this.rowOf(n)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(n,t,r){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let i=t.__latIconCells;if(!i){i=[],W(t);for(let f=0;f<this.columns;f++){const u=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(u,"mousedown",o=>{v(o.preventDefault)&&o.preventDefault();const m=u.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(u),i.push(u)}t.__latIconCells=i}for(let f=0;f<i.length;f++){const u=i[f],o=n[f];if(o===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(W(u),u.__latIconName=void 0);continue}const m=r*this.columns+f;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",o),u.setAttribute("title",o),u.setAttribute("aria-label",o),u.__latIconName!==o&&(W(u),u.appendChild(U(this.doc,o,{className:B.icon})),u.__latIconName=o);const c=this.selected===o;u.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",c),u.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(W(n),this.selected==null){n.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(U(this.doc,this.selected,{className:B.icon})),n.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(n){this.selected=n;const t=this.matches.indexOf(n);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(n))?!0:`"${String(n)}" is not a known icon name`}onKeyDown(n){const t=()=>{v(n.preventDefault)&&n.preventDefault()};switch(n.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 r=this.cursorName();r&&this.choose(r);return}case"Escape":t(),this.cancel();return;case"Tab":{const r=this.cursorName();r&&(this.selected=r),this.commit();return}default:break}}destroy(){for(const n of this.off)n();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function l(a){const n=z();if(Array.isArray(a)&&a.length){const t=new Set(n);return a.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const d=g}),Le("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/temperature.js"),U=H.formatTemperature,z=H.parseTemperature,w=H.findScale;function v(d,a){return U(d,{...a,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends F{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.params.column&&this.params.column.dataType||null,n=a&&a.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const a=this.props;this.opts=this.buildOptions();const n=w(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,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?r:null}});i.value=v(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const f=typeof a.step=="number"?a.step:0;return f>0&&this.#e.push(_(i,"keydown",u=>{u.key==="ArrowUp"?(W(u.preventDefault)&&u.preventDefault(),this.nudge(f)):u.key==="ArrowDown"&&(W(u.preventDefault)&&u.preventDefault(),this.nudge(-f))})),this.hint=$(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),$(this.doc,"div",{class:`${B.editor}__unit`,children:[i,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 n=z(this.input?this.input.value:"",this.opts);let t=(n??0)+a;const{min:r,max:i}=this.props;typeof r=="number"&&t<r&&(t=r),typeof i=="number"&&t>i&&(t=i),this.input&&(this.input.value=v(t,this.opts))}readValue(){const a=this.input?String(this.input.value).trim():"";if(a==="")return null;const n=z(a,this.opts);return n===null?Number.NaN:n}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&a<n?`Must be ${n} 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 l=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 l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),F=Q.BaseEditor,B=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/currency.js"),U=H.parseMoney,z=H.toMoney,w=H.normaliseCode,v=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(a){const n=z(a);return n?String(n.amount):""}class l extends F{input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=z(this.params.value),i=w(this.props.code)||r&&r.code||w(t.code)||"USD";let f=this.props.codes||t.codes||v;return f=f.map(u=>w(u)).filter(Boolean),f.includes(i)||(f=[i,...f]),{code:i,codes:f,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=$(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.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 r=$(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const i of this.opts.codes){const f=$(this.doc,"option",{text:i,attrs:{value:i}});i===this.opts.code&&(f.selected=!0),r.appendChild(f)}return this.picker=r,$(this.doc,"div",{class:`${B.editor}__unit`,children:[t,r]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&W(n.select)&&n.select()}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=this.picker?this.picker.value:this.opts.code,r=U(n,{...this.opts,code:t});return r===null?Number.NaN:r}checkValue(n){if(n===null)return!0;if(!n||typeof n!="object"||!Number.isFinite(n.amount))return"Enter an amount";const t=n.amount,{min:r,max:i}=this.props;return typeof r=="number"&&t<r?`Must be ${r} or more`:typeof i=="number"&&t>i?`Must be ${i} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const d=l}),Le("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return l}}),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 i}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return h}}),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 x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return O}}),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 ae}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return ce}});const F=K("packages/dom/src/editors/text.js").TextEditor,$=K("packages/dom/src/editors/textarea.js").TextareaEditor,X=K("packages/dom/src/editors/number.js").NumberEditor,H=K("packages/dom/src/editors/date.js").DateEditor,z=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,v=K("packages/dom/src/editors/select.js").SelectEditor,l=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,i=K("packages/dom/src/editors/duration.js").DurationEditor,u=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,m=K("packages/dom/src/editors/password.js").PasswordEditor,h=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,x=K("packages/dom/src/editors/slider.js").SliderEditor,T=K("packages/dom/src/editors/colour.js").ColourEditor,P=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,I=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,O=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"),te=J.isCtor,ne=J.isFunction,oe=J.warnOnce,le=K("packages/dom/src/editors/common.js");for(const he of Object.keys(le))he!=="default"&&Object.defineProperty(e,he,{enumerable:!0,get:function(){return le[he]}});const ae=Object.freeze({text:F,textarea:$,number:X,date:H,checkbox:z,select:v,multiSelect:l,temperature:G,currency:Z,time:a,datetime:t,duration:i,ipaddress:u,password:m,code:h,unit:p,radix:A,slider:x,rating:R,segmented:y,treeSelect:P,objectPicker:I,iconPicker:O,colour:T}),se=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function ee(he,ge){const Ee=he&&he.edit&&he.edit.editor,ye=ge&&ge.editors||{},Ae=!!(he&&he.lookup&&he.lookup.multiple);if(te(Ee)||ne(Ee))return Ee;if(typeof Ee=="string"){if(Ae&&Ee==="select")return l;const be=ye[Ee]||ae[Ee];if(be)return be;oe(`editor:missing:${Ee}`,`unknown editor "${Ee}"; falling back to the data type default`)}const pe=he&&he.type||"text";if(pe==="lookup"||he&&he.lookup)return Ae?l:v;const we=se[pe];return we&&(ye[we]||ae[we])||null}function ie(he,ge){const Ee=ee(he.column||{},ge);if(!Ee)return null;const ye=new Ee;return ye.init(he),ne(ye.cancelBeforeStart)&&ye.cancelBeforeStart()===!0?(ne(ye.destroy)&&ye.destroy(),null):ye}const ce=ae}),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 v}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction;function z(c){let h=0,s=0,p=0,b=null,A=null;for(const k of c||[]){if(k==null||k==="")continue;h++;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:h,numericCount:s,sum:s?p:null,min:b,max:A,avg:s?p/s:null}}class w{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=$(this.doc,"div",{class:`${F.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild($(this.doc,"span",{class:`${F.statusBar}__label`,text:h.label})),this.valueNode=$(this.doc,"span",{class:`${F.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,s){const p=this.ctx&&this.ctx.messages;return(p&&U(p.t)?p:W).t(h,s)}element(){return this.root}refresh(){const h=this.read();this.valueNode&&this.valueNode.textContent!==h&&(this.valueNode.textContent=h)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class v extends w{read(){const h=this.ctx.host||{},s=U(h.totalRowCount)?h.totalRowCount():0,p=U(h.loadError)?h.loadError():null;if(p)return p;if(s==null)return this.t("status.counting");const b=U(h.rowCount)?h.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}):`${f(y,this.ctx.locale)}${A?` ${A}`:""}`;return b===s?this.t("status.total",{rows:k(s)}):this.t("status.shownOfTotal",{shown:f(b,this.ctx.locale),total:k(s)})}}class g extends w{read(){const h=this.ctx.host||{},s=U(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(s)return typeof s.count=="number"?this.t("status.selectedAcrossSource",{count:s.count}):this.t("status.selectedAcrossSourceCounting");const p=U(h.selectedCount)?h.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class l extends w{read(){const h=this.ctx.host||{},s=U(h.rangeValues)?h.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}`)} ${o(y,this.ctx.locale)}`)}return A.join(" ")}}class d extends w{read(){const h=this.ctx.host||{},s=U(h.progress)?h.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 h=this.ctx.host||{},s=U(h.updateStats)?h.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 n extends w{read(){const h=this.ctx.host||{},s=U(h.hiddenUnresolved)?h.hiddenUnresolved():0;return s?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:s})}):""}}const t=Object.freeze({rowCount:v,selectedCount:g,aggregation:l,progress:d,updates:a,comments:n});class r{panels=[];root=null;init(h){const s=h||{};this.doc=B(s),this.host=s.host||{},this.messages=s.messages||null,this.root=$(this.doc,"div",{class:F.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(h,s,p){const b=new s;return b.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:h,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(h){const s=this.panels.findIndex(A=>A.name===h);if(s<0)return!1;const[p]=this.panels.splice(s,1),b=p.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),U(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)U(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const i=new Map;function f(c,h){const s=h||"";let p=i.get(s);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),i.set(s,p)),p.format(Number(c)||0)}const u=new Map;function o(c,h){const s=h||"";let p=u.get(s);return p||(p=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),u.set(s,p)),p.format(Number(c)||0)}const m=r}),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 l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/renderer/direction.js").isRtlElement,v=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,r){const i=[];for(const f of t||[]){const u=H(f)?f(r):f;if(u==null||u===!1)continue;if(u==="separator"){i.push({separator:!0});continue}if(typeof u=="string"){i.push({name:u});continue}const o=u,m=o.subMenu||o.children;m?i.push({...o,subMenu:g(m,r)}):i.push(o)}return i.filter((f,u,o)=>f.separator?u===0||u===o.length-1?!1:!o[u-1].separator:!0)}class l{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(r){const i=r||{};this.doc=B(i),this.host=i.host||this.doc.body,this.ctx=i.ctx||{},this.onClose=i.onClose||null,this.parent=i.parent||null}place(r){const i=this.host,f=H(i.getBoundingClientRect)?i.getBoundingClientRect():{left:0,top:0},u=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},o=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=o.innerWidth||0,c=o.innerHeight||0;let h=r.x||0,s=r.y||0;const p=z(i);if(r.anchor&&H(r.anchor.getBoundingClientRect)){const k=r.anchor.getBoundingClientRect();r.placement==="below"?(h=p?k.right-u.width:k.left,s=k.bottom):(h=p?k.left-u.width:k.right,s=k.top)}else p&&(h-=u.width);const b={left:Math.max(0,f.left||0),top:Math.max(0,f.top||0),right:Math.min(m||1/0,(f.left||0)+(f.width||1/0)),bottom:Math.min(c||1/0,(f.top||0)+(f.height||1/0))};h+u.width>b.right&&(h-=u.width),h<b.left&&(h=b.left),s+u.height>b.bottom&&(s-=u.height),s<b.top&&(s=b.top);const A=b.bottom-s;u.height>A&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(A))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(i.scrollLeft||0))}px`,this.root.style.top=`${Math.round(s-f.top+(i.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=g(r.items,this.ctx),this.returnFocus=r.returnFocus||null,this.anchor=r.anchor&&H(r.anchor.setAttribute)&&r.anchor.getAttribute&&r.anchor.getAttribute("aria-haspopup")?r.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=$(this.doc,"div",{class:F.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((i,f)=>{if(i.separator){this.root.appendChild($(this.doc,"div",{class:F.menuSeparator,attrs:{role:"separator"}}));return}const u=$(this.doc,"div",{class:[F.menuItem,i.cssClass||""],attrs:{role:i.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":i.disabled?"true":null,"aria-checked":i.checked===void 0?null:String(i.checked===!0),"aria-haspopup":i.subMenu?"true":null,"aria-expanded":i.subMenu?"false":null,"data-index":f}});if(i.icon!=null&&i.icon!==""){const m=$(this.doc,"span",{class:F.icon});v(m,i.icon,`menu:${i.name||f}`),u.appendChild(m)}u.appendChild($(this.doc,"span",{class:`${F.menuItem}__label`,text:i.name||""})),i.shortcut&&u.appendChild($(this.doc,"span",{class:`${F.menuItem}__shortcut`,text:i.shortcut})),i.subMenu&&u.appendChild($(this.doc,"span",{class:`${F.menuItem}__arrow`,text:"›"}));const o=this.itemNodes.length;this.off.push(_(u,"click",()=>this.invoke(o))),this.off.push(_(u,"mouseenter",()=>{this.focus(o),i.subMenu?this.openSubMenu(o):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(_(this.root,"keydown",i=>this.onKeyDown(i))),H(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=i=>{this.root&&!a(this.root,i.target)&&!(this.child&&this.child.root&&a(this.child.root,i.target))&&this.hide()},!0)),H(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let r=0;r<this.itemNodes.length;r++)if(!this.itemAt(r).disabled)return r;return-1}itemAt(r){const i=this.itemNodes[r];return i?this.items[Number(i.getAttribute("data-index"))]||{}:{}}focus(r){if(r<0||r>=this.itemNodes.length)return;const i=this.itemNodes[this.focused];i&&i.classList.remove(`${F.menuItem}--focused`),this.focused=r;const f=this.itemNodes[r];f.classList.add(`${F.menuItem}--focused`),H(f.focus)&&f.focus(),H(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const i=this.itemNodes.length;if(!i)return;let f=this.focused;for(let u=0;u<i;u++)if(f=(f+r+i)%i,!this.itemAt(f).disabled){this.focus(f);return}}invoke(r){const i=this.itemAt(r);if(!(!i||i.disabled)){if(i.subMenu){this.openSubMenu(r);return}H(i.action)&&i.action({...this.ctx,item:i}),this.hideRoot()}}openSubMenu(r){const i=this.itemAt(r);i.subMenu&&(this.closeChild(),this.child=new l({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:i.subMenu,anchor:this.itemNodes[r]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(r){switch(r.key){case"ArrowDown":d(r),this.move(1);break;case"ArrowUp":d(r),this.move(-1);break;case"Home":d(r),this.focus(this.firstEnabled());break;case"End":d(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":d(r),this.openSubMenu(this.focused);break;case"ArrowLeft":d(r),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":d(r),this.invoke(this.focused);break;case"Escape":d(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const i=r.toLowerCase(),f=this.itemNodes.length;for(let u=1;u<=f;u++){const o=(this.focused+u+f)%f,m=this.itemAt(o);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(i)){this.focus(o);return}}}hideRoot(){let r=this;for(;r.parent;)r=r.parent;r.hide()}hide(){this.closeChild();for(const r of this.off)r();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&&H(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&H(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,H(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function d(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function a(t,r){let i=r;for(;i;){if(i===t)return!0;i=i.parentNode}return!1}const n=l}),Le("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),F=Q.documentFor,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,v=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(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||W;const t=n||{};this.doc=F(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:v.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const u of this.off)u();this.off.length=0,_(n),this.diffs=new Map;const t=this.views(),r=t.filter(u=>u.builtin),i=t.filter(u=>!u.builtin);r.length&&(n.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),r.length)),n.appendChild(this.buildList(r))),n.appendChild(this.buildHead(String(this.props.title||"Saved views"),i.length)),i.length?n.appendChild(this.buildList(i)):n.appendChild(B(this.doc,"p",{class:v.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&n.appendChild(f)}buildList(n){const t=B(this.doc,"div",{class:v.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=U(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?n:n.slice().sort((t,r)=>String(t.name||"").localeCompare(String(r.name||"")))}activeId(){return U(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:v.head,children:[B(this.doc,"span",{class:v.title,text:String(n)}),B(this.doc,"span",{class:v.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,i=U(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,f=B(this.doc,"div",{class:[v.item,r?v.itemActive:"",this.editing===t?v.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(n)),f;const u=B(this.doc,"button",{class:v.apply,attrs:{type:"button","aria-current":r?"true":null,title:[r?`${n.name} is applied`:`Apply ${n.name}`,n.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:v.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});U(this.host.apply)?this.off.push($(u,"click",()=>this.applyView(t))):u.setAttribute("disabled",""),n.description&&u.appendChild(B(this.doc,"span",{class:v.description,text:String(n.description)}));const o=this.buildDiff(t,r);return o&&u.appendChild(o),f.appendChild(u),n.builtin||f.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,i)),f}buildBadges(n){const t=B(this.doc,"span",{class:v.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[v.badge,v.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!U(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[v.diff,v.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const i=l(r);return i.length?B(this.doc,"span",{class:v.diff,text:i.join(" · ")}):null}diffOf(n){if(!U(this.host.diff))return null;if(this.diffs.has(n))return this.diffs.get(n);let t=null;try{t=this.host.diff(n)}catch{t=null}return this.diffs.set(n,t),t}buildActions(n,t){const r=String(n.id),i=B(this.doc,"span",{class:v.actions});if(t&&U(this.host.rename)&&i.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&U(this.host.clearDefault)?i.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&U(this.host.setDefault)&&i.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),U(this.host.export)&&i.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&U(this.host.remove)){const f=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");f.classList.add(v.actionDanger),i.appendChild(f)}return i}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:v.confirm});r.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:n.name})}));const i=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:n.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return i.classList.add(v.actionDanger),r.appendChild(i),r.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),r}buildRenameRow(n){const t=String(n.id),r=B(this.doc,"span",{class:v.confirm}),i=B(this.doc,"input",{class:v.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});i.value=String(n.name||""),this.input=i;const f=()=>{const o=String(i.value||"").trim();this.editing=null,o&&o!==n.name&&this.host.rename(t,o),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push($(i,"keydown",o=>{o.key==="Enter"?f():o.key==="Escape"&&u()})),r.appendChild(i),r.appendChild(this.buildAction("Save","Save the new name",f)),r.appendChild(this.buildAction("Cancel","Leave the name alone",u)),r}buildFoot(){if(this.props.allowSave===!1||!U(this.host.saveAs))return null;const n=B(this.doc,"div",{class:v.foot}),t=B(this.doc,"input",{class:v.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 r=()=>{const f=String(t.value||"").trim();if(!f){U(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(f),this.refresh()};this.off.push($(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push($(t,"keydown",f=>{f.key==="Enter"&&r()}));const i=B(this.doc,"button",{class:v.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push($(i,"click",r)),n.appendChild(t),n.appendChild(i),n}buildAction(n,t,r,i){const f=B(this.doc,"button",{class:v.action,text:i?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return i&&f.appendChild(w(this.doc,i,{className:v.actionIcon})),this.off.push($(f,"click",r)),f}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&U(n.focus)&&n.focus(),n&&U(n.select)&&n.select()}destroy(){for(const n of this.off)n();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function l(a,n=3){if(!a||!a.changed)return[];const t=a.counts||{},r=[],i=(f,u,o)=>{f&&r.push((f===1?u:o).replace("%",String(f)))};if(i(t.columnsHidden,"hides % column","hides % columns"),i(t.columnsShown,"shows % column","shows % columns"),i(t.columnsMoved,"moves % column","moves % columns"),i(t.columnsPinned,"repins % column","repins % columns"),i(t.columnsResized,"resizes % column","resizes % columns"),a.filters&&a.filters.changed){const f=t.filterColumns||0;r.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return a.quick&&a.quick.changed&&r.push("changes the search"),a.sort&&a.sort.changed&&r.push("changes the sort"),a.group&&a.group.changed&&r.push("changes the grouping"),a.pivot&&a.pivot.changed&&r.push("changes the pivot"),i(t.columnsTotalled,"changes % total","changes % totals"),a.pagination&&a.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const d=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"),F=Q.CLS,B=Q.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(H){this.ctx=H,this.doc=H.document,this.host=H.host||{},this.props=H.props||{},this.root=B(this.doc,"div",{class:`${F.panel}__body`}),this.refresh()}t(H,U){const z=this.host||{};if(typeof z.t=="function")return z.t(H,U);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(H,U);const v=w.grid;return(v&&v.messages?v.messages:_).t(H,U)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();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 h}}),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"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,H=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"),v=w.compileRules,g=w.summariseColumn,l=w.needsDistribution,d=w.DISTRIBUTION_LABELS,a="*",n=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}]),r=Object.freeze([{op:"topPercent",label:d.topPercent,values:1},{op:"bottomPercent",label:d.bottomPercent,values:1},{op:"topN",label:d.topN,values:1},{op:"bottomN",label:d.bottomN,values:1},{op:"aboveMean",label:d.aboveMean,values:0},{op:"belowMean",label:d.belowMean,values:0},{op:"aboveMedian",label:d.aboveMedian,values:0},{op:"belowMedian",label:d.belowMedian,values:0},{op:"zAbove",label:d.zAbove,values:1},{op:"zBelow",label:d.zBelow,values:1},{op:"outlier",label:d.outlier,values:0}]),i=Object.freeze([...t,...r]),f=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"}]),u=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"]}]),o=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=i.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:j}=b.scale;if(Number.isFinite(S)&&Number.isFinite(R))return`Colour scale, ${S} to ${R}`;const x=o.find(E=>E.from===j);return x?`Colour scale ${x.label}`:"Colour scale"}const A=b.when||{},k=i.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 h 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=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:a,title:"All columns"},...A]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(A){if(!H(this.host.columnSamples))return[];const k=this.host.columnSamples(A);return Array.isArray(k)?k:[...k||[]]}#r(A,k,y){const S=l(A)?g(k):null;return v(A,S)({value:y})}#o(){const A=$(this.doc,"div",{class:`${F.panel}__row`});A.appendChild($(this.doc,"label",{class:`${F.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const k=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const S=$(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=$(this.doc,"ul",{class:`${F.panel}__list`}),k=this.#t();if(!k.length)return A.appendChild($(this.doc,"li",{class:`${F.panel}__empty`,text:this.t("formatting.noRules")})),A;k.forEach((R,j)=>{const x=$(this.doc,"li",{class:`${F.panel}__item`,attrs:{"data-rule":R.id}}),E=$(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})})),x.appendChild(E);const T=$(this.doc,"span",{class:`${F.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 C=R.scale.colours;T.style.setProperty("background",`linear-gradient(90deg, ${C[0]}, ${C[C.length-1]})`)}x.appendChild(T),x.appendChild($(this.doc,"span",{class:`${F.panel}__text`,text:c(R)}));const P=$(this.doc,"button",{class:`${F.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...j===0?{disabled:"disabled"}:{}}});this.off.push(_(P,"click",()=>this.#c("moveRule",this.scope,R.id,j-1))),x.appendChild(P);const D=$(this.doc,"button",{class:`${F.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...j===k.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,j+1))),x.appendChild(D);const I=$(this.doc,"button",{class:`${F.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(R)}`}});this.off.push(_(I,"click",()=>this.#c("removeRule",this.scope,R.id))),x.appendChild(I),A.appendChild(x)});const y=this.#s(k);y&&A.appendChild(y);const S=$(this.doc,"button",{class:`${F.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=$(this.doc,"div",{class:`${F.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of k.slice(0,n)){const j=this.#r(y,k,R),x=$(this.doc,"span",{class:`${F.panel}__previewcell`,text:String(R)});j&&x.style&&x.style.setProperty&&(j.background&&x.style.setProperty("background",String(j.background)),j.color&&x.style.setProperty("color",String(j.color))),S.appendChild(x)}return S}#l(){const A=$(this.doc,"div",{class:`${F.panel}__form`}),k=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return k.appendChild($(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),k.appendChild($(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=$(this.doc,"div",{class:`${F.panel}__form`}),k=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=$(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const I of t)y.appendChild($(this.doc,"option",{text:I.label,attrs:{value:I.op}}));k.appendChild(y);const S=$(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const I of r)S.appendChild($(this.doc,"option",{text:I.label,attrs:{value:I.op}}));k.appendChild(S),k.value="gt",A.appendChild(k);const R=$(this.doc,"input",{class:`${F.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),j=$(this.doc,"input",{class:`${F.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});A.appendChild(R),A.appendChild(j);const x=()=>{const I=m(k.value);R.style.setProperty("display",I>=1?"":"none"),j.style.setProperty("display",I>=2?"":"none"),P()};this.off.push(_(k,"change",x));const E=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const I of f)E.appendChild($(this.doc,"option",{text:I.name,attrs:{value:I.name}}));E.value=f[0].name,A.appendChild(E);const T=$(this.doc,"div",{class:`${F.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});A.appendChild(T);const L=()=>{const I=f.find(N=>N.name===E.value)||f[0],C=m(k.value),O={op:k.value};return C>=1&&(O.value=R.value),C>=2&&(O.value2=j.value),{when:O,style:{background:I.background,color:I.color}}},P=()=>{X(T);const I=this.#n(this.scope);if(I.length)for(const C of I.slice(0,n)){const O=this.#r([L()],I,C),N=$(this.doc,"span",{class:`${F.panel}__previewcell`,text:String(C)});O&&N.style&&N.style.setProperty&&(O.background&&N.style.setProperty("background",String(O.background)),O.color&&N.style.setProperty("color",String(O.color))),T.appendChild(N)}};this.off.push(_(R,"input",P)),this.off.push(_(j,"input",P)),this.off.push(_(E,"change",P)),x();const D=$(this.doc,"button",{class:`${F.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,L()),R.value="",j.value=""})),A.appendChild(D),A}#u(){const A=$(this.doc,"div",{class:`${F.panel}__form`}),k=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const E of u)k.appendChild($(this.doc,"option",{text:E.name,attrs:{value:E.name}}));k.value=u[0].name,A.appendChild(k);const y=$(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const E of o)y.appendChild($(this.doc,"option",{text:E.label,attrs:{value:E.from}}));y.value=o[0].from,A.appendChild(y);const S=$(this.doc,"div",{class:`${F.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});A.appendChild(S);const R=()=>{const E=u.find(T=>T.name===k.value)||u[0];return{scale:{from:y.value,colours:[...E.colours]}}},j=()=>{X(S);const E=this.#n(this.scope);if(E.length)for(const T of E.slice(0,n)){const L=this.#r([R()],E,T),P=$(this.doc,"span",{class:`${F.panel}__previewcell`,text:String(T)});L&&L.background&&P.style&&P.style.setProperty&&P.style.setProperty("background",String(L.background)),S.appendChild(P)}};this.off.push(_(k,"change",j)),this.off.push(_(y,"change",j)),j();const x=$(this.doc,"button",{class:`${F.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(x,"click",()=>{this.#c("addRule",this.scope,R())})),A.appendChild(x),A}#c(A,...k){H(this.host[A])&&this.host[A](...k),this.refresh()}}function s(b={}){const A=new h;return A.init({document:B(b),host:b.host||{}}),A}const p=h}),Le("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"shouldThinLabels",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=70,w=40;function v(t,r){return!t||!r?!1:t<r*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"}]),l=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),d=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 r=Math.abs(t);return r!==0&&(r<.001||r>=1e7)?t.toExponential(2):String(Number(t.toPrecision(4)))}class n extends U{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const r=this.root;if(!r)return;for(const u of this.off)u();this.off.length=0,_(r);const i=this.#t();if(!i.length){r.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("stats.noColumns")}));return}i.some(u=>u.id===this.column)||(this.column=i[0].id),r.appendChild(this.#o(i));const f=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!f&&W(this.host.columnProfileAsync)){const u=B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("facets.computing")});r.appendChild(u);const o=++this.#e,m=this.column;Promise.resolve(this.host.columnProfileAsync(m)).then(c=>{if(o!==this.#e||this.root!==r||this.column!==m)return;const h=B(this.doc,"div",{});this.#n(h,c);for(const s of[...h.children])r.insertBefore(s,u);r.removeChild(u)},()=>{o!==this.#e||this.root!==r||(u.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(r,f)}#n(r,i){if(!i||!i.present){r.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("stats.noValues")}));const u=this.#r(i);u&&r.appendChild(u);return}if(r.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("stats.filtered",{count:i.rows})})),Array.isArray(i.topValues)){r.appendChild(this.#l(i,l)),r.appendChild(this.#a(i.topValues));const u=this.#r(i);u&&r.appendChild(u);return}if(r.appendChild(this.#l(i)),i.computed!=="source"){for(const o of d){const m=this.#i(o);m&&r.appendChild(m)}const u=this.#s();u&&r.appendChild(u)}i.histogram&&i.histogram.length>1&&r.appendChild(this.#u(i.histogram));const f=this.#r(i);f&&r.appendChild(f)}#r(r){const i=r&&Array.isArray(r.unavailable)?r.unavailable:[];if(!i.length)return null;const f=this.doc.createElement("div");f.setAttribute("data-unavailable",""),f.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("stats.unavailable",{stats:i.map(o=>o.stat).join(", ")})}));const u=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const o of i)u.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:o.stat})),u.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:o.reasonKey?this.t(o.reasonKey,o.reasonParams):o.reason}));return f.appendChild(u),f}#o(r){const i=B(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const f of r){const u=B(this.doc,"option",{text:f.title,attrs:{value:f.id,selected:f.id===this.column?!0:null}});i.appendChild(u)}return i.value=this.column,this.off.push($(i,"change",()=>{this.column=i.value,this.refresh()})),B(this.doc,"label",{class:`${F.panel}__field`,children:[B(this.doc,"span",{class:`${F.panel}__label`,text:this.t("stats.column")}),i]})}#i(r){const i=this.host.reduceColumn;if(!W(i)||!this.column)return null;const f=[];for(const m of r.kernels){const c=i(this.column,m);c==null||Number.isNaN(c)||f.push([m,c])}if(!f.length)return null;const u=this.doc.createElement("div");u.appendChild(B(this.doc,"h4",{class:`${F.panel}__subtitle`,text:this.t(r.label)}));const o=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const[m,c]of f)o.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(`total.${m}`)})),o.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:typeof c=="number"?a(c):String(c)}));return u.appendChild(o),u}#s(){const r=this.host.columnCapability;if(!W(r)||!this.column)return null;const i=r(this.column);if(!i)return null;const f=this.doc.createElement("div");f.appendChild(B(this.doc,"h4",{class:`${F.panel}__subtitle`,text:this.t("stats.section.capability")}));const u=B(this.doc,"dl",{class:`${F.panel}__stats`}),o=[["stats.cp",i.cp,null],["stats.cpk",i.cpk,i.interval],["stats.pp",i.pp,null],["stats.ppk",i.ppk,i.intervalPp],["stats.outOfSpec",i.outOfSpec,null]];for(const[m,c,h]of o){if(c==null)continue;u.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(m)}));const s=[B(this.doc,"span",{text:a(c)})];h&&Number.isFinite(h.lower)&&s.push(B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:`${a(h.lower)} – ${a(h.upper)}`,attrs:{title:`${Math.round(h.confidence*100)}%`}})),u.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,children:s}))}return f.appendChild(u),f}#l(r,i=g){const f=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const u of i){const o=r[u.key];f.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(u.label)})),f.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:u.kind==="count"?String(o??0):a(o)}))}return f}#a(r){const i=this.doc.createElement("div");i.appendChild(B(this.doc,"h4",{class:`${F.panel}__subtitle`,text:this.t("stats.topValues")}));const f=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const u of r)f.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:String(u.value)})),f.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,children:[B(this.doc,"span",{text:String(u.count)}),B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:`${Math.round(u.share*100)}%`})]}));return i.appendChild(f),i}#u(r){const i=r.reduce((m,c)=>Math.max(m,c.count),0)||1,f=B(this.doc,"div",{class:`${F.panel}__histogram`});f.appendChild(B(this.doc,"h4",{class:`${F.panel}__subtitle`,text:this.t("stats.distribution.detail")}));const u=B(this.doc,"ul",{class:`${F.panel}__histogram-list`,attrs:{role:"list","aria-label":this.t("stats.distribution.detail")}}),o=[];for(const m of r){const c=m.count||0,h=c?Math.max(2,c/i*100):0,s=String(c),p=h>=z,b=B(this.doc,"div",{class:`${F.panel}__bar`,style:{width:`${h}%`},children:p?[B(this.doc,"span",{class:`${F.panel}__bin-count ${F.panel}__bin-count--inside`,text:s})]:[]}),A=B(this.doc,"div",{class:`${F.panel}__bin-track`,children:p?[b]:[b,B(this.doc,"span",{class:`${F.panel}__bin-count ${F.panel}__bin-count--outside`,text:s})]}),k=B(this.doc,"span",{class:`${F.panel}__bin-range`,text:`${a(m.from)}–${a(m.to)}`});o.push(k);const y=this.t("stats.bin",{count:c,from:a(m.from),to:a(m.to)});u.appendChild(B(this.doc,"li",{class:`${F.panel}__bin`,attrs:{title:y,"aria-label":y},children:[k,A]}))}return f.appendChild(u),this.#c(f,u,o),f}#c(r,i,f){const u=globalThis.ResizeObserver;if(!W(u))return;const o=()=>{const c=r.clientWidth||(W(r.getBoundingClientRect)?r.getBoundingClientRect().width:0);if(!c)return;let h=0;for(const s of f){const p=s.scrollWidth||(W(s.getBoundingClientRect)?s.getBoundingClientRect().width:0);p>h&&(h=p)}i.classList.toggle(`${F.panel}__histogram-list--thin`,v(c,h))},m=new u(o);m.observe(r),this.off.push(()=>m.disconnect()),o()}}}),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"),F=Q.CLS,B=Q.el,$=Q.clear,X=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function U(v,g=4){const l=Number(v);return Number.isFinite(l)?l.toFixed(g):l===1/0?"∞":"—"}class z extends H{#e(){const g=this.props||{};if(Array.isArray(g.predictors)&&g.predictors.length&&g.response)return g;const l=this.ctx&&this.ctx.grid,d=l&&X(l.get)?l.get("regression"):null;return d&&Array.isArray(d.predictors)&&d.response?d:null}refresh(){const g=this.root;if(!g)return;$(g);const l=this.#e();if(!l){g.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("regression.noModel")}));return}const d=X(this.host.regressionModel)?this.host.regressionModel(l):null;if(!d){g.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("regression.observations",{count:d.n})})),g.appendChild(this.#t(d)),g.appendChild(this.#n(d));const a=this.#r(d,l);a&&g.appendChild(a),g.appendChild(this.#o(d))}#t(g){const l=B(this.doc,"dl",{class:`${F.panel}__stats`}),d=(a,n)=>{l.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-label`,text:a})),l.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:n}))};return d(this.t("regression.r2"),U(g.r2,4)),d(this.t("regression.adjR2"),U(g.adjR2,4)),l}#n(g){const l=B(this.doc,"div",{class:`${F.panel}__section`});l.appendChild(B(this.doc,"h4",{class:`${F.panel}__heading`,text:this.t("regression.coefficients")}));const d=B(this.doc,"table",{class:`${F.panel}__coef-table`}),a=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])a.appendChild(B(this.doc,"th",{text:this.t(n)}));d.appendChild(a);for(const n of g.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${U(n.estimate)} ± ${U(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:U(n.stdError)})),t.appendChild(B(this.doc,"td",{text:U(n.t,3)})),t.appendChild(B(this.doc,"td",{text:U(n.p,4)})),d.appendChild(t)}return l.appendChild(d),l}#r(g,l){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const d=B(this.doc,"div",{class:`${F.panel}__section`});d.appendChild(B(this.doc,"h4",{class:`${F.panel}__heading`,text:this.t("regression.vif")}));const a=B(this.doc,"dl",{class:`${F.panel}__stats`});return g.vif.forEach((n,t)=>{a.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-label`,text:l.predictors[t]})),a.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:U(n,3)}))}),d.appendChild(a),d}#o(g){const l=g.heteroscedasticity,d=B(this.doc,"div",{class:`${F.panel}__section`});return d.appendChild(B(this.doc,"h4",{class:`${F.panel}__heading`,text:this.t("regression.heteroscedasticity")})),l?(d.appendChild(B(this.doc,"p",{class:`${F.panel}__flag`,attrs:{"data-heteroscedastic":l.heteroscedastic?"true":"false"},text:this.t(l.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:U(l.statistic,3),p:U(l.p,4)})})),d):(d.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("regression.cannotFit")})),d)}}const w=z}),Le("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return v}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=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 l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class v extends U{first=null;second=null;#e(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const l=this.root;if(!l)return;for(const t of this.off)t();this.off.length=0,_(l);const d=this.#e();if(d.length<2){l.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("compare.needTwo")}));return}d.some(t=>t.id===this.first)||(this.first=d[0].id),(!d.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(d.find(t=>t.id!==this.first)||d[0]).id),l.appendChild(this.#t("compare.first",d,this.first,t=>{this.first=t,this.second===t&&(this.second=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()})),l.appendChild(this.#t("compare.second",d,this.second,t=>{this.second=t,this.first===t&&(this.first=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()}));const a=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!a||!a.n){l.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("compare.noPairs")}));return}l.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("compare.pairs",{count:a.n})}));const n=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const t of z){const r=a[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,text:w(r)})))}l.appendChild(n)}#t(l,d,a,n){const t=B(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===a?!0:null}}));return t.value=a,this.off.push($(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${F.panel}__field`,children:[B(this.doc,"span",{class:`${F.panel}__label`,text:this.t(l)}),t]})}}}),Le("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return v}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=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 l=Math.abs(g);return l!==0&&(l<.001||l>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class v extends U{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const l=this.root;if(!l)return;for(const i of this.off)i();this.off.length=0,_(l);const d=this.#e();if(!d.length){l.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("insights.empty")}));return}const a=this.#t();a&&l.appendChild(a);const n=this.#n();n&&l.appendChild(n),l.appendChild(this.#o(d));const t=this.#s();t&&l.appendChild(t);const r=this.#u();r&&l.appendChild(r)}#t(){if(!W(this.host.subsetVsPopulation))return null;const l=this.host.subsetVsPopulation();if(!l)return null;const d=this.#c("insights.subset");return l.filtered?(d.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("stats.filtered",{count:l.subsetN})})),d.appendChild(this.#r(l.ranked)),d):(d.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("insights.noFilter")})),d)}#n(){const l=this.props&&this.props.other;if(!l||!W(this.host.datasetVsDataset))return null;let d;try{d=this.host.datasetVsDataset(l)}catch{return null}if(!d||!d.ranked)return null;const a=this.#c("insights.dataset");return a.appendChild(this.#r(d.ranked)),a}#r(l){const d=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const a of l||[]){const n=B(this.doc,"dt",{class:`${F.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(a.name??a.column)})),n.appendChild(B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:String(a.measure||"")}));const t=B(this.doc,"dd",{class:`${F.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:w(a.magnitude)})),a.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:this.t("insights.smallSample")})),d.appendChild(n),d.appendChild(t)}return d}#o(l){const d=this.#c("insights.groups");l.some(n=>n.id===this.column)||(this.column=l[0].id),(!l.some(n=>n.id===this.by)||this.by===this.column)&&(this.by=(l.find(n=>n.id!==this.column)||l[0]).id),d.appendChild(this.#d("stats.column",l,this.column,n=>{this.column=n,this.by===n&&(this.by=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()})),d.appendChild(this.#d("insights.by",l,this.by,n=>{this.by=n,this.column===n&&(this.column=(l.find(t=>t.id!==n)||l[0]).id),this.refresh()}));const a=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return a?(d.appendChild(this.#i(a)),d):(d.appendChild(B(this.doc,"p",{class:`${F.panel}__empty`,text:this.t("insights.needGroups")})),d)}#i(l){const d=B(this.doc,"dl",{class:`${F.panel}__stats`});Array.isArray(l.groups)&&l.groups.length===2&&this.#a(d,"insights.groups",`${l.groups[0]} · ${l.groups[1]}`),this.#a(d,"insights.test",String(l.method||l.test||""));const a=l.effectSize||{};this.#a(d,"insights.effect",`${a.name||""} ${w(a.value)}`.trim());const n=l.interval;let t="—";if(n&&Number.isFinite(n.lower)&&Number.isFinite(n.upper)){const i=Number.isFinite(n.confidence)?` (${Math.round(n.confidence*100)}%)`:"";t=`${w(n.lower)} – ${w(n.upper)}${i}`}const r=this.#a(d,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(l.pValue)&&this.#a(d,"insights.pValue",w(l.pValue)),d}#s(){if(!W(this.host.anomalies))return null;let l;try{l=this.host.anomalies()}catch{return null}if(!l)return null;const d=this.#c("insights.anomalies");d.appendChild(B(this.doc,"p",{class:`${F.panel}__count`,text:this.t("insights.anomalyCount",{count:l.flagged||0,n:l.n||0})}));const a=B(this.doc,"dl",{class:`${F.panel}__stats`});this.#a(a,"insights.anomalyMethod",String(l.method||""));const n=this.#l(l);n!==null&&this.#a(a,"insights.anomalyThreshold",w(n)),d.appendChild(a);const t=(l.rows||[]).map(r=>({name:r.rowKey!=null?String(r.rowKey):`#${r.index}`,measure:(r.why||[]).map(i=>i.name||i.column).join(", "),magnitude:r.score}));return d.appendChild(this.#r(t)),d}#l(l){if(l.method==="mahalanobis")return Number.isFinite(l.cutoff)?l.cutoff:null;if(l.method==="iqr")return Number.isFinite(l.k)?l.k:null;const d=Array.isArray(l.columns)?l.columns[0]:null;return d&&Number.isFinite(d.threshold)?d.threshold:null}#a(l,d,a){l.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(d)}));const n=B(this.doc,"dd",{class:`${F.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:a})),l.appendChild(n),n}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const l=this.host.columnCapability(this.column);if(!l)return null;const d=this.#c("stats.section.capability"),a=B(this.doc,"dl",{class:`${F.panel}__stats`});for(const n of z){const t=l[n.field];if(t==null)continue;a.appendChild(B(this.doc,"dt",{class:`${F.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:w(t)})],i=n.interval?l[n.interval]:null;i&&Number.isFinite(i.lower)&&r.push(B(this.doc,"span",{class:`${F.panel}__stat-interval`,text:`${w(i.lower)} – ${w(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),a.appendChild(B(this.doc,"dd",{class:`${F.panel}__stat-value`,children:r}))}return d.appendChild(a),d}#c(l){const d=this.doc.createElement("div");return d.appendChild(B(this.doc,"h4",{class:`${F.panel}__subtitle`,text:this.t(l)})),d}#d(l,d,a,n){const t=B(this.doc,"select",{class:`${F.panel}__select`,attrs:{"aria-label":this.t(l)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===a?!0:null}}));return t.value=a,this.off.push($(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${F.panel}__field`,children:[B(this.doc,"span",{class:`${F.panel}__label`,text:this.t(l)}),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 j}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),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 P}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.cssEscape,$=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,U=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),w=z.isFunction,v=z.nextFrame,g=K("packages/dom/src/cell/icons.js"),l=g.createIcon,d=g.updateIcon,a=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,i=K("packages/dom/src/formattingpanel.js").FormattingPanel,u=K("packages/dom/src/statisticspanel.js").StatisticsPanel,m=K("packages/dom/src/regressionpanel.js").RegressionPanel,h=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 C=this.root;if(!C)return;for(const Z of this.off)Z();this.off.length=0,W(C);const O=_(this.doc,"input",{class:`${F.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(O.value=this.query),this.off.push(X(O,"input",()=>{this.query=O.value,this.paintList()})),C.appendChild(O),C.appendChild(this.buildZone("group","Row groups")),C.appendChild(this.buildZone("values","Grouped row calculation")),C.appendChild(this.buildZone("pivot","Pivot"));const N=_(this.doc,"div",{class:`${F.panel}__heading`});N.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${F.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${F.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),C.appendChild(N),this.list=_(this.doc,"div",{class:`${F.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),C.appendChild(this.list),this.paintList()}columns(){const C=this.host;return w(C.columns)?C.columns()||[]:C.columns&&w(C.columns.all)?C.columns.all():[]}paintList(){const C=this.list;if(!C)return;W(C);const O=String(this.query||"").trim().toLowerCase();this.paintNodes(C,this.bandTree(),O)}paintNodes(C,O,N,G=!1){let q=0;for(const Z of O){if(Z.column){const ae=String(Z.column.title||Z.column.id||"");if(N&&!G&&!ae.toLowerCase().includes(N))continue;C.appendChild(this.buildColumnRow(Z.column)),q++;continue}const J=!!N&&this.bandTitle(Z.band).toLowerCase().includes(N),te=_(this.doc,"div",{class:`${F.panel}__bandBody`}),ne=this.paintNodes(te,Z.children,N,G||J);if(N&&!ne&&!J)continue;const oe=_(this.doc,"div",{class:`${F.panel}__band`,attrs:{role:"group","aria-label":this.bandTitle(Z.band),"data-band":Z.band.id}}),le=!this.collapsed.has(Z.band.id);oe.appendChild(this.buildBandRow(Z,le)),(le||N)&&oe.appendChild(te),C.appendChild(oe),q++}return q}bandTree(){const C=this.columns(),O=new Map,N=this.host;if(w(N.columnGroups)){const Z=J=>{for(const te of J||[])Array.isArray(te.columns)&&(O.set(te.id,te.title),Z(te.columns))};Z(N.columnGroups())}const G=[],q=new Map;for(const Z of C){let J=G,te="";for(const ne of Z.groupPath||[]){te+=`/${ne}`;let oe=q.get(te);oe||(oe={band:{id:ne,title:O.has(ne)?O.get(ne):""},children:[],ids:[]},q.set(te,oe),J.push(oe)),oe.ids.push(Z.id),J=oe.children}J.push({column:Z})}return G}bandTitle(C){return String(C.title||"")||this.t("columngroup.untitled")}buildColumnRow(C){const O=String(C.title||C.id||""),N=_(this.doc,"div",{class:`${F.panel}__column`,attrs:{"data-col":C.id,draggable:"true",title:this.t("panel.columnDragHint",{column:O})}});N.appendChild(_(this.doc,"span",{class:`${F.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":O}});return G.checked=!(C.layout&&C.layout.hidden),C.layout&&C.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(C.id,G.checked))),N.appendChild(G),N.appendChild(_(this.doc,"span",{text:O})),N.setAttribute("tabindex","0"),N.setAttribute("role","listitem"),this.off.push(X(N,"keydown",q=>this.onRowKey(q,C))),this.off.push(X(N,"dragstart",()=>{this.dragging=C.id})),this.off.push(X(N,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(N,"dragover",q=>{if(!this.dragging||this.dragging===C.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,C)){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===C.id)return;const J=this.bandDrop(Z,C);if(J==="leave"){this.leaveBand(Z);return}if(J){this.joinBand(Z,J);return}this.moveColumn(Z,C.id,D(q,N))})),N}bandOf(C){const O=typeof C=="string"?this.columns().find(G=>G.id===C):C,N=O&&O.groupPath||[];return N.length?N[N.length-1]:null}bandDrop(C,O){const N=this.host;if(!w(N.groupColumns))return null;const G=this.bandOf(C),q=this.bandOf(O);return q&&q!==G?q:G&&!q?"leave":null}joinBand(C,O){const N=this.columns().find(q=>q.id===C),G=this.titleOf(C);if(N&&N.layout&&N.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([C],{groupId:O}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(O)}),{repeat:!0}),this.refresh()}leaveBand(C){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(C),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(C)}),{repeat:!0}),this.refresh())}bandName(C){const O=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===C)return q.band;const Z=O(q.children);if(Z)return Z}return null},N=O(this.bandTree());return N?this.bandTitle(N):C}buildBandRow(C,O){const{band:N,ids:G}=C,q=this.bandTitle(N),Z=_(this.doc,"div",{class:`${F.panel}__bandRow`,attrs:{"data-band-row":N.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${F.panel}__bandToggle`,attrs:{type:"button","aria-expanded":O?"true":"false","aria-label":this.t(O?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:O?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(N.id))),Z.appendChild(J);const te=new Map(this.columns().map(se=>[se.id,se])),ne=G.filter(se=>!(te.get(se).layout&&te.get(se).layout.hidden)).length,oe=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":this.t("panel.bandVisible",{band:q})}});oe.checked=ne===G.length,oe.indeterminate=ne>0&&ne<G.length,ne>0&&ne<G.length&&oe.setAttribute("aria-checked","mixed");const le=G.filter(se=>!(te.get(se).layout&&te.get(se).layout.lockVisible));le.length||oe.setAttribute("disabled",""),this.off.push(X(oe,"change",()=>{const se=this.host;oe.checked?w(se.showColumns)&&se.showColumns(le):w(se.hideColumns)&&se.hideColumns(le),this.refresh()})),Z.appendChild(oe);const ae=_(this.doc,"span",{class:`${F.panel}__bandTitle`,text:q});if(Z.appendChild(ae),w(this.host.renameGroup)){const se=_(this.doc,"button",{class:`${F.panel}__link`,text:this.t("columngroup.rename"),attrs:{type:"button","aria-label":this.t("panel.bandRenameFor",{band:q})}});this.off.push(X(se,"click",()=>this.startBandRename(Z,ae,N))),Z.appendChild(se)}if(w(this.host.dissolveGroup)){const se=_(this.doc,"button",{class:`${F.panel}__link`,text:this.t("columngroup.dissolve"),attrs:{type:"button","aria-label":this.t("panel.bandDissolveFor",{band:q})}});this.off.push(X(se,"click",()=>this.dissolveBand(N.id))),Z.appendChild(se)}return this.off.push(X(Z,"keydown",se=>this.onBandKey(se,N,Z))),this.off.push(X(Z,"dragover",se=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===N.id||(w(se.preventDefault)&&se.preventDefault(),Z.setAttribute("data-drop","into"))})),this.off.push(X(Z,"dragleave",()=>Z.removeAttribute("data-drop"))),this.off.push(X(Z,"drop",se=>{w(se.preventDefault)&&se.preventDefault();const ee=this.dragging;this.dragging=null,this.clearDropMark(),!(!ee||!w(this.host.groupColumns)||this.bandOf(ee)===N.id)&&this.joinBand(ee,N.id)})),Z}toggleBand(C){this.collapsed.has(C)?this.collapsed.delete(C):this.collapsed.add(C),this.paintList(),this.focusBand(C)}focusBand(C){const O=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${B(C)}"]`):null;O&&w(O.focus)&&O.focus()}dissolveBand(C){if(!w(this.host.dissolveGroup))return;const O=this.bandName(C);this.collapsed.delete(C),this.host.dissolveGroup(C),this.announce(this.t("a11y.group.dissolved",{group:O}),{repeat:!0}),this.refresh()}startBandRename(C,O,N){const G=_(this.doc,"input",{class:`${F.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))),O.parentNode&&O.parentNode.replaceChild(G,O),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(C,O,N){if(C.target&&C.target!==N)return;const G=C.key;G==="Enter"?(w(C.preventDefault)&&C.preventDefault(),this.toggleBand(O.id)):G==="Delete"?(w(C.preventDefault)&&C.preventDefault(),this.dissolveBand(O.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(C.preventDefault)&&C.preventDefault(),this.walk(N,G==="ArrowUp"))}walk(C,O){const N=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=N.indexOf(C),q=N[G+(O?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(C,O){const N=C&&C.key,G=S.zoneKeys[String(N).toLowerCase()];if(G&&!C.ctrlKey&&!C.metaKey&&!C.altKey){w(C.preventDefault)&&C.preventDefault(),this.toggleZone(G,O);return}if(N!=="ArrowUp"&&N!=="ArrowDown")return;const q=N==="ArrowUp",Z=this.columns().map(ae=>ae.id),J=Z.indexOf(O.id);if(J<0)return;if(w(C.preventDefault)&&C.preventDefault(),!C.shiftKey){const ae=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],se=ae.findIndex(ie=>ie.getAttribute("data-col")===O.id),ee=ae[se+(q?-1:1)];ee&&w(ee.focus)&&ee.focus();return}const te=O.layout&&(O.layout.movable===!1||O.layout.lockPosition),ne=String(O.title||O.id||"");if(te){this.announce(this.t("a11y.panel.cannotMove",{column:ne}),{repeat:!0});return}const oe=Z[J+(q?-1:1)];if(!oe){this.announce(this.t(q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ne}),{repeat:!0});return}this.moveColumn(O.id,oe,q),this.announce(this.t("a11y.panel.moved",{column:ne,at:q?J:J+2,of:Z.length}),{repeat:!0});const le=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(O.id)}"]`):null;le&&w(le.focus)&&le.focus()}toggleZone(C,O){const N=this.titleOf(O.id),G=this.t(S.zoneLabel[C]||"panel.zone.group");if(this.zoneColumns(C).includes(O.id)){this.dropFromZone(C,O.id),this.announce(this.t("a11y.panel.removedFrom",{column:N,list:G}),{repeat:!0}),this.restoreFocus(O.id);return}if(this.addToZone(C,O.id)){this.announce(this.t("a11y.panel.addedTo",{column:N,list:G}),{repeat:!0}),this.restoreFocus(O.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:N,list:G}),{repeat:!0})}restoreFocus(C){const O=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(C)}"]`):null;O&&w(O.focus)&&O.focus()}announce(C,O){const N=this.host||{};w(N.announce)&&N.announce(C,O)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const C of this.list.querySelectorAll("[data-drop]"))C.removeAttribute("data-drop")}moveColumn(C,O,N){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(C,O,N),this.refresh())}buildZone(C,O){const N=_(this.doc,"div",{class:`${F.panel}__zone`,attrs:{"data-zone":C,role:"group","aria-label":O}});N.appendChild(_(this.doc,"div",{class:`${F.panel}__zoneTitle`,text:O}));const G=this.zoneColumns(C);let q=S.zoneAbout[C]||"";C==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&N.appendChild(_(this.doc,"div",{class:`${F.panel}__zoneAbout`,text:q}));const Z=_(this.doc,"div",{class:`${F.panel}__zoneBody`});G.length||Z.appendChild(_(this.doc,"span",{class:`${F.panel}__zoneHint`,text:this.t(S.zoneHint[C]||"panel.zoneHint.any")})),C==="values"&&Z.classList.add(`${F.panel}__zoneBody--rows`);for(const J of G){const te=_(this.doc,"span",{class:[F.chip,C==="values"?`${F.chip}--row`:""]});if(te.appendChild(_(this.doc,"span",{class:`${F.chip}__label`,text:this.titleOf(J)})),C==="values"&&w(this.host.setValueAggregation)){const oe=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",le=_(this.doc,"select",{class:`${F.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const ae of S.aggregations)le.appendChild(_(this.doc,"option",{text:this.t(`total.${ae.name}`),attrs:{value:ae.name,selected:ae.name===oe?"":null}}));le.value=oe,this.off.push(X(le,"change",()=>{this.host.setValueAggregation(J,le.value),this.refresh()})),te.appendChild(le)}const ne=_(this.doc,"button",{class:F.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(ne,"click",()=>this.dropFromZone(C,J))),te.appendChild(ne),Z.appendChild(te)}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(C,this.dragging)})),N.appendChild(Z),N}static aggregations=Object.freeze(Object.keys(y).map(C=>({name:C})));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(C){const O=S.zoneApi[C],N=this.host;return O&&w(N[O.read])?N[O.read]()||[]:[]}titleOf(C){const O=this.columns().find(N=>N.id===C);return String(O&&(O.title||O.id)||C)}addToZone(C,O){const N=S.zoneApi[C],G=this.columns().find(Z=>Z.id===O);if(!N||!G||G[N.permission]===!1||!w(this.host[N.write]))return!1;const q=this.zoneColumns(C);return q.includes(O)?!1:(this.host[N.write]([...q,O]),this.refresh(),!0)}dropFromZone(C,O){const N=S.zoneApi[C];return!N||!w(this.host[N.write])?!1:(this.host[N.write](this.zoneColumns(C).filter(G=>G!==O)),this.refresh(),!0)}setVisible(C,O){const N=this.host;O&&w(N.showColumns)?N.showColumns([C]):!O&&w(N.hideColumns)&&N.hideColumns([C])}}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 C=this.root;if(!C)return;for(const te of this.off)te();this.off.length=0,W(C);const O=this.host,N=(w(O.columns)?O.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!w(O.filterFor))return;const G=N.filter(te=>this.isFiltered(te.id));C.appendChild(this.buildSearch()),C.appendChild(this.buildSummary(G.length,N.length));const q=this.query.trim().toLowerCase(),Z=q?N.filter(te=>String(te.title||te.id).toLowerCase().includes(q)):N;if(!Z.length){C.appendChild(_(this.doc,"p",{class:`${F.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${F.panel}__filters`});for(const te of Z)J.appendChild(this.buildSection(te));C.appendChild(J)}isFiltered(C){const O=this.host;return w(O.isFiltered)?O.isFiltered(C)===!0:!1}buildSearch(){const C=_(this.doc,"input",{class:`${F.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return C.value=this.query,this.off.push(X(C,"input",()=>{this.query=C.value||"",this.refresh();const O=this.root&&this.root.querySelector?this.root.querySelector(`.${F.panel}__search`):null;O&&w(O.focus)&&O.focus()})),C}buildSummary(C,O){const N=_(this.doc,"div",{class:`${F.panel}__filterSummary`});if(N.appendChild(_(this.doc,"span",{class:`${F.panel}__filterCount`,text:C?this.t("panel.filterSummaryActive",{active:C,total:O}):this.t("panel.filterSummaryNone",{total:O}),attrs:{"data-active":C?"true":"false"}})),!C)return N;const G=_(this.doc,"button",{class:`${F.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(C){const O=C.id,N=String(C.title||O),G=this.isFiltered(O),q=this.open.has(O),Z=_(this.doc,"section",{class:`${F.panel}__filter`,attrs:{"data-col":O,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${F.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:N})},children:[l(this.doc,q?"chevronDown":"chevronRight",{className:`${F.panel}__twisty`}),_(this.doc,"span",{class:`${F.panel}__filterName`,text:N})]});G&&J.appendChild(_(this.doc,"span",{class:`${F.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=_(this.doc,"div",{class:`${F.panel}__filterBody`,style:{display:q?"":"none"}}),ne=()=>{if(te.firstChild)return;const oe=this.host.filterFor(O);oe&&w(oe.element)&&te.appendChild(oe.element())};if(this.off.push(X(J,"click",()=>{const oe=this.open.has(O);oe?this.open.delete(O):this.open.add(O),J.setAttribute("aria-expanded",oe?"false":"true"),te.style.display=oe?"none":"";const le=J.firstElementChild;le&&d(le,oe?"chevronRight":"chevronDown"),oe||ne()})),Z.appendChild(J),G){const oe=_(this.doc,"button",{class:`${F.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:N}),title:this.t("panel.clearFilter")},children:[l(this.doc,"close",{className:F.icon})]});this.off.push(X(oe,"click",le=>{w(le.stopPropagation)&&le.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(O),this.refresh()})),Z.appendChild(oe)}return Z.appendChild(te),q&&ne(),Z}}class j extends A{refresh(){const C=this.root;if(!C)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(C);const O=w(this.host.quickFilter)?this.host.quickFilter():"",N=_(this.doc,"input",{class:`${F.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});N.value=O||"",this.off.push(X(N,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(N.value),this.paintCount()})),C.appendChild(N),this.box=N;const G=_(this.doc,"button",{class:`${F.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()})),C.appendChild(G),this.count=_(this.doc,"p",{class:`${F.panel}__count`}),C.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){v(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const C=w(this.host.rowCount)?this.host.rowCount():null,O=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(C===null||O===null||C===void 0){this.count.textContent="";return}this.count.textContent=C===O?this.t("count.rows",{count:O}):this.t("panel.rowsOf",{shown:C,total:O})}}const x=Object.freeze({columns:S,filters:R,views:t,quick:j,formatting:i,statistics:u,regression:m,compare:h,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(C,O){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(C,O)}init(C){const O=C||{};this.doc=$(O),this.host=O.host||{},this.grid=O.grid||null,this.messages=O.messages||O.grid&&O.grid.messages||U,this.icons=O.icons===void 0?O.side==="left":!!O.icons,this.side=O.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[F.panel,`${F.panel}--${this.side}`,this.icons?`${F.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${F.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${F.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:`${F.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(O.actions)?O.actions:[])this.registerAction(q);const N=O.registry||{},G=Array.isArray(O.panels)&&O.panels.length?O.panels:["columns","filters"];for(const q of G){const Z=q!==null&&typeof q=="object",J=Z?q.name:q,te=w(J),ne=te?J.name||"panel":String(J),oe=Z&&w(q.Ctor)?q.Ctor:te?J:N[ne]||x[ne];oe&&this.registerPanel(ne,oe,Z?q:{})}O.openPanel&&this.show(O.openPanel)}registerPanel(C,O,N){const G=new O;G.init({document:this.doc,host:this.host,grid:this.grid,props:N&&N.props||{}});const q=N&&N.title||C,Z=N&&N.icon||C,J=_(this.doc,"button",{class:`${F.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":C,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(l(this.doc,Z,{className:`${F.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(C))),this.tabs.appendChild(J),this.panels.push({name:C,title:q,panel:G}),G}registerAction(C){if(!C||!C.name)return null;if(C.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${F.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const O=_(this.doc,"button",{class:`${F.panel}__action`,text:this.icons?null:w(C.title)?String(C.title()):C.title,attrs:{type:"button","data-action":C.name,title:w(C.title)?null:C.title,"aria-label":w(C.title)?null:C.title}});if(this.icons){const q=(w(C.icon)?C.icon():C.icon)||(a(C.name)?C.name:"blank");O.appendChild(l(this.doc,q,{className:`${F.panel}__icon`})),O.setAttribute("data-icon",q)}const N=X(O,"click",()=>{w(C.enabled)&&!C.enabled()||(w(C.run)&&C.run(),this.paintActions())});return this.off.push(N),this.actionGroup.appendChild(O),this.actions.push({...C,button:O,offClick:N}),this.paintActions(),O}removeAction(C){const O=this.actions.findIndex(G=>G.name===C);if(O<0)return!1;const N=this.actions[O];return w(N.offClick)&&N.offClick(),N.button&&N.button.parentNode&&N.button.parentNode.removeChild(N.button),this.actions.splice(O,1),!0}paintActions(){for(const C of this.actions){if(!C.button)continue;const O=w(C.enabled)?!!C.enabled():!0;if(C.button.disabled=!O,C.button.setAttribute("aria-disabled",O?"false":"true"),w(C.active)&&C.button.setAttribute("aria-pressed",C.active()?"true":"false"),w(C.title)){const N=String(C.title());C.button.setAttribute("title",N),C.button.setAttribute("aria-label",N),!this.icons&&C.button.textContent!==N&&(C.button.textContent=N)}if(this.icons&&w(C.icon)){const N=String(C.icon());C.button.getAttribute("data-icon")!==N&&(W(C.button),C.button.appendChild(l(this.doc,N,{className:`${F.panel}__icon`})),C.button.setAttribute("data-icon",N))}}}show(C){const O=this.panels.find(N=>N.name===C);return O?(W(this.body),w(O.panel.refresh)&&O.panel.refresh(),this.body.appendChild(O.panel.element()),this.openPanel=C,this.paintTabs(),w(O.panel.focus)&&O.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(C){this.openPanel===C?this.hide():this.show(C)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let C=0;C<this.tabs.childNodes.length;C++){const O=this.tabs.childNodes[C];O&&O.setAttribute&&O.setAttribute("aria-selected",O.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const C=this.panels.find(O=>O.name===this.openPanel);C&&w(C.panel.refresh)&&!this.#e(C.panel)&&C.panel.refresh(),this.paintActions()}#e(C){const O=this.doc&&this.doc.activeElement;if(!O||O===this.doc.body)return!1;const N=w(C.element)?C.element():null;return!!(N&&w(N.contains)&&N.contains(O))}destroy(){for(const C of this.off)C();this.off.length=0;for(const C of this.panels)w(C.panel.destroy)&&C.panel.destroy();this.panels=[],this.root=null}}const P=L;function D(I,C){if(!C.getBoundingClientRect||typeof I.clientY!="number")return!0;const O=C.getBoundingClientRect();return I.clientY<O.top+O.height/2}}),Le("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return v}});const F=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),$=B.CLS,_=B.el,X=B.on,W=B.clear,H=B.cssEscape,z=K("packages/core/src/internal/util.js").isFunction,w="text/x-lattice-col";class v extends F{dragging=null;#e=[];init(l){this.ctx=l,this.doc=l.document,this.host=l.host||{},this.props=l.props||{},this.root=_(this.doc,"div",{class:$.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const l=this.host;return z(l.columns)?l.columns()||[]:l.columns&&z(l.columns.all)?l.columns.all():[]}groups(){return z(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(l){z(this.host.setGroupBy)&&this.host.setGroupBy(l)}titleOf(l){const d=this.columns().find(a=>a.id===l);return String(d&&(d.title||d.id)||l)}canGroup(l){const d=this.columns().find(a=>a.id===l);return!!d&&d.allowGroup!==!1&&!d.generated}announce(l,d){z(this.host.announce)&&this.host.announce(l,d)}refresh(){const l=this.root;if(!l)return;for(const n of this.off)n();this.off.length=0,W(l),l.appendChild(_(this.doc,"span",{class:$.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const d=this.groups(),a=_(this.doc,"div",{class:$.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});d.length||a.appendChild(_(this.doc,"span",{class:$.groupZoneHint,text:this.t("groupZone.hint")})),d.forEach((n,t)=>a.appendChild(this.#t(n,t,d.length))),l.appendChild(a),this.chips=a,l.appendChild(this.#i(d)),this.off.push(X(l,"dragover",n=>{this.dragging==null&&!this.#l(n)||(z(n.preventDefault)&&n.preventDefault(),l.setAttribute("data-over","true"))})),this.off.push(X(l,"dragleave",()=>l.removeAttribute("data-over"))),this.off.push(X(l,"drop",n=>{z(n.preventDefault)&&n.preventDefault(),l.removeAttribute("data-over");const t=this.#l(n)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(l,d,a){const n=this.titleOf(l),t=_(this.doc,"div",{class:[$.chip,$.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":l,"aria-label":this.t("groupZone.chip",{column:n,at:d+1,of:a})}});t.appendChild(_(this.doc,"span",{class:$.groupZoneChipText,text:n}));const r=_(this.doc,"button",{class:$.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(X(r,"click",()=>this.#r(l))),t.appendChild(r),this.off.push(X(t,"dragstart",i=>{this.dragging=l,i.dataTransfer&&z(i.dataTransfer.setData)&&i.dataTransfer.setData(w,l)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",i=>{const f=this.#l(i)||this.dragging;f==null||f===l||z(i.preventDefault)&&i.preventDefault()})),this.off.push(X(t,"drop",i=>{const f=this.#l(i)||this.dragging;f!=null&&(z(i.preventDefault)&&i.preventDefault(),z(i.stopPropagation)&&i.stopPropagation(),this.#o(f,d))})),this.off.push(X(t,"keydown",i=>this.#n(i,l,d))),t}#n(l,d,a){const n=l&&l.key,t=this.groups();if(n==="Delete"||n==="Backspace"){z(l.preventDefault)&&l.preventDefault(),this.#r(d,t,a);return}const r=n==="ArrowLeft"||n==="ArrowUp",i=n==="ArrowRight"||n==="ArrowDown",f=n==="Home",u=n==="End";if(!r&&!i&&!f&&!u)return;if(z(l.preventDefault)&&l.preventDefault(),l.shiftKey&&(r||i)){const c=a+(r?-1:1);if(c<0||c>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(d)}),{repeat:!0});return}const h=t.slice();h.splice(a,1),h.splice(c,0,d),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(d),at:c+1,of:h.length}),{repeat:!0}),this.#a(d);return}let o=a+(r?-1:i?1:0);f&&(o=0),u&&(o=t.length-1);const m=t[o];m&&this.#a(m)}#r(l,d=this.groups(),a=d.indexOf(l)){const n=this.titleOf(l);this.setGroups(d.filter(r=>r!==l)),this.announce(this.t("a11y.panel.removedFrom",{column:n,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(l,d){if(!this.canGroup(l)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0});return}const a=this.groups(),n=a.indexOf(l),t=a.slice();n>=0&&(t.splice(n,1),n<d&&(d-=1)),t.splice(Math.max(0,Math.min(d,t.length)),0,l),this.setGroups(t);const r=t.indexOf(l);this.announce(this.t(n>=0?"a11y.panel.moved":"a11y.panel.addedTo",n>=0?{column:this.titleOf(l),at:r+1,of:t.length}:{column:this.titleOf(l),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(l)}#i(l){const d=new Set(l),a=_(this.doc,"label",{class:$.groupZoneAdd}),n=_(this.doc,"select",{class:$.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())d.has(t.id)||!this.canGroup(t.id)||n.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,a.appendChild(n),a}#s(){for(const d of this.#e)d();this.#e.length=0;const l=this.props&&this.props.header;if(!(!l||!z(l.querySelectorAll)))for(const d of l.querySelectorAll("[data-col]")){const a=z(d.getAttribute)?d.getAttribute("data-col"):null;!a||!this.canGroup(a)||(z(d.setAttribute)&&d.setAttribute("draggable","true"),this.#e.push(X(d,"dragstart",n=>{this.dragging=a,n.dataTransfer&&z(n.dataTransfer.setData)&&n.dataTransfer.setData(w,a)})),this.#e.push(X(d,"dragend",()=>{this.dragging=null})))}}#l(l){const d=l&&l.dataTransfer;if(d&&z(d.getData)){const a=d.getData(w);if(a)return a}return null}#a(l){const d=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(l)}"]`):null;d&&z(d.focus)&&d.focus()}#u(){this.adderSelect&&z(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const l of this.#e)l();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 U}}),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"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/internal/util.js").isFunction;class U{root=null;init(g){this.doc=g.document,this.root=$(this.doc,"div",{class:`${F.tooltip}__text`}),this.update(g.content)}update(g){if(!this.root)return;const l=g==null?"":String(g);this.root.textContent!==l&&(this.root.textContent=l)}element(){return this.root}destroy(){this.root=null}}class z{root=null;component=null;timer=null;target=null;off=[];constructor(g){const l=g||{};this.doc=B(l),this.host=l.host||this.doc.body,this.delay=l.delay??400,this.hideDelay=l.hideDelay??0,this.components={text:U,...l.components||{}}}show(g){this.cancelTimer();const l=g.delay??this.delay;if(!l){this.showNow(g);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(g)},l)}showNow(g){const l=g.component||"text",d=typeof l=="function"?l:this.components[l]||U;return this.root||(this.root=$(this.doc,"div",{class:F.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==d?(this.component&&H(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new d,this.componentCtor=d,this.component.init({document:this.doc,content:g.content,...g.props||{}}),this.root.appendChild(this.component.element())):H(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||!H(this.target.getBoundingClientRect))return;const g=this.target.getBoundingClientRect(),l=this.doc.defaultView||{};this.root.style.left=`${g.left+(l.scrollX||0)}px`,this.root.style.top=`${g.bottom+(l.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,l,d){const a=()=>this.show({target:g,content:l(),...d||{}}),n=()=>this.hide(),t=[_(g,"mouseenter",a),_(g,"mouseleave",n),_(g,"focus",a),_(g,"blur",n)],r=()=>{for(const i of t)i()};return this.off.push(r),r}destroy(){this.hide();for(const g of this.off)g();this.off.length=0,this.component&&H(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 v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js").isFunction;function w(l){const d=Math.max(1,Number(l.pageSize)||100),a=l.total==null?null:Math.max(0,Number(l.total)),n=a==null?null:Math.max(1,Math.ceil(a/d)),t=Math.max(0,n==null?Number(l.page)||0:Math.min(Number(l.page)||0,n-1)),r=a===0?0:t*d+1,i=a==null?(t+1)*d:Math.min(a,(t+1)*d);return{page:t,pageSize:d,pageCount:n,from:r,to:i,first:t===0,last:n==null?l.hasMore!==!0:t>=n-1,total:a}}class v{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(d){const a=d||{};this.doc=B(a),this.host=a.host||{},this.pageSize=Number(a.pageSize)||100;const n=Array.isArray(a.pageSizes)&&a.pageSizes.length?[...a.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!n.includes(this.pageSize)&&n.push(this.pageSize),this.pageSizes=n.sort((t,r)=>t-r),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=$(this.doc,"nav",{class:F.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(d,a){const n=this.messages;return(n&&typeof n.t=="function"?n:H).t(d,a)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(d){d.total!==void 0&&(this.total=d.total),d.counting!==void 0&&(this.counting=d.counting===!0),d.hasMore!==void 0&&(this.hasMore=d.hasMore===!0),d.page!==void 0&&(this.page=Number(d.page)||0),this.paint()}goTo(d){const a=this.page;this.page=d;const n=this.model();return this.page=n.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 d=this.model();return d.pageCount==null?this.page:this.goTo(d.pageCount-1)}setPageSize(d){const a=this.page*this.pageSize;this.pageSize=Math.max(1,Number(d)||1),this.page=Math.floor(a/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const d=this.root;if(!d)return;for(const o of this.off)o();this.off.length=0,X(d);const a=this.model(),n=$(this.doc,"select",{class:`${F.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const o of this.pageSizes)n.appendChild($(this.doc,"option",{text:String(o),attrs:{value:o}}));n.value=String(this.pageSize),this.off.push(_(n,"change",()=>this.setPageSize(Number(n.value)))),d.appendChild(n);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});d.appendChild($(this.doc,"span",{class:`${F.pagination}__summary`,text:t}));const r=(o,m,c,h)=>{const s=$(this.doc,"button",{class:`${F.pagination}__button`,text:o,attrs:{type:"button","aria-label":h,disabled:c?"":null}});return c||this.off.push(_(s,"click",m)),s};d.appendChild(r("«",()=>this.goTo(0),a.first,this.t("pagination.first"))),d.appendChild(r("‹",()=>this.previous(),a.first,this.t("pagination.previous")));const i=$(this.doc,"span",{class:`${F.pagination}__page`});i.appendChild($(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=$(this.doc,"input",{class:`${F.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))}});f.value=String(a.page+1);const u=()=>{const o=parseInt(String(f.value).trim(),10);if(!Number.isFinite(o)){f.value=String(this.model().page+1);return}this.goTo(o-1)};this.off.push(_(f,"keydown",o=>{o.key==="Enter"?(u(),o.preventDefault?.()):o.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):o.stopPropagation?.()})),this.off.push(_(f,"blur",()=>u())),this.off.push(_(f,"focus",()=>f.select?.())),i.appendChild(f),a.pageCount!=null&&i.appendChild($(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:a.pageCount})}`})),d.appendChild(i),d.appendChild(r("›",()=>this.next(),a.last,this.t("pagination.next"))),d.appendChild(r("»",()=>this.last(),a.last||a.pageCount==null,this.t("pagination.last")))}destroy(){for(const d of this.off)d();this.off.length=0,this.root=null}}const g=v}),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 v}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=K("packages/dom/src/editors/common.js"),F=Q.CLS,B=Q.documentFor,$=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,U=K("packages/core/src/i18n/index.js").defaultMessages;function z(a,n){const t=a&&a.grid&&a.grid.messages;return(t&&W(t.t)?t:U).t(n)}class w{root=null;init(n){this.doc=n.document,this.root=$(this.doc,"div",{class:`${F.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[$(this.doc,"span",{class:`${F.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),$(this.doc,"span",{class:`${F.overlay}__message`,text:n.message||z(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class v{root=null;init(n){this.doc=n.document,this.root=$(this.doc,"div",{class:`${F.overlay}__empty`,attrs:{role:"status"},children:[$(this.doc,"span",{class:`${F.overlay}__message`,text:n.message||z(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:v});class l{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...g,...t.components||{}},this.root=$(this.doc,"div",{class:F.overlay,attrs:{"data-open":"false"}}),this.slot=$(this.doc,"div",{class:`${F.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(n,t){const r=typeof n=="function"?n:this.components[n];return r?(this.hide(),this.component=new r,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof n=="string"?n:"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(n,t){this.components[n]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const d=l}),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 F=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return F.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return F.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 $=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return $.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 h}});const Q=K("packages/dom/src/editors/common.js"),F=Q.documentFor,B=Q.el,$=Q.on,_=Q.clear,X=K("packages/core/src/internal/util.js"),W=X.isFunction,H=X.warnOnce,z=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,v=K("packages/dom/src/detailhost.js").insideDetail,l=K("packages/dom/src/renderer/renderer.js").displayIndexOf,d=K("packages/dom/src/renderer/viewport.js"),a=d.CLASS,n=d.NAMESPACE,r=K("packages/dom/src/themeof.js").carryTheme,i={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"},f=400,u=140,o=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;#f=null;#h=[];#p=!1;constructor(p){const b=p||{};this.#e=b.grid,this.#t=b.host,this.#n=b.viewport,this.#r=F(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.#h.push(b);const A=this.#e.on("cell:mouseout",()=>this.#k());W(A)&&this.#h.push(A),this.#h.push($(p,"focusin",y=>this.#O(y))),this.#h.push($(p,"focusout",()=>this.#k())),this.#h.push($(this.#r,"keydown",y=>this.#y(y),!0));const k=this.#r.defaultView;k&&W(k.addEventListener)&&this.#h.push($(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):f,k=b.maxWidth;return{delay:A,hideDelay:u,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=l(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.#j(b)}#O(p){const b=p&&p.target;if(!b||!W(b.closest)||v(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.#j(A)}#y(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#j(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.#f!==null)return;const{hideDelay:p}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},p)}#C(){if(this.#o)return this.#o;const p=this.#r,b=B(p,"div",{class:[n,i.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(p,"div",{class:i.body}),b.appendChild(this.#i),this.#h.push($(b,"mouseenter",()=>this.#$())),this.#h.push($(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 H(`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:i.title,text:k(p.title)}));const y=Array.isArray(p.rows)?p.rows:[];if(y.length){const S=B(b,"div",{class:i.rows});for(const R of y){if(!R||typeof R!="object")continue;const j=B(b,"div",{class:i.row});j.appendChild(B(b,"span",{class:i.label,text:k(R.label)})),j.appendChild(B(b,"span",{class:i.value,text:k(R.value)})),S.appendChild(j)}A.appendChild(S)}p.note!==void 0&&p.note!==null&&p.note!==""&&A.appendChild(B(b,"div",{class:i.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();r(k,this.#n&&this.#n.root);let y;if(W(A.render))try{y=A.render(b)}catch(j){H(`tooltip-render:${b.colId}`,`Column '${b.colId}' cell.tooltip render threw; no tooltip was shown.`,j);return}const S=this.#S(y,b.colId);if(W(A.mount))try{A.mount(this.#i,b),this.#u=A}catch(j){H(`tooltip-mount:${b.colId}`,`Column '${b.colId}' cell.tooltip mount threw; the tooltip was closed.`,j),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,j=y.width||0,x=y.height||0;let E=k.bottom+o;const T=k.top-o-x;E+x>R-o&&T>=o&&(E=T),R&&(E=Math.max(o,Math.min(E,Math.max(o,R-x-o))));let L=k.left;S&&(L=Math.min(L,Math.max(o,S-j-o))),L=Math.max(o,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){H("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.#f!==null&&(clearTimeout(this.#f),this.#f=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#h)p();this.#h.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=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 F=globalThis.navigator,B=String(F&&(F.userAgentData?.platform||F.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 d}}),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 r}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),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 h}}),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"),F=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),w=z.aggregatesFor,v=z.totalLabel,g=10,l=150;function d(A,k){const y=(te,ne)=>(A&&A.messages?A.messages:W).t(te,ne),S=A.columns.get(k);if(!S)return[];const R=A.sort.get(),j=R.find(te=>te.col===k),x=S.layout&&S.layout.pin,E=A.state.get().group||[],T=E.includes(k);if(S.generated&&Array.isArray(S.groupedIds))return r(A,S,E);const L=!S.sort||S.sort.enabled!==!1,P=!S.filter||S.filter.enabled!==!1,D=[];L&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:j&&j.dir==="asc",action:()=>A.sort.set([{col:k,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:j&&j.dir==="desc",action:()=>A.sort.set([{col:k,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!j,action:()=>A.sort.set(R.filter(te=>te.col!==k))},{separator:!0}),P&&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:x==="start",action:()=>A.columns.pin(k,"start")},{name:y("menu.pinEnd"),disabled:x==="end",action:()=>A.columns.pin(k,"end")},{name:y("menu.unpin"),disabled:!x,action:()=>A.columns.pin(k,null)}]});const I=!(S.layout&&(S.layout.movable===!1||S.layout.lockPosition)),C=!(S.layout&&S.layout.resizable===!1),O=te=>{const ne=A.columns.get(te);return Number(ne&&ne.layout&&ne.layout.width)||l},N=A.columns.visible().filter(te=>!te.generated).map(te=>te.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:!C,children:[{name:y("menu.narrower"),disabled:!C,action:()=>A.columns.resize(k,Math.max(1,O(k)-g))},{name:y("menu.wider"),disabled:!C,action:()=>A.columns.resize(k,O(k)+g)},{name:y("menu.autosize"),disabled:!C,action:()=>A.columns.autoSize(k)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!I,children:[{name:y("menu.moveLeft"),disabled:!I||G<=0,action:()=>A.columns.move(k,Math.max(0,G-1))},{name:y("menu.moveRight"),disabled:!I||G<0||G>=N.length-1,action:()=>A.columns.move(k,Math.min(N.length-1,G+1))},{name:y("menu.moveToStart"),disabled:!I||G<=0,action:()=>A.columns.move(k,0)},{name:y("menu.moveToEnd"),disabled:!I||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(te=>te!==k):[...E,k])}),E.length&&D.push({name:y("menu.expandAll"),action:()=>A.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>A.rows.collapseAll()}),F(A.columns.groupColumns)){const te=S.groupPath||[],ne=te.length?te[te.length-1]:null,oe=[{name:y("columngroup.group"),disabled:N.length<2||G<0,action:()=>{const le=N[G+1]??N[G-1];if(!le)return;const ae=(A.columns.get(le)||{}).groupPath||[],se=ae.length?ae[ae.length-1]:null;se?A.columns.groupColumns([k],{groupId:se}):A.columns.groupColumns([k,le],{title:y("columngroup.newGroup")})}}];ne&&oe.push({name:y("columngroup.dissolve"),action:()=>A.columns.dissolveGroup(ne)}),D.push({separator:!0},...oe)}const q=A.state&&F(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(te=>te!==k):[...Z,k])}),S.allowTotal!==!1)if(F(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,j=[{name:y("menu.aggregateNone"),checked:!k.total,action:()=>A.columns.setTotal(S,null)},{separator:!0},...w(k).map(x=>({name:v(x),checked:R===x,action:()=>A.columns.setTotal(S,x)})),{separator:!0},n(A,k,y,"group",y("menu.aggregateGroup")),n(A,k,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:j}}function n(A,k,y,S,R){const j=k.id,x=S==="grand"?k.grandTotal:k.groupTotal,E=typeof x=="string"?x:null,T=[{name:y("menu.aggregateSame"),checked:x==null,action:()=>A.columns.setTotal(j,null,{scope:S})},{separator:!0},...w(k).map(L=>({name:v(L),checked:E===L,action:()=>A.columns.setTotal(j,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,j=!!(R&&R.has(k)),x=[];return R&&(x.push({name:y(j?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(k)}),(R.list().length>1||R.active&&!j)&&x.push({name:y("menu.stopRedactingAll"),action:()=>R.clear()}),x.push({separator:!0})),x.push({name:y("menu.hideColumn"),disabled:S.layout&&S.layout.lockVisible===!0,action:()=>A.columns.hide(k)}),x}function r(A,k,y){const S=(T,L)=>(A&&A.messages?A.messages:W).t(T,L),R=y[0],j=A.sort.get(),x=R?j.find(T=>T.col===R):null,E=[];R&&E.push({name:S("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>A.sort.set([{col:R,dir:"asc"}])},{name:S("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.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(P=>P!==T))})}return E.push({name:S("menu.clearGrouping"),disabled:!y.length,action:()=>A.columns.group([])}),E}function i(){const A=globalThis.navigator&&globalThis.navigator.clipboard;return!!(A&&typeof A.readText=="function")}function f(A){return F(A.get)&&A.get("edit")===!1?!1:(A.columns&&F(A.columns.visible)?A.columns.visible():[]).some(y=>{const S=y&&y.edit;return S?S.enabled===void 0||F(S.enabled)?!0:S.enabled!==!1:!1})}function u(A,k){if(F(A.get)&&A.get("edit")===!1)return!1;const y=k&&k.edit;return y?y.enabled===void 0||F(y.enabled)?!0:y.enabled!==!1:!1}const o=new Set(["number","currency","percent","integer"]);function m(A){const k=F(A.get)?A.get("rangeChart"):void 0;return k?F(k)?{enabled:!0,handler:k}:k&&typeof k=="object"&&F(k.onChart)?{enabled:!0,handler:k.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(A){const k=A.selection&&F(A.selection.ranges)?A.selection.ranges():[];if(!Array.isArray(k)||!k.length)return null;const y=k[k.length-1],S=F(A.columns.visible)?A.columns.visible():[],R=new Set(S.filter(j=>j&&o.has(j.type)).map(j=>j.id));return(y.columns||[]).some(j=>R.has(j))?y:null}function h(A,k){const y=(Z,J)=>(A&&A.messages?A.messages:W).t(Z,J),{colId:S,row:R}=k,j=A.selection.keys().length,x=A.selection.cells().length,E=(A.state&&F(A.state.get)?A.state.get().group:null)||[],T=A.ranges||null,L=_()?"Cmd":"Ctrl",P=()=>x||j||0,D=Z=>A.columns&&F(A.columns.get)?A.columns.get(Z):null,I=F(A.selection.cells)?A.selection.cells():[],C=[...new Set(I.map(Z=>Z&&Z.colId).filter(Boolean))];!C.length&&S&&C.push(S);const O=C.length?C.some(Z=>u(A,D(Z))):f(A),N=S?u(A,D(S)):!1,G=m(A),q=G.enabled?c(A):null;return[{name:x>1?`Copy ${x} cells`:y("menu.copy"),shortcut:`${L}+C`,disabled:!P(),action:()=>T&&x?T.copy():A.export.clipboard({rows:j?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!P(),action:()=>A.export.clipboard({headers:!0,rows:j?"selected":"range"})},...S==null?[]:[{name:y("menu.paste"),shortcut:`${L}+V`,disabled:!T||!O||!i(),action:()=>T&&T.paste()},{separator:!0},{name:y("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!T||!O||!x,action:()=>T&&T.clear()},{name:y("menu.fillDown"),shortcut:`${L}+D`,disabled:!T||!O||x<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 ${j} selected row${j===1?"":"s"} to CSV`,disabled:!j,action:()=>A.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>A.export.excel({rows:"visible",download:!0})},{name:`Export ${j} selected row${j===1?"":"s"} to Excel`,disabled:!j,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&&F(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:!j,action:()=>A.selection.clear()},...F(A.get)&&A.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:j||1}),disabled:!j&&!R,action:()=>A.edit.deleteRows(j?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(F(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 j of k){if(!j)continue;const x=s(j.layer,S,y,j.where);S=x.items,x.spoke&&(R=x.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=F(k.items)?k.items:null,this.#s=F(k.headerItems)?k.headerItems:null,this.#r=new U({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,d(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&&F(y.preventDefault)&&y.preventDefault();const S=this.#l(k),R=h(this.#n,S),j=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(S.column),where:`column '${S.colId}' contextMenu`}],S);!j||!j.length||(!this.#e&&y&&F(y.preventDefault)&&y.preventDefault(),this.#r.show({items:j,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&&F(y.get)?y.get(k.colId):void 0),R=k.row,j=this.#n.rows,x=k.key!==void 0?k.key:R?R.key:void 0;return{key:x,colId:k.colId,value:k.value!==void 0||x===void 0||k.colId==null?k.value:j&&F(j.value)?j.value(x,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 v}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),X=_.groupedShortcuts,W=_.SHORTCUT_IDS,U=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class v{#e;#t;#n=null;#r=null;#o=[];constructor(l){this.#e=l.grid,this.#t=l.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(l,d){const a=this.#e;return(a&&a.messages?a.messages:$).t(l,d)}#s(l){const d=W[l.combo];if(!d)return l.meaning;const a=`shortcut.${d}`,n=this.#i(a);return n===a?l.meaning:n}mount(){const l=this.#t.viewport?.root;if(!l||!F(l.addEventListener))return;const d=a=>{if(this.open||a.key!=="?")return;const n=a.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(a.preventDefault(),a.stopPropagation(),this.show())};l.addEventListener("keydown",d,!0),this.#o.push(()=>l.removeEventListener("keydown",d,!0))}show(){const l=this.#l();if(!l)return;const d=l.ownerDocument;this.#r=d&&d.activeElement,l.style.display="",F(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const l=this.#r;this.#r=null,l&&F(l.focus)&&l.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,d=l?.ownerDocument;if(!l||!d?.createElement)return null;const a=d.createElement("div");a.className=z,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("tabindex","-1");const n=`${z}-title`;a.setAttribute("aria-labelledby",n);const t=d.createElement("div");t.className=`${z}__head`;const r=d.createElement("h2");r.className=`${z}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const i=d.createElement("button");i.className=`${z}__close`,i.type="button",i.setAttribute("aria-label",this.#i("shortcuts.close")),i.textContent="×",t.appendChild(r),t.appendChild(i),a.appendChild(t);const f=d.createElement("div");f.className=`${z}__body`;for(const o of X())o.items.length&&f.appendChild(this.#a(d,o));a.appendChild(f);const u=d.createElement("p");return u.className=`${z}__hint`,u.textContent=this.#i("shortcuts.hint"),a.appendChild(u),l.appendChild(a),this.#n=a,this.#u(a,i),a}#a(l,d){const a=l.createElement("section");a.className=`${z}__group`;const n=l.createElement("h3");n.className=`${z}__group-title`,n.textContent=this.#i(d.messageKey),a.appendChild(n);const t=l.createElement("dl");t.className=`${z}__list`;const r=U();for(const i of d.items){const f=l.createElement("dt");f.className=`${z}__keys`,i.alternatives.forEach((o,m)=>{if(m>0){const c=l.createElement("span");c.className=`${z}__or`,c.textContent=this.#i("shortcuts.or"),f.appendChild(c)}o.forEach((c,h)=>{h>0&&f.appendChild(l.createTextNode("+"));const s=l.createElement("kbd");s.textContent=r&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,f.appendChild(s)})});const u=l.createElement("dd");u.className=`${z}__meaning`,u.textContent=this.#s(i),t.appendChild(f),t.appendChild(u)}return a.appendChild(t),a}#u(l,d){const a=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...l.querySelectorAll(w)];if(!r.length){t.preventDefault();return}const i=r[0],f=r[r.length-1],u=l.ownerDocument.activeElement;t.shiftKey&&(u===i||u===l)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),i.focus())},n=t=>{t.preventDefault?.(),this.hide()};l.addEventListener("keydown",a),d.addEventListener("click",n),this.#o.push(()=>{l.removeEventListener("keydown",a),d.removeEventListener("click",n)})}destroy(){for(const l of this.#o)l();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 H}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return a}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/renderer.js").displayIndexOf,W="lat-rowdrag",H="lat-rowdrag-marker",U="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"}),v=4,g=new Set;function l(n){if(!n)return null;const t=n===!0?{}:typeof n=="object"?n: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 d(n){return n===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!n||typeof n!="object"?null:{column:typeof n.column=="string"?n.column:null,manualOrder:n.manualOrder===!0,betweenGroups:n.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=d(t.grid.get("rowReorder")),this.#o=l(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 r=t&&t.transfer;return!r||!r.send?!1:r.group===this.#o.group}get transfer(){return this.#o}#u(t,r){const i=this.#e;return(i&&i.messages?i.messages:$).t(t,r)}#c(t,r){const i=this.#t&&this.#t.announce;F(i)&&i.call(this.#t,t,r)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(r=>!r.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),r=this.#t.viewport?.root;if(!t||!r)return;const i=r.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const f of i){if(f.querySelector(`.${W}`))continue;const u=f.parentNode;if(u&&F(u.getAttribute)&&u.getAttribute("data-pinned"))continue;const o=this.#n.createElement("span");o.className=W,o.setAttribute("data-role","row-drag"),o.setAttribute("aria-hidden","true"),o.setAttribute("title",this.#u("a11y.reorder.grab")),o.textContent="⠿",f.insertBefore(o,f.firstChild||null)}this.#h(r,t)}#f(){const t=this.#e.rowOrder;return!!(t&&F(t.manual)&&t.manual())}#h(t,r){const i=this.#f();if(F(t.setAttribute)&&(i?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const f=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!f)return;let u=f.querySelector(`.${z}`);u||(u=this.#n.createElement("button"),u.className=z,u.setAttribute("type","button"),u.setAttribute("data-role","manual-order"),u.setAttribute("tabindex","-1"),u.textContent=this.#u("rowOrder.button"),u.addEventListener("click",m=>{m.stopPropagation?.(),this.toggleManual()}),u.addEventListener("pointerdown",m=>m.stopPropagation?.()),f.insertBefore(u,f.firstChild||null)),u.setAttribute("aria-pressed",i?"true":"false");const o=this.#u(i?"rowOrder.exit":"rowOrder.enter");u.setAttribute("title",o),u.setAttribute("aria-label",o)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#f()?t.exit():t.enter({origin:"user"}),i=f=>{f&&f.reason&&this.#c(this.#u(w[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&F(r.then)?r.then(i):i(r)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!F(t.addEventListener))return;const r=m=>this.#p(m),i=m=>this.#m(m),f=()=>this.#g(),u=m=>this.#E(m);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",u),F(this.#e.on)){let m=this.#f();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#f()!==m&&(m=this.#f(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const o=this.#n.defaultView||this.#n;o.addEventListener?.("pointermove",i),o.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",u),o.removeEventListener?.("pointermove",i),o.removeEventListener?.("pointerup",f)})}#p(t){const r=t.target;if(!r||!F(r.closest)||!r.closest('[data-role="row-drag"]'))return;const i=r.closest(".lat-row"),f=i?X(i):-1;if(f<0)return;const u=this.#e.rows.get(f);if(!u||u.group)return;const o=this.#N();if(o&&!(this.#o&&this.#o.send)){this.#c(this.#u(o),{repeat:!0});return}t.preventDefault?.(),this.#i={key:u.key,from:f,at:f,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<v)return;r.armed=!0,this.#z(r),r.over=this,this.#e.emit("rowDrag:started",this.#b(r,this,r.from,r.key),"user")}this.#l&&this.#V(t.clientX,t.clientY);const i=this.#S(t.clientX,t.clientY);if(r.target=i,i!==this){this.#I(),i&&i.accepts(this)?(i.showDropTarget(t.clientX,t.clientY),r.hit=i.hitAt(t.clientX,t.clientY)):r.hit=null,this.#O(r,i),this.#y(r,i,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const f=this.#$(t.clientX,t.clientY);if(this.#O(r,i),f<0){this.#y(r,this,null,null);return}r.at=f,this.#L(f);const u=this.#e.rows.get(f);this.#y(r,this,f,u?u.key:null)}#g(){const t=this.#i;this.#i=null,this.#I(),this.#B();for(const f of g)f.hideDropTarget();if(!t||(this.#j(t),!t.armed))return;const r=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),r&&r!==this){this.#C(t,r);return}if(t.at===t.from)return;const i=this.#N();if(i){this.#c(this.#u(i),{repeat:!0});return}this.#P(t.key,t.at)}#b(t,r,i,f){const u=this.#e.rows.byKey(t.key);return{key:t.key,data:u?u.data:null,over:r?r.grid:null,at:i,overKey:f}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#b(t,r,null,null),dropped:!1};const i=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#b(t,r,i.at,i.overKey),dropped:!0}}if(r===this){const i=this.#e.rows.get(t.at);return{...this.#b(t,this,t.at,i?i.key:null),dropped:t.at!==t.from&&this.#N()===null}}return{...this.#b(t,null,null,null),dropped:!1}}#O(t,r){if(t.over===r)return;const i=t.over;t.over=r,i&&(this.#j(t),this.#e.emit("rowDrag:left",this.#b(t,i,null,null),"user"))}#y(t,r,i,f){t.pending={over:r,at:i,overKey:f},t.frame===null&&(t.frame=this.#k(()=>{t.frame=null;const u=t.pending;t.pending=null,!(!u||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#b(t,u.over,u.at,u.overKey),"user")}))}#j(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#k(t){const r=this.#n.defaultView||globalThis;if(F(r.requestAnimationFrame)){const f=r.requestAnimationFrame(t);return()=>{F(r.cancelAnimationFrame)&&r.cancelAnimationFrame(f)}}const i=setTimeout(t,16);return()=>clearTimeout(i)}#C(t,r){if(!r.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const i=this.#e.rows.byKey(t.key);if(!i)return;const f=this.#o.mode,u=t.key,o=t.hit||{at:r.grid.rows.count(),overKey:null};let m=null;const c=r.receive(i.data,o.at,{overKey:o.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(u),onCancel:s=>{m=s}}),h=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}f==="move"?(this.#e.rows.apply({remove:[u]}),this.#e.emit("row:sent",{key:u,data:i.data,mode:f})):this.#e.emit("row:copied",{key:u,data:i.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&F(c.then)?c.then(h):h(c)}receive(t,r,i={}){const f=this.#e,u=t&&typeof t=="object"?{...t}:t,o=i.overKey??null,m=i.source||null,c=F(i.onCancel)?i.onCancel:null,h=()=>{const k=f.rows.totalCount(),y=f.rows.apply({add:[u],at:Math.max(0,r||0)}),S=f.rows.totalCount()>k;return S&&f.emit("row:received",{data:u,at:r,overKey:o,rejected:y?.rejected||[]}),S},s=()=>{if(o!==null){const k=f.rows.get(r);if(!k||k.key!==o)return!1}else r=f.rows.count();return!F(i.revalidate)||i.revalidate()},p=F(f.rendererHost)?f.rendererHost():null;if(!p||!F(p.gateBefore))return h();const b=c?f.on("rowReceive:cancelled",k=>c(k.reason)):null,A=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:u,at:r,overKey:o,source:m,origin:"user"},h,s);return b&&(A&&F(A.then)?A.then(b,b):b()),A}hitAt(t,r){const i=this.#$(t,r);if(i<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(i);return{at:i,overKey:f?f.key:null}}showDropTarget(t,r){const i=this.root;i&&F(i.setAttribute)&&i.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&F(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#S(t,r){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=i&&F(i.closest)?i.closest(".lattice"):null;if(!f)return null;for(const u of g)if(u.root===f)return u;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 r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!r)return;const i=this.#n.activeElement,f=i&&F(i.closest)?i.closest(".lat-row"):null,u=f?X(f):-1;if(u<0)return;t.preventDefault?.(),t.stopPropagation?.();const o=this.#N();if(o){this.#c(this.#u(o),{repeat:!0});return}const m=this.#e.rows.get(u);!m||m.group||this.#P(m.key,this.#T(u,r))}#T(t,r){const i=this.#e;if(r>0||!F(i.rows.groupHeadings))return t+r;const f=new Set(i.rows.groupHeadings(t).map(o=>o.key));let u=t+r;for(;u>=0;){const o=i.rows.get(u);if(!o||!f.has(o.key))break;u+=r}return u<0?t:u}#P(t,r){const i=this.#e.rows.count(),f=Math.max(0,Math.min(i-1,r)),u=this.#e.rows.move(t,f,{origin:"user"});u&&F(u.then)?u.then(o=>this.#M(o,i)):this.#M(u,i)}#M(t,r){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const i=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,f=i?this.#u("a11y.reorder.vetoedBecause",{reason:i}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const i=t.regrouped.map(f=>String(f.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:i}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:r}),{repeat:!0})}#N(){const t=this.#e,r=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return r.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#f()&&!r.betweenGroups)return"a11y.reorder.grouped";const i=t.filters.get();return i&&Object.keys(i).length?"a11y.reorder.filtered":null}#$(t,r){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=i&&F(i.closest)?i.closest(".lat-row"):null;return!f||F(f.getAttribute)&&f.getAttribute("data-pinned")?-1:X(f)}#z(t){const r=this.root,i=r&&F(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;i&&F(i.classList?.add)&&i.classList.add(U);const f=this.#n.body;if(!f||!F(f.appendChild))return;const u=this.#d(),o=u&&F(this.#e.rows?.text)&&this.#e.rows.text(t.key,u)||this.#u("a11y.reorder.grab"),m=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,c=(s,p)=>m&&m.getPropertyValue(s).trim()||p,h=this.#n.createElement("div");h.textContent=String(o),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.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(";"),f.appendChild(h),this.#l=h}#V(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#B(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&F(t.querySelectorAll)?t.querySelectorAll(`.${U}`):[];for(const i of r)i.classList.remove(U)}#L(t){const r=this.#t.viewport?.overlays;if(!r)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=H,r.appendChild(this.#s));const i=this.#t.viewport.root,f=i.querySelector(`.lat-row[data-index="${t}"]`)||i.querySelectorAll(".lat-row")[0];if(!f||!F(f.getBoundingClientRect))return;const u=f.getBoundingClientRect(),o=i.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?u.bottom:u.top)-o.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.#j(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 $}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const F=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function $(W){return(W||[]).map(H=>({id:H.id,width:H.width,flex:H.flex,hidden:H.hidden,pin:H.pin===void 0?null:H.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(H){if(!H||this.#e.has(H))return;this.#e.add(H);const U=[];for(const w of B)U.push(H.on(w,()=>this.#r(H)));U.push(H.on("scroll",w=>this.#i(H,w))),U.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,U);const[z]=this.#e;z!==H&&this.#o(H,$(z.columns.state()))}remove(H){const U=this.#t.get(H);if(U)for(const z of U)z();this.#t.delete(H),this.#e.delete(H)}get size(){return this.#e.size}destroy(){for(const H of[...this.#e])this.remove(H)}#r(H){if(this.#n)return;const U=$(H.columns.state());this.#n=!0;try{for(const z of this.#e)z!==H&&this.#o(z,U)}finally{this.#n=!1}}#o(H,U){if(!H.columns||!F(H.columns.apply))return;const z=new Map((H.columns.state()||[]).map(v=>[v.id,v])),w=[];for(const v of U){const g=z.get(v.id);g&&(w.push({...g,...v}),z.delete(v.id))}for(const v of z.values())w.push(v);H.columns.apply(w)}#i(H,U){if(this.#n)return;const z=U&&typeof U.left=="number"?U.left:null;if(z!==null){this.#n=!0;try{for(const w of this.#e)w!==H&&w.scroll?.to?.({left:z})}finally{this.#n=!1}}}}function X(W){const H=new _;for(const U of W||[])H.add(U);return H}}),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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(U){if(!U)return null;const z=U===!0?{}:typeof U=="object"?U: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 v=this.#e;return(v&&v.messages?v.messages:$).t(z,w)}mount(){if(!this.active)return;const z=this.#t.viewport,w=z?.root;if(!w||!F(w.insertBefore))return;const v=this.#n.createElement("div");v.className=_,v.setAttribute("role","toolbar"),v.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 l=this.#n.createElement("select");l.className=`${_}__select`,this.#r.multiple&&l.setAttribute("multiple","");const d=`${_}-select-${Math.abs(H(String(w.className)))}`;l.id=d,g.setAttribute("for",d),v.appendChild(g),v.appendChild(l),w.insertBefore(v,z.header||w.firstChild),this.#o=v,this.#i=l;const a=()=>{const t=this.#r.multiple?[...l.selectedOptions||[]].map(r=>r.value).filter(Boolean):l.value?[l.value]:[];this.#e.columns.showTagged(t),this.#u(t)};l.addEventListener("change",a),this.#l.push(()=>l.removeEventListener("change",a));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(z){const w=this.#t&&this.#t.announce;if(!F(w))return;const v=z.length?z.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:v}))}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 v=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 l=this.#n.createElement("option");l.value=g,l.textContent=g,v.includes(g)&&(l.selected=!0),this.#i.appendChild(l)}this.#r.multiple||(this.#i.value=v.length?v[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 H(U){let z=0;for(let w=0;w<U.length;w++)z=z*31+U.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 U}});const F=K("packages/core/src/internal/util.js").isFunction,$=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 H(z,w){return z?Array.isArray(z.conditions)?z.conditions.some(v=>H(v,w)):z.col===w&&z.op==="eq"&&z.value===!0:!1}class U{#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}#f(w,v){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,v)}#h(){const w=this.#r&&this.#r.column;let v=null;for(const g of this.#e.columns.all()){const l=W(g.shadow);if(!l||l.kind!=="anomalyFlag")continue;const d=l.of||g.field||g.id;if(w){if(g.id===w||d===w)return this.#d=g.id,g}else v||(v=g,this.#d=g.id)}return w?null:v}#p(){if(!this.#d||!F(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(v=>{!v||v.group||v.key==null||this.#e.rows.value(v.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,v=w&&w.root;if(!v||!F(v.insertBefore))return;const g=this.#n.createElement("div");g.className=_,g.setAttribute("role","status");const l=this.#n.createElement("button");l.className=`${_}__button`,l.setAttribute("type","button"),l.setAttribute("aria-pressed","false"),g.appendChild(l),v.insertBefore(g,w.header||v.firstChild),this.#o=g,this.#i=l;const d=()=>this.toggle();l.addEventListener("click",d),this.#s.push(()=>l.removeEventListener("click",d));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},v=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(v)}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.#h()){this.#o.style.display="none";return}if(this.#l&&!H(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#b(this.#c,!0);return}const v=this.#p();if(this.#c=v,!v){this.#o.style.display="none";return}this.#b(v,!1)}#b(w,v){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",v?"true":"false"),this.#i.setAttribute("aria-pressed",v?"true":"false");const g=this.#r&&this.#r.label,l=v?this.#f("anomaly.chipActive",{count:w}):g||this.#f("anomaly.chip",{count:w});this.#i.textContent=l}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 l}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,U=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,l="lat-rowform",d='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function a(f){if(!f)return null;const u=f===!0?{}:typeof f=="object"?f:null;if(!u)return null;const o=F(u.load)?u.load:null,m=Array.isArray(u.fields)&&u.fields.length?u.fields:null;return{timeout:r(u.timeout),container:u.container??null,mode:u.container?"inline":u.mode==="dialog"?"dialog":"drawer",load:o,create:F(u.create)?u.create:null,fields:m,title:u.title??null,width:typeof u.width=="string"?u.width:null,trigger:u.trigger===!1?"none":"dblclick"}}function n(f,u){const o=F(f)?f():f;return o?typeof o=="string"?u&&F(u.querySelector)?u.querySelector(o):null:o&&F(o.appendChild)?o:null:null}const t=2e3;function r(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class i{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#f=null;#h=0;#p=null;#m=!1;#g=[];constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document,this.#r=u.registry||null,this.#o=a(u.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#b(u,o){const m=this.#e;return(m&&m.messages?m.messages:_).t(u,o)}mount(){if(!this.active)return;const u=this.#t.viewport?.root;if(!u||!F(u.addEventListener)||this.#o.trigger==="none")return;const o=m=>{const c=m.target;if(!c||!F(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const h=c.closest(".lat-row"),s=h?w(h):-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))};u.addEventListener("dblclick",o,!0),this.#g.push(()=>u.removeEventListener("dblclick",o,!0))}openRow(u){const o=this.#e.rows.byKey(u);if(!o)return!1;const m=this.#C();if(!m)return!1;this.#a=o,this.#u=!1,this.#k(),this.#f=this.#n.activeElement,m.style.display="",this.#L(m),this.#E(o);const c=this.#o.load;if(!c)this.#V(o.data);else{this.#N();const h=++this.#h;this.#T(h,s=>{this.#$(new Error(`Loading the record timed out after ${s}ms`),u,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:o,data:o.data,key:u,grid:this.#e})).then(s=>{h!==this.#h||!this.open||(this.#M(),this.#V(s||o.data))}).catch(s=>{h!==this.#h||!this.open||(this.#M(),this.#$(s,u))})}return F(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:u,row:o}),!0}openNew(u){const o=this.#C();if(!o)return!1;this.#h+=1,this.#M(),this.#a=null,this.#u=!0,this.#k(),this.open||(this.#f=this.#n.activeElement),o.style.display="",this.#L(o);const m=o.querySelector(`.${l}__title`);return m&&(m.textContent=this.#b("form.newTitle")),this.#V(u&&typeof u=="object"?{...u}:{}),F(o.focus)&&o.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#M(),this.#ge(),this.#i.style.display="none";const u=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#k();const o=this.#f;this.#f=null,o&&F(o.focus)&&o.focus(),this.#e.emit("form:closed",{key:u})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const u=this.#a?this.#a.key:null,o={},m={},c=[],h=[];for(const s of this.#d){const p=F(s.editor.commit)?s.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#_(s,p.message),!1;if(o[s.field]=p.value,s.readOnly){h.push(s.field);continue}const b=s.initial;Object.is(b,p.value)||(m[s.field]=p.value,s.colId?c.push({key:u,colId:s.colId,value:p.value}):h.push(s.field))}return this.#u?this.#w(o):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:u,values:o,changed:m,unmapped:h}),this.close(),!0)}#w(u){const o=this.#d.filter(h=>!h.colId).map(h=>h.field),m=this.#o.create;if(!m)return this.#O(u)?(this.#y(u,u,o),!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.#h;return this.#T(c,h=>{this.#j(new Error(`Adding the record timed out after ${h}ms`),u,!0)}),Promise.resolve().then(()=>m(u)).then(h=>{if(!(c!==this.#h||!this.open)){if(this.#M(),!this.#O(h)){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.#j(new Error("rowForm.create answered with a row that carries no row key"),u,!1);return}this.#y(h,u,o)}}).catch(h=>{c!==this.#h||!this.open||(this.#M(),this.#j(h,u,!1))}),!0}#O(u){if(!u||typeof u!="object")return!1;const o=W(this.#e.get("rowKey"),{warn:!1});return!o||o.stable===!1?!1:F(o.keyEmpty)?!o.keyEmpty(u):!0}#y(u,o,m){const c=this.#e,h=c.rows.apply({add:[u]}),s=h&&Array.isArray(h.added)?h.added[0]:null;if(!s){this.#j(new Error("The new row could not be added"),o,!1);return}const p=s.key;c.emit("form:saved",{key:p,values:o,changed:o,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&&F(c.selection.set)&&c.selection.set([p]),c.scroll&&F(c.scroll.toRow)&&c.scroll.toRow(p)}#j(u,o,m){this.#P(!0),this.#k();const c=this.#n.createElement("div");c.className=`${l}__failure`;const h=this.#n.createElement("p");h.className=`${l}__note ${l}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#b("form.createFailed");const s=this.#n.createElement("button");s.className=`${l}__retry`,s.type="button",s.textContent=this.#b("form.retry"),s.addEventListener("click",()=>this.save()),c.appendChild(h),c.appendChild(s),F(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:u,timedOut:m,created:!0})}#k(){const u=this.#c;this.#c=null,u&&u.parentNode&&u.parentNode.removeChild(u)}#C(){if(this.#i)return this.#i;const u=this.#t.viewport?.overlays,o=this.#n||u?.ownerDocument;if(!o?.createElement)return null;const m=n(this.#o.container,o),c=m||u;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 h=o.createElement("div"),s=this.#m?"lattice ":"";h.className=`${s}${l} ${l}--${this.#m?"inline":this.#o.mode}`,h.setAttribute("role",this.#m?"region":"dialog"),this.#m||h.setAttribute("aria-modal","true"),h.setAttribute("tabindex","-1"),this.#o.width&&h.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${l}-title`;h.setAttribute("aria-labelledby",p);const b=o.createElement("div");b.className=`${l}__head`;const A=o.createElement("h2");A.className=`${l}__title`,A.id=p,b.appendChild(A);const k=o.createElement("div");k.className=`${l}__body`;const y=o.createElement("div");y.className=`${l}__foot`;const S=o.createElement("button");S.className=`${l}__cancel`,S.type="button",S.textContent=this.#b("form.cancel");const R=o.createElement("button");return R.className=`${l}__save`,R.type="button",R.textContent=this.#b("form.save"),y.appendChild(S),y.appendChild(R),h.appendChild(b),h.appendChild(k),h.appendChild(y),c.appendChild(h),this.#i=h,this.#s=k,this.#l=R,this.#S(h,R,S),h}#S(u,o,m){const c=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const b=[...u.querySelectorAll(d)];if(!b.length){p.preventDefault();return}const A=b[0],k=b[b.length-1],y=u.ownerDocument.activeElement;p.shiftKey&&(y===A||y===u)?(p.preventDefault(),k.focus()):!p.shiftKey&&y===k&&(p.preventDefault(),A.focus())},h=p=>{p.preventDefault?.(),this.save()},s=p=>{p.preventDefault?.(),this.close()};u.addEventListener("keydown",c),o.addEventListener("click",h),m.addEventListener("click",s),this.#g.push(()=>{u.removeEventListener("keydown",c),o.removeEventListener("click",h),m.removeEventListener("click",s)})}#E(u){const o=this.#i.querySelector(`.${l}__title`);if(!o)return;const m=this.#o.title;F(m)?o.textContent=String(m({row:u,data:u.data})??""):typeof m=="string"?o.textContent=m:o.textContent=this.#b("form.title")}#T(u,o){this.#M();const m=this.#o.timeout;if(!m)return;const c=this.#n.defaultView||globalThis;F(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(u!==this.#h||!this.open)&&(this.#h+=1,o(m))},m))}#P(u){this.#l&&(this.#l.disabled=!u,u?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#M(){if(this.#p===null)return;const u=this.#n.defaultView||globalThis;F(u.clearTimeout)&&u.clearTimeout(this.#p),this.#p=null}#N(){this.#ge(),this.#P(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const u=this.#n.createElement("p");u.className=`${l}__note`,u.setAttribute("role","status"),u.textContent=this.#b("form.loading"),this.#s.appendChild(u)}#$(u,o,m="form.loadFailed"){this.#ge(),this.#P(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${l}__note ${l}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#b(m);const h=this.#n.createElement("button");h.className=`${l}__retry`,h.type="button",h.textContent=this.#b("form.retry"),h.addEventListener("click",()=>this.openRow(o)),this.#s.appendChild(c),this.#s.appendChild(h),this.#e.emit("form:error",{key:o,error:u,timedOut:m==="form.loadTimeout"})}#z(){return this.#o.fields?this.#o.fields.map(u=>typeof u=="string"?{field:u}:u):this.#e.columns.all().filter(u=>!u.generated&&u.field).map(u=>({field:u.field,label:u.title,colId:u.id}))}#V(u){this.#ge(),this.#P(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const o=u&&typeof u=="object"?u:{};for(const m of this.#z()){const c=m.field;if(!c)continue;const h=m.colId?this.#e.columns.get(m.colId):this.#ae(c),s=Object.hasOwn(o,c)?o[c]:null,p=this.#n.createElement("div");p.className=`${l}__field`;const b=this.#n.createElement("label");b.className=`${l}__label`,b.textContent=String(m.label??(h&&h.title)??c);const A=this.#n.createElement("div");A.className=`${l}__control`,p.appendChild(b),p.appendChild(A),this.#s.appendChild(p);const k={field:c,colId:h?h.id:null,editor:null,initial:s,opener:null,wrap:p,readOnly:!1},S=!!(h&&(h.computed||h.generated))?null:U({grid:this.#e,column:this.#se(m,h,c),colId:h?h.id:c,row:this.#a,data:o,value:s,text:s==null?"":String(s),locale:this.#e.get("locale"),props:m.props||h&&h.edit&&h.edit.props,lookup:m.lookup||h&&h.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,h,s),this.#d.push(k);continue}k.editor=S;try{F(S.value)&&(k.initial=S.value())}catch{}if(this.#d.push(k),S.popup===!0)this.#D(A,k);else{const R=F(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(u,o,m){const c=this.#n.createElement("div");c.className=`${l}__static`,c.setAttribute("aria-readonly","true");let h="";try{const s=o&&o.dataType&&o.dataType.format;F(s)&&(h=s({value:m,column:o,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{h=""}(h===""||h==null)&&(h=m==null?"":String(m)),c.textContent=h,u.appendChild(c)}#L(u){if(!this.#m)return;const o=this.#t.viewport?.root;if(!(!o||!F(o.getAttribute)))for(const m of["data-theme","data-density","dir"]){const c=m==="data-theme"?g(o):o.getAttribute(m);c?u.setAttribute(m,c):F(u.removeAttribute)&&u.removeAttribute(m)}}#I(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#D(u,o){const m=this.#n.createElement("button");m.className=`${l}__opener`,m.type="button",o.opener=m,this.#ue(o);const c=()=>{F(o.editor.attached)&&o.editor.attached()};m.addEventListener("click",c),this.#g.push(()=>m.removeEventListener("click",c)),u.appendChild(m)}#_(u,o){const m=u.wrap;m&&F(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const c=u.opener||(F(u.editor.focusTarget)?u.editor.focusTarget():null);c&&F(c.focus)&&c.focus();const h=this.#t&&this.#t.announce;F(h)&&o&&h.call(this.#t,String(o))}#X(u){if(!u.opener||!u.editor)return;const o=F(u.editor.popupHandle)?u.editor.popupHandle():null;o&&F(o.hide)&&o.hide(),this.#ue(u),F(u.opener.focus)&&u.opener.focus()}#ue(u){if(!u.opener)return;let o="";try{const c=u.colId?this.#e.columns.get(u.colId):null,h=c&&c.dataType&&c.dataType.format;F(h)&&(o=h({value:F(u.editor.value)?u.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(o===""||o==null)&&F(u.editor.toClipboard)&&(o=u.editor.toClipboard())}catch{o=""}const m=o===""||o==null;u.opener.textContent=m?this.#b("form.choose"):String(o),u.opener.classList.toggle(`${l}__opener--empty`,m)}#se(u,o,m){const c=u.editor||u.type||u.lookup||u.props,h={...o&&o.edit?o.edit:{},enabled:!0};return u.editor&&(h.editor=u.editor),u.props&&(h.props=u.props),o&&!c?{...o,edit:h}:{...o||{id:m,field:m},type:u.type||o&&o.type||"text",lookup:u.lookup||o&&o.lookup||void 0,edit:h}}#ae(u){for(const o of this.#e.columns.all())if(!o.generated&&o.field===u)return o;return null}#ge(){for(const u of this.#d)F(u.editor.destroy)&&u.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#M(),this.#ge();for(const u of this.#g)u();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"),F=Q.isFunction,B=Q.warnOnce,$=K("packages/dom/src/ui/toolpanel.js"),_=$.ToolPanel,X=$.toolPanels,W=$.toolPanelTitles,H=$.toolPanelIcons,U=K("packages/dom/src/filters/index.js"),z=U.createFilter,w=U.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,l=K("packages/dom/src/filters/engineset.js"),d=l.EngineSetFilter,a=l.VALUE_LIMIT,n=K("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,i=n.scannableRows,f=n.el,u=K("packages/dom/src/filtermenu.js"),o=u.mergeColumnFilter,m=u.branchFor,c=u.valueSource,h=u.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,P,D){const I=f(L,"div",{class:`${t.panel}__filterRefusal`});return I.appendChild(f(L,"div",{class:`${t.filter}__note`,text:D,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),I.appendChild(P.element()),{get:()=>P.get(),set:C=>P.set(C),active:()=>P.active(),...F(P.clear)?{clear:()=>P.clear()}:{},destroy:()=>P.destroy(),element:()=>I}}function b(L){const{grid:P,container:D}=L||{};if(!P)throw new Error("[lattice] mountPanel needs a grid");if(!D||!D.appendChild)throw new Error("[lattice] mountPanel needs a container element");const I=F(L.panel)?L.panel:X[String(L.panel)];if(!I)throw new Error(`[lattice] unknown panel "${L.panel}"; known panels are ${Object.keys(X).join(", ")}`);const C=D.ownerDocument||r(D),O=E(P,C,L.announce),N=new I;N.init({document:C,host:O,grid:P,props:L.props||{}});const G=N.element();D.appendChild(G);const q=[];for(const Z of s)F(P.on)&&q.push(P.on(Z,()=>N.refresh()));return F(P.on)&&q.push(P.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,F(N.destroy)&&N.destroy(),G&&G.parentNode&&G.parentNode.removeChild(G)}}}const A=260,k=30,y=`${t.panel}-dock`;function S(L,P,D){if(!L||!F(L.set))return;const I=m(D.filters.get(),P)||null,C=F(L.get)&&(!F(L.active)||L.active())&&L.get()||null;JSON.stringify(C)!==JSON.stringify(I)&&(I?L.set(I):F(L.clear)?L.clear():L.set(null))}function R(L,P){if(L==="insights"){const C=P&&F(P.get)?P.get("insights"):null;return{other:(C&&typeof C=="object"?C:{}).compareWith||null}}if(L!=="views")return{};const D=P&&F(P.get)?P.get("views"):null,I=D&&typeof D=="object"?D:{};return{allowSave:I.allowSave!==!1,showDiff:I.showDiff===!0,builtinTitle:I.builtinTitle,savedTitle:I.savedTitle}}function j(L,P){const D=L!==null&&typeof L=="object",I=D?L.name:L,C=F(I),O=C?I.name||"panel":String(I),N=C?I:X[O];if(!N)return B(`toolpanel:${O}`,`unknown tool panel "${O}"`),null;const G=D&&L.props||{};return{name:O,title:D&&L.title||(W[O]?P.messages.t(W[O]):O),icon:D&&L.icon||H[O]||O,Ctor:N,props:{...C?{}:R(O,P),...G}}}function x(L){const P=L.pagination&&F(L.pagination.get)?L.pagination.get():null;return P&&Number.isFinite(P.total)?P.total:L.rows.count()}function E(L,P,D){const I=new Map;return{announce(C,O){F(D)&&D(C,O)},t(C,O){return L.messages.t(C,O)},grid:L,document:P,columns:()=>L.columns.all(),columnGroups:()=>L.state.get().columnGroups||[],groupColumns:(C,O)=>L.columns.groupColumns(C,O),ungroupColumn:C=>L.columns.ungroupColumn(C),renameGroup:(C,O)=>L.columns.renameGroup(C,O),dissolveGroup:C=>L.columns.dissolveGroup(C),showColumns:C=>L.columns.show(C),hideColumns:C=>L.columns.hide(C),groupBy:()=>L.state.get().group||[],setGroupBy:C=>L.columns.group(C),pivotBy:()=>(L.state.get().pivot||{}).columns||[],setPivotBy:C=>L.columns.pivot(C),valueColumns:()=>L.columns.all().filter(C=>C.total).map(C=>C.id),setValueColumns:C=>L.columns.totals(C),valueAggregation(C){const O=L.columns.get(C);return!O||!O.total?"sum":typeof O.total=="string"?O.total:"custom"},setValueAggregation(C,O){L.columns.setTotal(C,O)},quickFilter:()=>L.state.get().quick||"",setQuickFilter:C=>L.filters.quick(C),rowCount:()=>x(L),totalRowCount:()=>F(L.rows.totalCount)?L.rows.totalCount():L.rows.count(),formattableColumns:()=>L.columns.visible().filter(C=>!C.generated).map(C=>({id:C.id,title:String(C.title??C.id)})),formattingRules:C=>L.formatting.list(C),columnSamples:C=>{let O=C;if(!O||O==="*"){const q=L.columns.visible().find(Z=>!Z.generated);O=q?q.id:null}if(!O)return[];const N=[],G=new Set;for(const q of i(L)){const Z=L.rows.value(q.key,O);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(C=>!C.generated).map(C=>({id:C.id,title:String(C.title??C.id)})),columnProfile:C=>{const O=L.config().source;return((L.state.get().pivot||{}).columns||[]).length&&O&&typeof O=="object"&&F(O.aggregate)?null:L.statistics.profile(C)},columnProfileAsync:C=>L.statistics.profileAsync(C),reduceColumn:(C,O)=>L.statistics.reduce(C,O),columnCapability:C=>L.statistics.capability(C),regressionModel:C=>F(L.statistics.regressionModel)?L.statistics.regressionModel(C):null,insightsColumns:()=>L.columns.visible().filter(C=>!C.generated).map(C=>({id:C.id,title:String(C.title??C.id),type:C.type})),subsetVsPopulation:()=>L.statistics.subsetVsPopulation(),datasetVsDataset:C=>L.statistics.datasetVsDataset(C),compareGroups:(C,O)=>L.statistics.compareGroups(C,O),anomalies:C=>L.statistics.anomalies(C||{}),compareColumns:(C,O)=>{if(!C||!O||C===O)return null;const N=L.statistics.regression(C,O);return{n:N?N.n:0,pearson:L.statistics.correlation(C,O),spearman:L.statistics.spearman(C,O),kendall:L.statistics.kendall(C,O),covariance:L.statistics.covariance(C,O),slope:N?N.slope:null,intercept:N?N.intercept:null,r2:N?N.r2:null,stdError:N?N.stdError:null,weighted:L.statistics.weightedAverage(C,O)}},addRule:(C,O)=>L.formatting.add(C,O),removeRule:(C,O)=>L.formatting.remove(C,O),updateRule:(C,O,N)=>L.formatting.update(C,O,N),moveRule:(C,O,N)=>L.formatting.move(C,O,N),clearRules:C=>L.formatting.clear(C),views:()=>L.views.list(),activeId:()=>L.views.activeId,apply:C=>{L.views.apply(C)},saveAs:C=>L.views.save(C),rename:(C,O)=>L.views.rename(C,O),setDefault:C=>L.views.setDefault(C),clearDefault:()=>L.views.setDefault(null),remove:C=>L.views.remove(C),export:C=>L.views.export(C),diff:C=>L.views.diff(C),moveColumn(C,O,N){const G=L.columns.all().map(te=>te.id),q=G.indexOf(C),Z=G.indexOf(O);if(q<0||Z<0)return;let J=N?Z:Z+1;q<J&&(J-=1),J!==q&&L.columns.move(C,J)},isFiltered(C){return m(L.filters.get(),C)!==null},clearFilter(C){L.filters.set(o(L.filters.get(),C,null));const O=I.get(C);O&&F(O.clear)?O.clear():O&&F(O.set)&&O.set(null)},clearAllFilters(){L.filters.set(null);for(const C of I.values())F(C.clear)?C.clear():F(C.set)&&C.set(null)},filterFor(C){if(I.has(C))return S(I.get(C),C,L),I.get(C);const O=L.columns.get(C);if(!O)return null;const N=O.filter&&O.filter.props&&O.filter.props.values,G=c(L),q=G?L.config().context??null:null,Z=G?oe=>G.columnValues(C,{...oe||{},context:q}):null,J={grid:L,column:O,colId:C,type:O.type,locale:L.get("locale"),props:{...O.filter&&O.filter.props,values:N||(O.lookup?void 0:G?()=>Z({limit:a}).then(oe=>oe&&oe.supported?oe.values.map(le=>le.value):[]):()=>L.columns.distinct(C)),...G?{valueList:!1}:{}},lookup:O.lookup,document:P,value:oe=>L.rows.value(oe.row&&oe.row.key,C),rows:G?()=>[]:O.lookup?void 0:()=>i(L),changed:()=>{const le=(F(te.active)?te.active():!0)&&F(te.get)?te.get():null;L.filters.set(o(L.filters.get(),C,le||null))},fetchValues:Z};let te=null;const ne=G&&!N&&!O.lookup?w(O):null;if(ne&&h(ne)){const oe=G.columnValuesRefusal(C);if(oe){const le=new g;le.init({...J,props:{...J.props,valueList:!1}}),te=p(P,le,L.messages.t("filter.valuesUnsupported",{column:O.title||C})),B(`filter:values-unsupported:${C}`,`the filter on column "${C}" cannot list its values: ${oe}. It offers the text condition editor instead.`)}else te=new d,te.init(J)}else te=z(J);return te&&(S(te,C,L),I.set(C,te)),te},destroyFilters(){for(const C of I.values())F(C.destroy)&&C.destroy();I.clear()}}}class T{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(P){this.#e=P.grid,this.#t=P.document,this.#n=P.root,this.#o=E(P.grid,P.document,P.announce);const I=(P.panels||["columns","filters"]).map(C=>j(C,P.grid)).filter(Boolean);this.#l=P.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:P.document,host:this.#o,grid:P.grid,panels:I,actions:P.actions,icons:P.icons,side:this.#l,openPanel:P.openPanel})}mount(){const P=this.#t.createElement("div");P.className=`${y} ${y}--${this.#l}`,P.appendChild(this.#r.element()),this.#n.appendChild(P),this.#i=P;const D=this.#r.show.bind(this.#r),I=this.#r.hide.bind(this.#r);this.#r.show=C=>{const O=D(C);return this.#h(),O},this.#r.hide=()=>{I(),this.#h()};for(const C of[...s,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(C,()=>this.#r.refresh()));this.#s.push(this.#e.on("config:changed",C=>{C&&(C.key==="regression"||Array.isArray(C.keys)&&C.keys.includes("regression"))&&this.#r.refresh()})),this.#s.push(this.#e.on("presentation:started",C=>{this.#u=!0;const O=C&&C.options&&Array.isArray(C.options.chrome)?C.options.chrome:[];this.#c=O.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",C=>{const O=C&&C.colId,N=this.#r.panels.find(G=>G.name==="statistics");N&&O!=null&&(N.panel.column=String(O)),this.open("statistics")})),this.#h()}open(P){this.#r.show(P),this.#h()}close(){this.#r.hide(),this.#h()}toggle(P){this.#r.toggle(P),this.#h()}addAction(P){if(!(!P||!P.name)&&!this.#r.actions.some(D=>D.name===P.name)){if(this.#r.registerAction(P),this.#a&&!P.annotation){const D=this.#r.actions.find(I=>I.name===P.name);D&&this.#f(D.button)}else!this.#a&&P.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(P){this.#r.removeAction(P)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(P=>P.annotation&&P.button)?(this.#d(),!0):!1}#d(){const P=this.#r;this.#a={hidden:[],reopen:P.openPanel||null},this.#a.reopen&&P.hide(),this.#f(P.body);for(const D of[...P.tabs?.children||[]])D!==P.actionGroup&&this.#f(D);for(const D of[...P.actionGroup?.children||[]]){const I=P.actions.find(C=>C.button===D);(!I||!I.annotation)&&this.#f(D)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const P=this.#a;if(!P)return!1;this.#a=null;for(const D of P.hidden)D.el&&D.el.style&&(D.el.style.display=D.display);return P.reopen&&this.#r.show(P.reopen),this.#h(),!0}#f(P){if(!P||!P.style||!this.#a)return;const D=P.style.display||"";D!=="none"&&(P.style.display="none",this.#a.hidden.push({el:P,display:D}))}#h(){if(!this.#i)return;const P=!!this.#r.openPanel;this.#i.setAttribute("data-open",P?"true":"false"),this.#i.style.width=P?`${A}px`:"";const D=`${P?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 P=this.#r&&F(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,D=P&&(P.offsetWidth||P.getBoundingClientRect?.().width)||0;return D>0?Math.ceil(D):k}destroy(){for(const P of this.#s)P();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"),F=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,X=K("packages/dom/src/editors/common.js"),W=X.CLS,H=X.markInvalid,U=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,v=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;#f=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.#f=c&&m.colId?{key:c,colId:m.colId}:null,this.open(m)})),this.#u.push(this.#e.on("cell:edit:end",()=>{this.#f=null,this.close(!0)}));const t=this.#n.viewport.root,r=this.#e.get("edit"),i=r&&typeof r=="object"&&r.start||"double",f=m=>{if(w(m.target,t))return;const c=l(m.target,A=>A.getAttribute&&A.getAttribute("data-col"));if(!c)return;const h=l(c,A=>A.getAttribute&&A.getAttribute("data-key"));if(!h)return;const s=this.#e.rows.byKey(h.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)},u=i==="key"?null:i==="single"?"click":"dblclick";u&&(t.addEventListener(u,f),this.#u.push(()=>t.removeEventListener(u,f)));const o=m=>{!this.#i||!this.#l||this.#g(m.target)||this.commit()};this.#t.addEventListener("mousedown",o,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",o,!0))}get target(){return this.#l}open(t){const r=t.key||t.row&&t.row.key,i=t.colId;if(!r||!i)return;if(this.#i&&this.#l&&this.#l.key===r&&this.#l.colId===i){this.#m();return}this.close();const f=this.#e.columns.get(i),u=this.#e.rows.byKey(r);if(!f||!u||!U({column:f,edit:f.edit,row:u,value:this.#e.rows.value(r,i),grid:this.#e}))return;const o=this.#y(r,i);if(this.#c=o,!o){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,c=!!(m&&F(m.isSecret)&&m.isSecret(i)),h=_({grid:this.#e,column:f,colId:i,row:u,data:u.data,value:c?null:this.#e.rows.value(r,i),text:c?"":this.#e.rows.text(r,i),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:o,overlay:this.#n.viewport.overlays,onCommit:b=>this.#p({value:b,key:r,colId:i}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:b=>{this.#d||this.#e.edit.stop(b)}},this.#r);if(!h){B(`celledit.noeditor:${i}`,`column "${i}" has no editor.`);return}this.#i=h,this.#s=o,this.#l={key:r,colId:i},this.#d=!1,this.#a=this.#O(o);const s=h.element();h.popup?(this.#n.viewport.overlays.appendChild(s),d(s,o,this.#n.viewport.root)):o.replaceChildren(s),o.classList.add(v),F(h.attached)&&h.attached(),a(s);const p=b=>this.#h(b);s.addEventListener("keydown",p),this.#u.push(()=>s.removeEventListener("keydown",p))}#h(t){const r=t.key;if(r!=="Enter"&&r!=="Tab"&&r!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),r==="Escape"){this.#e.edit.stop(!0);return}const i=r==="Enter"?this.#b(t.shiftKey?-1:1):this.#w(t.shiftKey?-1:1);this.commit()&&i&&this.#e.edit.start(i.key,i.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(F(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:r}=this.#l;if(F(this.#i.value)){const i=this.#i.value();if(F(this.#i.validate)){const f=this.#i.validate(i);if(f!==!0){if(H(this.#c,f),F(this.#i.focusTarget)){const u=this.#i.focusTarget();u&&F(u.focus)&&u.focus()}return!1}H(this.#c,null)}this.#p({value:i,key:t,colId:r})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(){const t=F(this.#i.element)?this.#i.element():null;if(!t)return;const r=t.querySelector&&t.querySelector("input, select, textarea, [tabindex]")||t;F(r.focus)&&r.focus()}#g(t){if(!t)return!1;const r=F(this.#i.element)?this.#i.element():null;if(r&&F(r.contains)&&r.contains(t))return!0;const i=this.#c;return!!(i&&F(i.contains)&&i.contains(t))}#b(t){if(!this.#l||this.#a<0)return null;for(let r=this.#a+t;r>=0&&r<this.#e.rows.count();r+=t){const i=this.#e.rows.get(r);if(i&&!i.group)return{key:i.key,colId:this.#l.colId}}return null}#w(t){if(!this.#l)return null;const r=this.#e.columns.visible(),i=r.findIndex(f=>f.id===this.#l.colId);for(let f=i+t;f>=0&&f<r.length;f+=t){const u=r[f];if(u.edit&&u.edit.enabled)return{key:this.#l.key,colId:u.id}}return null}#O(t){const r=l(t,f=>f.getAttribute&&f.getAttribute("data-index"));if(!r)return-1;const i=Number(r.getAttribute("data-index"));return Number.isFinite(i)?i:-1}#y(t,r){const i=this.#n.viewport.root;if(!i||!i.querySelectorAll)return null;for(const f of i.querySelectorAll(`[data-col="${r}"]`)){const u=l(f,o=>o.getAttribute&&o.getAttribute("data-key"));if(u&&u.getAttribute("data-key")===t)return f}return null}close(t=!1){const r=this.#l,i=this.#d;this.#c&&H(this.#c,null);const f=this.#j();if(this.#i&&F(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(v),this.#o&&F(this.#o.releaseCell)){const u=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,u)}this.#s.replaceChildren&&this.#s.replaceChildren(),f&&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&&r&&!i){const u=this.#f;u&&u.key===r.key&&u.colId===r.colId&&this.#e.edit.stop(!1)}}#j(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&F(this.#i.element)?this.#i.element():null,i=f=>!!f&&F(f.contains)&&f.contains(t);return i(r)||i(this.#s)}#k(t){const i=F(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;i&&F(i.focus)&&i.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function l(n,t){let r=n;for(;r;){if(t(r))return r;r=r.parentNode}return null}function d(n,t,r){if(!F(t.getBoundingClientRect))return;const i=t.getBoundingClientRect(),f=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(i.top-f.top)}px`,n.style.minWidth=`${Math.round(i.width)}px`,n.style.left=`${Math.round(i.left-f.left)}px`;const u=n.offsetWidth||Math.round(i.width),o=Math.round(i.left-f.left)+u-Math.round(f.width);o>0&&(n.style.left=`${Math.max(0,Math.round(i.left-f.left)-o)}px`)}function a(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;F(t.focus)&&t.focus(),F(t.select)&&t.select()}}),Le("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return U}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,H=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class U{#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,v=w.createElement("div");v.className=H;const g=w.createElement("span");g.className=`${H}__ref`,g.textContent="";const l=w.createElement("div");l.className=`${H}__slot`;const d=w.createElement("span");d.className=`${H}__readonly`,v.appendChild(g),v.appendChild(l),this.#n.insertBefore(v,this.#n.firstChild),this.#r=v,this.#o=g,this.#i=l,this.#l=d;for(const a of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(a,n=>this.#h(n)))}bind(w,v){const g=this.#e.columns.get(v),l=w?this.#e.rows.byKey(w):null;this.#a=l&&g&&!l.group?{key:w,colId:v}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:w,colId:v}=this.#a,g=this.#e.columns.get(v);if(!g)return;if(this.#o.textContent=g.title||v,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,v),this.#i.appendChild(this.#l);return}const d=this.#e.rows.byKey(w);if(!d)return;const a=_({grid:this.#e,column:g,colId:v,row:d,data:d.data,value:this.#e.rows.value(w,v),text:this.#e.rows.text(w,v),locale:this.#e.get("locale"),props:g.edit&&g.edit.props,lookup:g.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:f=>f?this.cancel():this.commit(!0)});if(!a){B(`editbar.noeditor:${v}`,`column "${v}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,v),this.#i.appendChild(this.#l);return}this.#s=a;const n=a.element();a.popup?(this.#l.textContent=this.#e.rows.text(w,v),this.#i.appendChild(this.#l)):this.#i.appendChild(n),F(a.attached)&&a.attached();const t=f=>this.#p(f),r=()=>{this.#u=!0},i=[n,this.#i];for(const f of i)f.addEventListener("keydown",t),f.addEventListener("input",r),f.addEventListener("change",r);this.#c=()=>{for(const f of i)f.removeEventListener("keydown",t),f.removeEventListener("input",r),f.removeEventListener("change",r)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&F(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#h(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:v,colId:g}=this.#a;if(!this.#s||!F(this.#s.value))return!1;const l=this.#s.value();return this.#u=!1,this.#e.edit.start(v,g),this.#e.edit.stop(!1,{value:l,key:v,colId:g}),this.refresh(),!0}destroy(){this.#f();for(const w of this.#d)w();this.#d=[],this.#r&&F(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 H}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return z}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.clear,H="lat-pastepreview",U='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(v){this.#e=v.grid,this.#t=v.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(v,g){const l=this.#e;return(l&&l.messages?l.messages:$).t(v,g)}#d(v){const g=`paste.preview.reason.${v}`,l=this.#c(g);return l===g?v:l}#f(v){return v==null||v===""?"":String(v)}#h(v,g){const l=this.#e.columns&&F(this.#e.columns.get)?this.#e.columns.get(g):null;return`${l&&(l.title||l.headerName)||g} · ${v}`}show(v,g){const l=this.#w();if(!l)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const d=v&&v.changes||[],a=v&&v.rejected||[],n=d.filter(r=>r.changed);this.#p(n,a);const t=l.ownerDocument;return this.#s=t&&t.activeElement,l.style.display="",F(l.focus)&&l.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:a.length}),{repeat:!0}),!0}#p(v,g){const l=this.#r.ownerDocument;W(this.#r);const d=X(l,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:v.length,changes:v.length,rejected:g.length})});if(this.#r.appendChild(d),!v.length&&!g.length){this.#r.appendChild(X(l,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!v.length;return}this.#o.disabled=!v.length,v.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:v.length})})),this.#r.appendChild(this.#m(l,v))),g.length&&(this.#r.appendChild(X(l,"h3",{class:`${H}__heading ${H}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:g.length})})),this.#r.appendChild(this.#g(l,g)))}#m(v,g){const l=X(v,"tr",{children:[X(v,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(v,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(v,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),d=g.map(a=>X(v,"tr",{children:[X(v,"th",{attrs:{scope:"row"},text:this.#h(a.key,a.colId)}),X(v,"td",{class:`${H}__old`,text:this.#f(a.oldValue)}),X(v,"td",{class:`${H}__new`,text:this.#f(a.newValue)})]}));return X(v,"table",{class:`${H}__table`,children:[X(v,"thead",{children:[l]}),X(v,"tbody",{children:d})]})}#g(v,g){const l=X(v,"tr",{children:[X(v,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(v,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),d=g.map(a=>X(v,"tr",{children:[X(v,"th",{attrs:{scope:"row"},text:this.#h(a.key,a.colId)}),X(v,"td",{class:`${H}__reason`,text:this.#d(a.reason)})]}));return X(v,"table",{class:`${H}__table ${H}__table--rejected`,children:[X(v,"thead",{children:[l]}),X(v,"tbody",{children:d})]})}confirm(){const v=this.#l;this.#b(),F(v)&&v()}cancel(){const v=this.#a;this.#b(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),F(v)&&v()}#b(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const v=this.#s;this.#s=null,v&&F(v.focus)&&v.focus()}#w(){if(this.#n)return this.#n;const v=this.#t.viewport&&this.#t.viewport.overlays,g=v&&v.ownerDocument;if(!v||!g||!F(g.createElement))return null;const l=`${H}-title`,d=X(g,"h2",{class:`${H}__title`,attrs:{id:l},text:this.#c("paste.preview.title")}),a=X(g,"div",{class:`${H}__body`}),n=X(g,"button",{class:`${H}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(g,"button",{class:`${H}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=X(g,"div",{class:`${H}__foot`,children:[t,n]}),i=X(g,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":l},children:[X(g,"div",{class:`${H}__head`,children:[d]}),a,r]});return v.appendChild(i),this.#n=i,this.#r=a,this.#o=n,this.#i=t,this.#O(i,n,t),i}#O(v,g,l){const d=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...v.querySelectorAll(U)].filter(o=>!o.disabled);if(!r.length){t.preventDefault();return}const i=r[0],f=r[r.length-1],u=v.ownerDocument.activeElement;t.shiftKey&&(u===i||u===v)?(t.preventDefault(),f.focus()):!t.shiftKey&&u===f&&(t.preventDefault(),i.focus())},a=t=>{t&&F(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&F(t.preventDefault)&&t.preventDefault(),this.cancel()};v.addEventListener("keydown",d),g.addEventListener("click",a),l.addEventListener("click",n),this.#u.push(()=>{v.removeEventListener("keydown",d),g.removeEventListener("click",a),l.removeEventListener("click",n)})}#y(v,g){const l=this.#t&&this.#t.announce;F(l)&&l.call(this.#t,v,g)}destroy(){for(const v of this.#u)v();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 i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),X=_.extendSeries,W=_.resolveSelectionConfig,H=K("packages/dom/src/renderer/textentry.js"),U=H.isTextEntry,z=H.isFindBarControl,v=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),l=g.chartableRange,d=g.rangeChartConfig,a="lat-cell--range",n="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"}),r=3;class i{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.document,this.#a=o.preview||null}mount(){const o=this.#t.viewport.root,m=p=>this.#c(p),c=p=>this.#d(p),h=()=>this.#f(),s=p=>this.#h(p);o.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",h),o.addEventListener("keydown",s),this.#o.push(()=>{o.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",h),o.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(o){if(o.button!==0)return;const m=o.target;if(!m||!F(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#M())return;this.#i={mode:"fill",fromX:o.clientX,fromY:o.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const c=this.#I(m);if(!c)return;if(o.shiftKey&&this.#e.selection.corner()){const s=this.#P(c);this.#e.selection.extendRange(s.rowIndex,s.colId),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!0};return}const h=this.#T(c);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:o.ctrlKey||o.metaKey}),this.#i={mode:"select",fromX:o.clientX,fromY:o.clientY,armed:!1}}#d(o){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(o.clientX-m.fromX)+Math.abs(o.clientY-m.fromY)<r)return;m.armed=!0}const c=this.#D(o.clientX,o.clientY);if(!c)return;if(m.mode==="fill"){this.#l=c,this.paint();return}const h=this.#P(c);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const o=this.#i;if(this.#i=null,!!o){if(o.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#h(o){if(this.#z()||z(o.target)||U(o.target))return;const m=o.ctrlKey||o.metaKey,c=o.key;if(m&&(c==="c"||c==="C")){this.copy(),o.preventDefault();return}if(m&&(c==="v"||c==="V")){this.paste(),o.preventDefault();return}if(m&&(c==="d"||c==="D")){this.fillDown(),o.preventDefault();return}if(m&&!o.altKey&&(c==="z"||c==="Z"||c==="y"||c==="Y")){const j=this.#e.edit;if(!j||j.undoShortcuts===!1)return;const x=c==="y"||c==="Y"||o.shiftKey;this.#y(x)&&o.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(),o.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),o.preventDefault();return}if(o.altKey&&c==="F1"){this.chartSelection()&&o.preventDefault();return}if(!o.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!h)return;if(m){const j=this.#L();if(!j)return;if(!this.#r){const P=this.#T(j);this.#u=P,this.#e.selection.startRange(P.rowIndex,P.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map(P=>P.id),E=x.indexOf(j.colId),T=this.#e.selection.corner()||{row:j.rowIndex,colId:j.colId},L=this.#P({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,T.row+h[0])),colId:x[Math.min(x.length-1,Math.max(0,(E<0?0:E)+h[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),o.preventDefault();return}this.#r=!1;const s=this.#e.selection.corner(),p=this.#L(),b=s||p;if(!b)return;if(!s&&p){const j=this.#T(p);this.#u=j,this.#e.selection.startRange(j.rowIndex,j.colId)}const A=this.#e.columns.visible().map(j=>j.id),k=A.indexOf(b.colId??b.colId),y=A[Math.min(A.length-1,Math.max(0,k+h[1]))],S=Math.min(this.#e.rows.count()-1,Math.max(0,(s?s.row:p.rowIndex)+h[0])),R=this.#P({rowIndex:S,colId:y});this.#e.selection.extendRange(R.rowIndex,R.colId),o.preventDefault()}async copy(){const o=this.#e.export.rangeText();if(!o)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||!F(m.writeText))return!1;try{return await m.writeText(o),this.#e.emit("clipboard:copy",{text:o,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:o,ok:!1,rows:"range"},"user"),!1}}async paste(){const o=globalThis.navigator&&globalThis.navigator.clipboard;if(!o||!F(o.readText))return 0;let m="";try{m=await o.readText()}catch{return 0}return this.pasteText(m)}pasteText(o){if(!o)return 0;const m=this.#e.selection.cells(),c=m.length?m[0]:this.#O();if(!c)return 0;const h=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,o,h);if(s.changes.length+s.rejected.length>1)return this.#m().show(s,{onConfirm:()=>this.#g(c,o,h)}),0}return this.#g(c,o,h)}#p(){const o=this.#e.edit;return!!(o&&o.pastePreview&&F(o.previewPaste))}#m(){return this.#a||(this.#a=new v({grid:this.#e,renderer:this.#t})),this.#a}#g(o,m,c){const h=this.#e.edit.pasteInto(o,m,c,{origin:"user"}),s=p=>this.#w(p?this.#b("a11y.range.written",{count:p}):this.#b("a11y.range.refused"),{repeat:!0});return h&&F(h.then)?h.then(s):s(h),h}#b(o,m){const c=this.#e;return(c&&c.messages?c.messages:$).t(o,m)}#w(o,m){const c=this.#t&&this.#t.announce;F(c)&&c.call(this.#t,o,m)}#O(){const o=this.#L();if(!o)return null;const m=this.#e.rows.get(o.rowIndex);return m?{key:m.key,colId:o.colId}:null}#y(o){const m=this.#e.history;return!(!m||!(o?m.canRedo():m.canUndo())||!(o?m.redo():m.undo()))}clear(){let o=this.#e.selection.cells();const m=this.#O(),c=this.#n&&this.#n.activeElement;if(!!(m&&c&&F(c.matches)&&c.matches('[data-col][tabindex="0"]'))&&!o.some(b=>b.key===m.key&&b.colId===m.colId)?o=[m]:o.length||(o=m?[m]:[]),!o.length)return 0;const s=this.#e.edit.setCells(o.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&&F(s.then)?s.then(p):p(s),s}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const o=this.#e.selection.cells();if(o.length<2)return 0;const m=[...new Set(o.map(s=>s.key))];if(m.length<2)return 0;const c=m[0],h=[];for(const{key:s,colId:p}of o)s!==c&&h.push({key:s,colId:p,value:this.#e.rows.value(c,p)});return this.#e.edit.setCells(h,"cell",{origin:"user"})}chartSelection(){const o=d(this.#e);if(!o.handler)return!1;const m=l(this.#e);return m?(o.handler(this.#e,m),!0):!1}fillTo(o){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))],h=[...new Set(m.map(y=>y.colId))],s=this.#B(c[c.length-1]);if(s<0||o<=s)return 0;const p=[];for(let y=s+1;y<=o;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 h){const S=c.map(j=>this.#e.rows.value(j,y)),R=this.#j(S,p,y);for(let j=0;j<p.length;j++)b.push({key:p[j].key,colId:y,value:R[j]})}const A=this.#e.edit.setCells(b,"cell",{origin:"user"}),k=this.#e.selection.corner();return k&&this.#e.selection.extendRange(o,k.colId),A}#j(o,m,c){const h=this.#e.get("selection"),s=h&&typeof h=="object"?h.fill:void 0;if(F(s)){const p=this.#e.columns.get(c),b=m.map(k=>({row:k,column:p})),A=s({source:o,target:b,direction:"down"});if(Array.isArray(A)&&A.length===m.length)return A}return X(o,m.length)}paint(){const o=this.#t.viewport.root;if(!o||!o.querySelectorAll)return;const m=this.#e.selection,c=m.ranges().length>0,h=this.#l;for(const s of o.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=!!h&&this.#k(y,p,h);s.classList.toggle(a,S||R);const j=S||R?this.#C(y,p,m):null;s.classList.toggle(n,!!j&&j.any);for(const[x,E]of Object.entries(t))s.classList.toggle(E,!!j&&j[x])}this.#S()}#k(o,m,c){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(b=>b.colId)).has(m))return!1;const p=this.#B([...new Set(h.map(b=>b.key))].pop());return o>p&&o<=c.rowIndex}#C(o,m,c){const h=this.#e.columns.visible().map(k=>k.id),s=h.indexOf(m),p=s>0?h[s-1]:null,b=s>=0&&s<h.length-1?h[s+1]:null,A={top:!c.inRange(o-1,m),bottom:!c.inRange(o+1,m),left:!p||!c.inRange(o,p),right:!b||!c.inRange(o,b)};return A.any=A.top||A.bottom||A.left||A.right,A}#S(){const o=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!o||this.#$()===!1||this.#e.selection.ranges().length>1||this.#M()){this.#s&&(this.#s.style.display="none");return}const c=this.#_(o.row,o.colId);if(!c||!F(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 h=c.getBoundingClientRect(),s=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const b=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(b-s.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-s.top)-4}px`}#E(o){const m=this.#t;return!o||typeof m.spanAt!="function"?null:m.spanAt(o.rowIndex,o.colId)}#T(o){const m=this.#E(o);return m?{rowIndex:m.row,colId:m.columnId}:o}#P(o){const m=this.#E(o);if(!m)return o;const c=this.#u,h=!!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:h?m.row:m.row+m.rows-1,colId:b?m.columnId:m.endColumnId}}#M(){const o=this.#e.selection.corner();if(!o)return!1;const m=this.#E({rowIndex:o.row,colId:o.colId});return!!m&&(m.rows>1||m.cols>1)}#N(){const o=this.#e.columns;return o&&F(o.visible)?o.visible().map(m=>m.id):[]}#$(){return W(this.#e.get("selection")).fillHandle}#z(){const o=this.#t.viewport.root;return!!(o&&o.querySelector&&o.querySelector(".lat-editor-host, .lat-editor--popup"))}#V(){const o=this.#e.selection.cells();return o.length?o[0]:null}#B(o){for(let m=0;m<this.#e.rows.count();m++){const c=this.#e.rows.get(m);if(c&&c.key===o)return m}return-1}#L(){const o=this.#t.viewport.root,m=o&&o.querySelector?o.querySelector('[data-col][tabindex="0"]'):null;return m?this.#I(m):null}#I(o){if(!o||!F(o.closest))return null;const m=o.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const c=m.closest("[data-index]");if(!c)return null;const h=Number(c.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:m.getAttribute("data-col")}}#D(o,m){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(o,m):null;return c?this.#I(c):null}#_(o,m){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const h of c.querySelectorAll(`[data-col="${m}"]`)){const s=h.closest?h.closest("[data-index]"):null;if(s&&Number(s.getAttribute("data-index"))===o)return h}return null}destroy(){for(const o of this.#o)o();this.#o=[],this.#s&&F(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&F(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=i}),Le("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return i}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),X=_.parseDelimited,W=_.inferColumns,H=_.mapRecords,U=_.readXlsx,z=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),v=w.el,g=w.clear,l=w.on,a=K("packages/dom/src/renderer/textentry.js").isTextEntry,n="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class i{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document;const o=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:o.file!==!1,drop:o.drop!==!1,paste:o.paste!==!1,mode:o.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(l(u,"dragover",o=>{o.dataTransfer&&[...o.dataTransfer.types||[]].includes("Files")&&(o.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(l(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(l(u,"drop",o=>{u.classList.remove("lat-import--dropzone");const m=o.dataTransfer&&o.dataTransfer.files&&o.dataTransfer.files[0];m&&(o.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(l(u,"paste",o=>{if(a(o.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=o.clipboardData&&o.clipboardData.getData("text/plain");!m||!m.includes(`
|
|
57
|
-
`)||(o.preventDefault(),this.fromText(m))})))}openFile(){const u=v(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const o=u.files&&u.files[0];o&&this.#c(o),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(F(u.arrayBuffer)){u.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,u.name);return}this.fromText(new TextDecoder().decode(c),u.name)});return}if(F(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const o=new this.#n.defaultView.FileReader;o.onload=()=>this.fromText(String(o.result||""),u.name),o.readAsText(u)}async fromXlsx(u,o){const{header:m,rows:c}=await U(u);if(!m.length)return;const h=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:h,delimiter:null,name:o,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,o){const{header:m,rows:c,delimiter:h}=X(u);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:h,name:o,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 u=this.#i.querySelector(t);u&&F(u.focus)&&u.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(u,o){const m=this.#t&&this.#t.announce;F(m)&&m.call(this.#t,u,o)}#h(u,o){return(this.#e&&this.#e.messages?this.#e.messages:$).t(u,o)}#p(){const u=this.#n,o=v(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),m=v(u,"div",{class:`${n}__panel`});m.appendChild(v(u,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=v(u,"div",{class:`${n}__body`}),m.appendChild(this.#s);const c=v(u,"div",{class:`${n}__footer`}),h=v(u,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),s=v(u,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(l(h,"click",()=>this.close())),this.#o.push(l(s,"click",()=>this.#g())),c.appendChild(h),c.appendChild(s),m.appendChild(c),o.appendChild(m),this.#o.push(l(o,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const A=[...o.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(o),this.#i=o}#m(){const u=this.#n,o=g(this.#s),{rows:m,columns:c,name:h,warnings:s}=this.#l;o.appendChild(v(u,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:m.length,name:h||this.#h("import.clipboard")})}));for(const S of s)o.appendChild(v(u,"p",{class:`${n}__warning`,text:S}));const p=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),b=v(u,"table",{class:`${n}__map`}),A=v(u,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])A.appendChild(v(u,"th",{text:this.#h(S)}));b.appendChild(A),c.forEach((S,R)=>{const j=v(u,"tr",{});j.appendChild(v(u,"td",{text:S.source}));const x=v(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#h("import.mapLabel",{source:S.source})}});x.appendChild(v(u,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const T of p)x.appendChild(v(u,"option",{text:T,attrs:{value:T,selected:T===S.field?!0:null}}));S.field&&!p.includes(S.field)&&x.appendChild(v(u,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const E=v(u,"td",{});E.appendChild(x),j.appendChild(E),j.appendChild(v(u,"td",{class:`${n}__type`,text:S.type})),b.appendChild(j)}),o.appendChild(b);const k=v(u,"div",{class:`${n}__mode`}),y=v(u,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});y.appendChild(v(u,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(v(u,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(v(u,"label",{text:this.#h("import.modeLabel")})),k.appendChild(y),o.appendChild(k)}#g(){const{rows:u,columns:o}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));o[b]&&p.value!==void 0&&p.value!==null&&(o[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,h=c==="replace"||c==="append"?c:this.#r.mode,s=H(u,o);this.#e.import.apply(s,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&F(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();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 v}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H=_.clear,U=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:$).t(l,d)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||$;const d=l||{};if(this.doc=U(d),this.host=d.host||{},this.props=d.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(l,d,a){const n=X(this.doc,"button",{class:`${z}__${l}`,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:d})]});return this.off.push(W(n,"click",()=>{const t=this.host[l];F(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,d=F(l.canUndo)?l.canUndo():!1,a=F(l.canRedo)?l.canRedo():!1,n=F(l.peek)?l.peek("undo"):null,t=F(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(l,d,a,n){if(!l)return;l.disabled=!a;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),i=l.querySelector(`.${z}__label`);i&&(i.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",a?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",a?f: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 l=this.menu;if(!l)return;H(l);const d=F(this.host.list)?this.host.list():[];if(!d.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((a,n)=>{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 r=n+1;for(let i=0;i<r;i++)F(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(t)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&F(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const v=w}),Le("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),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"),F=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",H="lat-cell--added-column";class U{#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 l=this.#e.diff,d=l&&l.enabled;for(const a of g.querySelectorAll("[data-key]")){const n=a.getAttribute("data-key"),t=d?l.statusOf(n):"unchanged";for(const i of Object.values(X))a.classList.remove(i);d&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const i of a.querySelectorAll("[data-col]")){const f=i.getAttribute("data-col");if(i.classList.remove(W,H),i.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,f);if(u==="changed"){i.classList.add(W);const o=this.#r(l,n,f);o===null?i.removeAttribute("title"):(i.setAttribute("data-before",o),i.setAttribute("title",this.#o("diff.before",{value:o})))}else u==="added-column"&&i.classList.add(H)}}}#r(g,l,d){const a=this.#e,n=a&&a.columns,t=n&&F(n.get)?n.get(d):null,r=a&&a.permissions;if(t&&r&&F(r.isSecret)&&r.isSecret(t))return null;const i=g.before(l,d);if(i==null)return this.#o("diff.empty");if(!t||!F(t.formatValue))return String(i);const f=F(g.beforeRow)?g.beforeRow(l):void 0,o={...(a.rows&&F(a.rows.byKey)?a.rows.byKey(l):null)||{},data:f===void 0?{}:f};try{const m=t.formatValue(i,o,o.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(i)}}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:_).t(g,l)}destroy(){for(const l of this.#n)l();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const l of g.querySelectorAll("[data-key]")){for(const d of Object.values(X))l.classList.remove(d);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(v){return!!(v&&v.diff&&(F(v.diff)||typeof v.diff=="object"))}const w=U}),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 F=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",$="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.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 H=()=>{this.#o=!1,this.paint()};F(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):F(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const v of z.querySelectorAll("[data-col]")){const g=U.active?U.colourFor(w,v.getAttribute("data-col")):null;g?(v.classList.add(B),v.style.setProperty($,g)):v.classList.contains(B)&&(v.classList.remove(B),v.style.removeProperty($))}}this.#s(U)}}#s(H){this.#r!==null&&F(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!F(this.#i.setTimeout))return;const z=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&F(H.model)?H.model():null}destroy(){this.#r!==null&&F(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty($)}}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 $}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const F=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",$="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.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 H=()=>{this.#r=!1,this.paint()};F(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):F(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!F(U.stateFor))return;const z=F(U.model)?U.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let v=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const d of g.querySelectorAll("[data-col]")){const a=w?U.stateFor(l,d.getAttribute("data-col")):null;a?(v=!0,d.classList.add(B),d.classList.toggle($,a==="current")):d.classList.contains(B)&&d.classList.remove(B,$)}}this.#o=v}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,$);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 l}});const Q=K("packages/dom/src/editors/common.js"),F=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,v=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!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,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:W).t(a,n)}mount(){const a=this.#j();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 n=this.#t.viewport?.root;if(n&&U(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const i=r.target;if(this.#s&&i===this.#s){r.preventDefault(),r.stopPropagation(),U(this.#s.select)&&this.#s.select();return}_(i)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.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 n=this.#k();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#y(),this.#j().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#E()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#V();const a=this.#j();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),a&&(a.clear(),a.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const i=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(i.focus)&&i.focus()}search(){this.#E()}destroy(){this.#O=!0,this.#V();for(const n of this.#g)n();this.#g=[];const a=this.#j();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&&U(a.invalidate)&&a.invalidate("size")}#j(){const a=this.#e&&this.#e.find;return a&&U(a.model)?a.model():null}#k(){if(this.#i)return this.#i;const a=this.#t.viewport,n=a?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=F(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=F(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=F(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=F(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=F(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const i=F(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=F(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=F(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=F(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=F(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=F(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),o=F(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const c of[this.#s,this.#l,this.#a,this.#u,i,f,u,o])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(i,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),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.#f,"change",()=>{const c=this.#f.value;this.#m=c?String(c):null,this.#E()})),this.#g.push(B(u,"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 r.addEventListener("keydown",m),this.#g.push(()=>r.removeEventListener("keydown",m)),r.style.display="none",n.insertBefore(r,a.header||n.firstChild),this.#i=r,this.#C(),r}#C(){const a=this.#f;if(!a)return;const n=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(F(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let i=!1;for(const f of r){if(!f||f.id===void 0)continue;const u=String(f.id);a.appendChild(F(n,"option",{text:f.title||u,attrs:{value:u}})),u===this.#m&&(i=!0)}i||(this.#m=null),a.value=this.#m||""}#S(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):v;if(this.#$(),a===0||!U(this.#r.setTimeout)){this.#E();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#E()},a)}#E(){const a=this.#j();if(!a||this.#O)return;const n=this.#s?this.#s.value:"";if(!n){this.#z(),a.clear();return}a.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#T()}),this.#P()}#T(){const a=this.#t&&this.#t.window,n=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,n)}#P(){if(this.#w!==null||this.#O)return;const a=()=>{this.#w=null,this.#M()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(a):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(a,0):a()}#M(){const a=this.#j();!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(),n=this.#j().active;let t="",r="idle";n&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),r=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),r=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const i=n&&a.windowed;this.#a.textContent=i?this.t("find.loadedRows"):"",this.#a.style.display=i?"":"none",n?a.complete&&(this.#u.textContent=a.total===0?this.t(i?"a11y.find.noneLoaded":"a11y.find.none"):this.t(i?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#$(){this.#b!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#z(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#V(){this.#$(),this.#z()}}const l=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 $}});const Q="lat-cell--redacted",F="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 H=W.active;for(const U of X.querySelectorAll(`.${F}[data-col]`))H&&W.has(U.getAttribute("data-col"))?U.classList.add(Q):U.classList.contains(Q)&&U.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const $=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 F=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function $(W,H){let U=W;for(;U;){if(H(U))return U;U=U.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const U=$(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),v=this.#r(z),g=v?H.errorFor(v,w):null;F(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();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 v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class v{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),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&&F(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 d=this.#t.viewport?.root;if(d&&F(d.addEventListener)){const a=n=>this.#l(n);d.addEventListener("keydown",a),this.#r.push(()=>d.removeEventListener("keydown",a))}}#l(d){const a=this.#e.presentation;if(!a?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(a.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(a.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),d.preventDefault?.()):t==="0"&&(a.setScale(1.5),d.preventDefault?.());return}if(!a.views.length||$(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),d.preventDefault?.()):t==="Home"?(a.goTo(0),d.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const n=a.ownerDocument;if(!n?.createElement)return;if(!this.#i){const i=n.createElement("div");i.className=U,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),a.appendChild(i),this.#i=i}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#h();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of w){if(a.has(r)||r==="toolPanel"&&this.#O())continue;const i=this.#y(r);i&&i.style&&i.style.display!=="none"&&(i.style.display="none",n.push(i))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(W),this.#h(),this.#m()}#f(){const d=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(H),this.#p(),d){const n=this.#e.toolPanel;n&&F(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const i=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!a||i&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const d=this.#e.element;return!d||!F(d.querySelector)?null:d.querySelector(`.${X.statusBar}`)}#w(d){const a=d.children||[];for(const n of a)if(!n.style||n.style.display!=="none")return!1;return!0}#O(){const d=this.#e.toolPanel;return!!(d&&F(d.presentOnly)&&d.presentOnly())}#y(d){const a=this.#e.element;if(!a||!F(a.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?a.querySelector(n):null}destroy(){this.#o&&this.#f();for(const d of this.#r)d();this.#r=[]}}const g=v}),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 H}});const F=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function $(U,z,w){const v=w.getComputedStyle(U),g=z.style;if(g)for(let l=0;l<v.length;l++){const d=v[l];B.has(d)||g.setProperty(d,v.getPropertyValue(d),v.getPropertyPriority(d))}}function _(U,z,w){if($(U,z,w),U.tagName==="CANVAS"&&F(U.toDataURL))try{const l=U.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${l})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const v=U.children||[],g=z.children||[];for(let l=0;l<v.length&&l<g.length;l++)_(v[l],g[l],w)}function X(U,z){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,z).origin===z}catch{return!0}}async function W(U,z={}){const w=U.ownerDocument,v=w?.defaultView;if(!v||typeof v.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=U.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),d=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(z.scale)||2),n=v.location?.origin||"";for(const m of U.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,n))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=U.cloneNode(!0);_(U,t,v),t.style.width=`${l}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new v.XMLSerializer().serializeToString(t),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new v.Image;await new Promise((m,c)=>{f.onload=()=>m(void 0),f.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`});const u=w.createElement("canvas");u.width=Math.round(l*a),u.height=Math.round(d*a);const o=u.getContext("2d");if(!o)throw new Error("capture could not get a 2d context");return o.fillStyle=z.background||v.getComputedStyle(U).backgroundColor||"#ffffff",o.fillRect(0,0,u.width,u.height),o.drawImage(f,0,0,u.width,u.height),new Promise((m,c)=>{u.toBlob(h=>h?m({blob:h,width:u.width,height:u.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=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 H}}),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"),F=Q.isFunction,B=Q.uid,$=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=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,v="system-ui, -apple-system, sans-serif";function g(h,s){if(!h||typeof h!="object")return null;const p=U[h.type];if(!p)return null;const b=typeof h.id=="string"&&h.id?h.id:B("mark"),A=Array.isArray(h.points)?h.points:[],k=[];for(const S of A){const R=Number(S&&S.x),j=Number(S&&S.y);Number.isFinite(R)&&Number.isFinite(j)&&k.push({x:R,y:j})}const y=typeof h.colour=="string"&&h.colour?h.colour:s;if(p==="text"){const S=typeof h.text=="string"?h.text:"";if(!k.length||!S)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:S,region:l(h.region)},j=Number(h.fontSize);return Number.isFinite(j)&&j>0&&(R.fontSize=j),typeof h.background=="string"&&h.background&&(R.background=h.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:l(h.region)}}function l(h){return h==="start"||h==="end"?h:"centre"}function d(h){const s={id:h.id,type:z[h.tool]||h.tool,colour:h.colour,points:h.points.map(p=>({x:p.x,y:p.y}))};return(h.region==="start"||h.region==="end")&&(s.region=h.region),h.tool==="text"&&(s.text=h.text,h.fontSize!==void 0&&(s.fontSize=h.fontSize),h.background!==void 0&&(s.background=h.background)),s}const a="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,s){return{id:h,count:s,valueOf(){return this.count}}}const i=10;function f(h,s,p){const b=p.x-s.x,A=p.y-s.y,k=b*b+A*A;let y=k?((h.x-s.x)*b+(h.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(h.x-S,h.y-R)}function u(h){const s=h.points;if(!s.length)return null;if(h.tool==="text"){const y=h.fontSize||w,S=(h.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 o(h,s){const p=u(h);if(!p)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(h.tool==="text")return 1/0}const b=h.points;if(h.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,f(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,f(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(),r(p.id,this.#s.length)):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?($("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||!F(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.#f(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#h(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#f(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})}#h(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||!F(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()};F(k.addEventListener)?k.addEventListener("change",y,{once:!0}):F(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=>l(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(!F(b?.getBoundingClientRect)||!F(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=j=>{if(!F(j?.getBoundingClientRect))return null;const x=j.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.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 j of[A,k]){if(!j)continue;const x=j.left+j.width;j.left+j.width/2<R?y=Math.max(y,x):S=Math.min(S,j.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(!F(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(!F(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=(n[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 ${v}`,s.textBaseline="top";const R=p.text||"";if(p.background){let j=R.length*S*.6;if(typeof s.measureText=="function"){const x=s.measureText(R);x&&Number.isFinite(x.width)&&(j=x.width)}s.fillStyle=p.background,s.fillRect(k.x-S*.15,k.y-S*.1,j+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.#j(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}#j(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=u(p);if(!b||!F(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=i*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(l(y.region)===p&&o(y,s)<=A)return y}return null}#S(){const s=F(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 j=s.getBoundingClientRect(),{left:x,top:E}=this.#S();return{x:S.clientX-j.left+(R==="centre"?x:0),y:S.clientY-j.top+E}},b=S=>{if(!this.#o||!this.#O(S))return;const R=this.#w(S.clientX);if(this.#o==="erase"){const j=this.#C(p(S,R),R);j&&(this.remove(j.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 j=!1;S.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=S.deltaY,j=!0),S.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=S.deltaX,j=!0),j&&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&&F(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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/internal/util.js").isFunction,$=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 v=Math.round(w/60);return v<60?`${v}m ago`:`${Math.round(v/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 H{#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,v=w.depth,g=w.position;this.#r.max=String(Math.max(1,v)),this.#r.value=String(Math.max(0,v-g)),this.#r.disabled=v===0;const l=w.at(),d=w.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=v===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(w,v){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,v)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,v=w?.ownerDocument;if(!w||!v?.createElement)return;const g=v.createElement("div");g.className=_;const l=v.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const d=v.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const a=v.createElement("span");a.className=`${_}__clock`;const n=v.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(d),g.appendChild(a),g.appendChild(n),w.appendChild(g),this.#n=g,this.#r=d,this.#o=l,this.#i=a;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const i=f=>f.stopPropagation();d.addEventListener("keydown",i),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",i)})}#u(){this.#n&&(F(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 U=H}),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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",H="lat-cell--commented",U="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 l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const d=[];for(const a of l.querySelectorAll("[data-key]")){const n=a.getAttribute("data-key");if(n){d.push(n);for(const t of a.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),i=g.at(n,r),f=!!(i&&i.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&i.unresolved>0),this.#i(t,i,r)}}}(d.length!==this.#r.length||d.some((a,n)=>a!==this.#r[n]))&&(this.#r=d,g.request(d))}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:$).t(g,l)}#i(g,l,d){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=l.count,n=l.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!F(g.addEventListener))return;const l=a=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=a.target&&F(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,a))return;const r=t.closest("[data-key]"),i=r&&r.getAttribute("data-key");i&&(a.stopPropagation(),a.preventDefault(),n.open(i,t.getAttribute("data-col")))},d=a=>{const n=this.#e.comments;if(!n||!n.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&&F(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),i=r&&r.getAttribute("data-key");i&&(a.preventDefault(),a.stopPropagation(),n.open(i,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",d,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",d,!0)})}#l(g,l){if(!F(g.getBoundingClientRect))return!1;const d=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,d.height*.6));return(X(g)?l.clientX<=d.left+a:l.clientX>=d.right-a)&&l.clientY<=d.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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="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 l of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(l,d=>this.#l(l,d)));this.#a(),this.paint()}}#l(g,l){if(this.#f(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=l&&l.peer;a&&(this.#r.textContent=this.#h(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const d=this.#e.get("presence")||{},a=l.createElement("span");if(a.className=`${U}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,d.roster===!1)return;const n=l.createElement("div");n.className=U,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",g.appendChild(n),this.#n=n}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const d=g.peers(),a=[...d].sort((n,t)=>n.at-t.at);for(const n of a)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const i of t.columns||[])this.#c(l,r,i,n,"range");for(const n of a)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of a)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(d)}#u(g){if(this.#s!==null)return;const l=g.filter(n=>n.cursorFresh);if(!l.length)return;const a=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,l,d,a,n){const t=g.querySelector(`[data-key="${X(l)}"]`),r=t&&t.querySelector(`[data-col="${X(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",a.colour),r.setAttribute("data-peer-name",a.name),r.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&a.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${d}`))}#d(g){if(this.#o.size){for(const l of g.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const g=this.#n.ownerDocument,l=this.#e.presence.peers();if(this.#n.textContent="",!l.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of l){const n=g.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",a.colour),n.toggleAttribute("data-idle",!!a.idle),n.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:a.name}));const r=g.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const i=g.createElement("span");i.className=`${U}__name`,i.textContent=a.name,n.appendChild(i),n.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(n)}const d=l.filter(a=>a.hidden).length;if(d){const a=g.createElement("span");a.className=`${U}__hidden`,a.textContent=this.#h("presence.hidden",{count:d}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const l=g&&g.name?g.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:l})}#h(g,l){const d=this.#e;return(d&&d.messages?d.messages:$).t(g,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&F(this.#n.remove)&&this.#n.remove(),this.#r&&F(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 v}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function v(a,n){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((n-a)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function g(a,n,t,r){n.textContent="";const i=String(t??"");if(!r){n.textContent=i;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,o=f.exec(i);for(;o;){o.index>u&&n.appendChild(a.createTextNode(i.slice(u,o.index)));const m=o[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),n.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),n.appendChild(c)}else{const c=m.indexOf("]("),h=m.slice(1,c),s=m.slice(c+2,-1);if(z.test(s)){const p=a.createElement("a");p.href=s,p.textContent=h,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(a.createTextNode(h))}u=o.index+m.length,o=f.exec(i)}u<i.length&&n.appendChild(a.createTextNode(i.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),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(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&F(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&F(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);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(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const i=r.querySelector(`[data-key="${X(n)}"]`);return i?i.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:$).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const i=n.createElement("div");i.className=`${U}__title`,r.appendChild(i);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const u=n.createElement("button");u.className=`${U}__close`,u.type="button",u.setAttribute("aria-label",this.#h("comments.close")),u.textContent="×",r.appendChild(u);const o=n.createElement("div");o.className=`${U}__list`,o.setAttribute("role","log"),o.setAttribute("aria-live","polite");const m=n.createElement("form");m.className=`${U}__composer`;const c=n.createElement("textarea");c.className=`${U}__input`,c.rows=2,c.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),m.appendChild(c),m.appendChild(h),t.appendChild(r),t.appendChild(o),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=o,this.#o=c,this.#m=i,this.#g=f;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(x=>x.offsetParent!==null||x===c);if(!y.length)return;const S=y[0],R=y[y.length-1],j=t.ownerDocument.activeElement;k.shiftKey&&j===S?(k.preventDefault(),R.focus()):!k.shiftKey&&j===R&&(k.preventDefault(),S.focus())};m.addEventListener("submit",s),u.addEventListener("click",p),f.addEventListener("click",b),t.addEventListener("keydown",A),this.#l.push(()=>{m.removeEventListener("submit",s),u.removeEventListener("click",p),f.removeEventListener("click",b),t.removeEventListener("keydown",A)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},i=Date.now(),f=n.openKey,{rowId:u,field:o}=H(f),m=this.#e.columns.get(o),c=this.#e.rows.byKey(u),h=F(r.rowLabel)&&c?r.rowLabel(c):u;if(this.#m.textContent=this.#h("comments.cellTitle",{column:m&&(m.title??m.id)||o,row:h}),this.#g.textContent=this.#b()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const s=n.thread||[];if(!s.length){this.#d(this.#h("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,i,p,r))}#O(n,t,r,i,f){const u=n.createElement("article");u.className=`${U}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const o=n.createElement("div");o.className=`${U}__meta`;const m=n.createElement("span");m.className=`${U}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),o.appendChild(m);const c=n.createElement("time");c.className=`${U}__time`;const h=v(t.at,r);c.textContent=t.edited?this.#h("comments.edited",{time:h}):h,o.appendChild(c),u.appendChild(o);const s=n.createElement("div");if(s.className=`${U}__body`,g(n,s,t.body,!!f.markdown),u.appendChild(s),t.value!==void 0&&!Object.is(t.value,i)){const A=n.createElement("p");A.className=`${U}__moved`,A.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(i)}),u.appendChild(A)}const p=t.can||{},b=A=>p[A]!==!1;if(b("edit")||b("delete")){const A=n.createElement("div");if(A.className=`${U}__actions`,b("delete")){const k=n.createElement("button");k.type="button",k.className=`${U}__action`,k.textContent=this.#h("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),A.appendChild(k)}u.appendChild(A)}return u}#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:r,field:i}=H(t),f=this.#f(r,i)||this.#i,u=this.#t.viewport?.root;if(!f||!u||!F(f.getBoundingClientRect))return;const o=f.getBoundingClientRect(),m=u.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let h=o.bottom-m.top+4;h+c.height>m.height&&o.top-m.top>c.height&&(h=o.top-m.top-c.height-4);let s=o.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=o.bottom<m.top||o.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&F(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=l}),Le("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H="lat-watermark",U="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class v{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),F(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&F(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#f(),this.#u()):!d&&this.#r&&(this.#h(),this.#c())}#a(){const d=this.#i;if(!d||!F(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),F(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%z.length,this.#h(),this.#f(),this.#u()},w)))}#c(){this.#l!==null&&F(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&F(d.watermark)&&d.watermark())}#f(){const d=this.grid&&this.grid.messages?this.grid.messages:$,a=X(this.#t,"a",{class:`${H}__link`,text:d.t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}}),n=X(this.#t,"span",{class:`${H}__free`,text:d.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,n]}),this.#o.push(W(this.#r,"pointerdown",t=>{F(t.stopPropagation)&&t.stopPropagation()})),this.#n&&F(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&F(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#h()}}const g=v}),Le("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.isFunction,$=K("packages/dom/src/editors/common.js"),_=$.el,X=$.on,H=K("packages/dom/src/themeof.js").themeOf,U="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",v="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 F("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:v}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,i=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(a):null;i&&(this.#e.setAttribute("data-theme",i),this.#u=!0),a.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,u]of Object.entries(z))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=u;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(U),this.#t.body.classList&&this.#t.body.classList.add(w),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const a=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,i]of Object.entries(this.#a))this.#e.style[r]=i;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(U),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.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(a){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;a(),t&&B(t.focus)&&t.focus()}#f(a){!a||a.key!=="Escape"||a.defaultPrevented||this.exit()}#h(){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 l=g}),Le("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),F=Q.documentFor,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,v=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,d=g.buildPrompt,a=g.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#O=!1;#y=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,o)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=F(u),this.#t=u.grid||null,this.#n=U(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:U(u.onPlan)?u.onPlan:null,onApply:U(u.onApply)?u.onApply:null,onError:U(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#j(u)}element(){return this.#s}refresh(){this.#O||!this.#s||this.#b!=="busy"&&this.#E()}destroy(){this.#O=!0,this.#w++;for(const u of this.#y)u();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.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#O||this.#b==="busy")return null;const o=String(u??(this.#l&&this.#l.value)??"").trim();if(!o)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 h=w(this.#t,this.#r),s=v(h);if(c=await this.#n({prompt:o,schema:h,schemaText:s,message:d(o,s),context:this.#o}),this.#O||m!==this.#w)return null;const p=a(c,h);return this.#C(p),p}catch(h){return this.#O||m!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#P(h instanceof Error?h.message:String(h))),null}}apply(){const u=this.#g;if(this.#O||!u||!u.ok)return null;const o=this.#t?.ai,m=U(o?.apply)?o.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),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: ${u.describe()}`),m}discard(){this.#O||(this.#E(),this.#T("Discarded."))}#j(u){const o=this.#e,m=B(o,"div",{class:`${n}__row`});this.#l=B(o,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push($(this.#l,"keydown",h=>{const s=h&&h.key;s==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(o,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push($(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(o,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(o,"p",{class:`${n}__summary`}),this.#d=B(o,"ul",{class:`${n}__notes`});const c=B(o,"div",{class:`${n}__buttons`});this.#f=B(o,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(o,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push($(this.#f,"click",()=>{this.apply()})),this.#y.push($(this.#h,"click",()=>{this.discard()})),c.appendChild(this.#f),c.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(o,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(o,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(u){if(this.#b=u,!this.#s)return;this.#s.setAttribute("data-state",u);const o=u==="busy";r(this.#l,o),r(this.#a,o),this.#a&&(this.#a.textContent=this.t(o?"prompt.asking":"prompt.ask")),i(this.#u,u!=="preview"),i(this.#m,u!=="error")}#C(u){const o=u;if(this.#i.onPlan&&this.#i.onPlan(u),!o.ok){this.#g=null;const m=o.rejected.length?o.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#P(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#T(""),this.#c&&(this.#c.textContent=o.describe()),this.#S(o.rejected),this.#k("preview")}#S(u){const o=this.#d;if(o){_(o),i(o,!u.length);for(const m of u.slice(0,6))o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:m.reason}));u.length>6&&o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#T(u){this.#p&&(this.#p.textContent=u)}#P(u){this.#g=null,this.#T(""),this.#m&&(this.#m.textContent=u),this.#k("error")}}function r(f,u){f&&(f.disabled=u,u?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function i(f,u){f&&(f.hidden=u,u?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),Le("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.isObject,$=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,v=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"},l="unknown",d=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 n(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 r(s,p,b=null){if(F(p)){const j=p(s,b);return j==="good"||j==="warn"||j==="bad"?j: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=j=>S?A<=j:A>=j;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function i(s){return!(F(s.value)||s.value!==void 0&&!B(s.value))}function f(s){return!s||!s.rows||!F(s.rows.totalCount)?!0:s.rows.totalCount()>0}function u(s){const p=B(s)?s:{},b=p.grid||null,A=c(p.container,b);if(!A)return $("stat.container","createStat needs a `container`: an element or a selector."),h();const k=A.ownerDocument||(typeof document>"u"?null:document);if(!k)return $("stat.document","createStat needs a document; it draws DOM."),h();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 j=k.createElement("div");j.className=g.interval;const x=k.createElement("div");x.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 te=k.createElement("span");te.className=g.icon,te.setAttribute("aria-hidden","true"),v(te,p.icon,`stat:${p.title||"stat"}`),y.appendChild(te);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(S),ne.appendChild(R),ne.appendChild(T),ne.appendChild(j),ne.appendChild(x),ne.appendChild(E),y.appendChild(ne)}else y.appendChild(S),y.appendChild(R),y.appendChild(T),y.appendChild(j),y.appendChild(x),y.appendChild(E);A.appendChild(y);let P=null;const D=[];let I=!1;function C(){if(F(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const te=B(p.value)?p.value:p,ne=te.of,oe=te.fn||"sum",le=te.show;return b?oe==="count"?N().length:ne?le?G(String(ne),String(oe),String(le)):O()==="filtered"&&b.statistics&&F(b.statistics.reduce)?b.statistics.reduce(String(ne),String(oe)):X(N().map(ae=>m(ae,String(ne))),String(oe)):null:null}function O(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const te=O();if(te==="all"){const oe=[];return F(b.rows.forEachAll)&&b.rows.forEachAll(le=>{le.group||oe.push(o(le))}),oe}if(te==="selected")return(b.selection&&F(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(o);const ne=[];return F(b.rows.forEach)&&b.rows.forEach(oe=>{oe.group||ne.push(o(oe))}),ne}function G(te,ne,oe){if(ne!=="min"&&ne!=="max")return $(`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 le=null,ae=null;for(const se of N()){const ee=Number(m(se,te));Number.isFinite(ee)&&(le===null||(ne==="max"?ee>le:ee<le))&&(le=ee,ae=se)}return ae===null?null:m(ae,oe)}function q(te){if(F(p.format))return String(p.format(te,b));if(te==null)return p.empty??"—";const ne=B(p.value)?p.value:p,oe=ne.show||ne.of;if((ne.show?!0:d.has(String(ne.fn||"sum")))&&b&&oe&&F(b.columns?.get)){const ae=b.columns.get(String(oe));if(ae&&F(ae.formatValue))return ae.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(p.decimals??2):String(te)}function Z(te){return te?(b&&b.messages||z).t(`stat.tone.${te}`):""}function J(){if(I)return;const te=C(),ne=i(p)&&!!b&&!f(b),oe=ne?null:te,le=F(p.baseline)?p.baseline(b):p.baseline;P=oe,S.textContent=p.title??"",S.hidden=!p.title,R.textContent=q(oe),T.hidden=!ne,ne&&(T.textContent=b.messages.t("stat.noData"));const ae=ne||le===void 0||le===null?a:n(typeof oe=="number"?oe:null,Number(le)),se=t(ae.direction,p.goodWhen||"up");if(x.hidden=ae.change===null,ae.change!==null){const he=ae.direction==="up"?"↑":ae.direction==="down"?"↓":"→",ge=ae.percent===null?q(Math.abs(ae.change)):`${Math.abs(ae.percent).toFixed(1)}%`;x.textContent=`${he} ${ge}`,x.setAttribute("data-tone",se),x.setAttribute("data-direction",ae.direction)}const ee=F(p.interval)?p.interval(oe,b):null,ie=!!ee&&Number.isFinite(ee.lower)&&Number.isFinite(ee.upper);j.hidden=!ie,ie&&(j.textContent=`${q(ee.lower)} – ${q(ee.upper)}`,Number.isFinite(ee.confidence)&&j.setAttribute("title",`${Math.round(ee.confidence*100)}%`));const ce=ne?l:p.bands?r(oe,p.bands,b):null;ce?y.setAttribute("data-tone",ce):y.removeAttribute("data-tone"),E.textContent=F(p.footer)?String(p.footer(oe,b)):p.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?T.textContent:"",ie?j.textContent:"",ae.change===null?"":x.textContent,ae.change===null?"":Z(se),E.textContent].filter(Boolean).join(", "))}if(b&&F(b.on)&&p.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=oe=>{te==="model:changed"&&!H(oe)||J()};b.on(te,ne),D.push(()=>F(b.off)&&b.off(te,ne))}return J(),{element:()=>y,value:()=>P,refresh:J,destroy(){I=!0;for(const te of D)try{te()}catch{}D.length=0,y.remove()}}}function o(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 h(){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 F=K("packages/core/src/internal/util.js").isObject,$=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:z}){this.#e=H,this.#t=U,this.#n=Array.isArray(z)?z.filter(F):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${_.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const z of this.#n){const w=$({...z,grid:this.#e,container:U});this.#o.push(w)}}destroy(){for(const H of this.#o)try{H.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 At}});const F=K("packages/core/src/index.js").createHeadlessGrid,$=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),H=W.fail,U=W.isFunction,z=W.warnOnce,v=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,o=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,h=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,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,P=K("packages/dom/src/alignedgrids.js").AlignedGrids,I=K("packages/dom/src/columntagbar.js").ColumnTagBar,O=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,le=K("packages/dom/src/editbar.js").EditBar,se=K("packages/dom/src/rangeselect.js").RangeController,ie=K("packages/core/src/model/selection.js").resolveSelectionConfig,he=K("packages/dom/src/importer.js").ImportController,Ee=K("packages/dom/src/historybar.js").HistoryBar,Ae=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,Ve=K("packages/dom/src/findpaint.js").FindPainter,je=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,ke=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,Se=K("packages/dom/src/maximise.js").Maximiser,Pe=K("packages/dom/src/promptbar.js").PromptBar,ze=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(He,pt,ct){const ot=pt==="redo"?"toolbar.redo":"toolbar.undo";return!ct||!ct.label?He(ot):He(pt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:ct.label})}const De=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Oe=2e3;function xe(He,pt,ct,ot){const St=pt.annotate===!0?Be(He,ot):[];if(pt.actions===!1)return[];if(pt.actions===void 0&&pt.side!=="left")return St;const jt=Array.isArray(pt.actions)?pt.actions:De,ht=(Dt,_t)=>He.messages.t(Dt,_t),Nt={undo:{name:"undo",title:()=>_e(ht,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>_e(ht,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>ht("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:pt.exportName})},excel:{name:"excel",title:()=>ht("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:pt.exportName})},clipboard:{name:"clipboard",title:()=>ht("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>ht("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return ht("toolbar.pause");const Dt=He.updates.stats().pending;return Dt?ht("toolbar.applyHeld",{count:Dt}):ht("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>ht("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>ht(ct&&ct.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>ct&&ct.active()?"minimise":"maximise",run:()=>ct.toggle()}};return ct||delete Nt.maximise,jt.map(Dt=>Dt==="-"?{name:"-",separator:!0}:typeof Dt=="string"?Nt[Dt]:!Dt||typeof Dt!="object"||!Dt.name?null:{...Dt,run:U(Dt.run)?()=>Dt.run({grid:He,keys:He.selection&&U(He.selection.keys)?He.selection.keys():[],cells:He.selection&&U(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Be(He,pt){const ct={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ot=(jt,ht)=>He.messages.t(jt,ht),St=["pen","arrow","rect","highlight","erase"].map(jt=>({name:jt,title:()=>ot(`toolbar.annotate.${jt}`),icon:ct[jt],run:()=>He.annotate?.use(jt),active:()=>He.annotate?.tool===jt,annotation:!0}));return St.push(Je(He,ot,pt)),St}function Je(He,pt,ct){return{name:"clearAll",title:()=>pt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>Qe(He,pt,ct)}}function Qe(He,pt,ct){const ot=He.toolPanel;if(!ot)return;const St=ht=>ct?.announce?.(pt(ht),{repeat:!0});ot.removeAction("clearAll");const jt=()=>{ot.removeAction("clearAllConfirm"),ot.removeAction("clearAllKeep"),ot.addAction(Je(He,pt,ct))};ot.addAction({name:"clearAllConfirm",title:()=>pt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),jt(),St("a11y.annotate.cleared")}}),ot.addAction({name:"clearAllKeep",title:()=>pt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>jt()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function it(He){let pt=null,ct=null;return He.on("source:error",ot=>{const St=ot&&ot.error;ct=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(He.messages?He.messages.t("overlay.error"):"Something went wrong")}),He.on("rows:changed",()=>{ct=null}),{loadError:()=>ct,rowCount:()=>{if(U(He.rows.matchCount))return He.rows.matchCount();const ot=He.pagination&&U(He.pagination.get)?He.pagination.get():null;return ot&&Number.isFinite(ot.total)?ot.total:He.rows.count()},totalRowCount:()=>U(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{pt||(pt=U(He.rendererHost)?He.rendererHost():{});const ot=U(pt.selectionSummary)?pt.selectionSummary():null;return ot&&ot.predicate?{count:ot.count}:null},selectedCount:()=>{const ot=He.selection&&He.selection.keys?He.selection.keys():null;return ot?ot.length:0},rangeValues:()=>{const ot=He.selection;return!ot||!U(ot.cells)?[]:ot.cells().map(({key:St,colId:jt})=>He.rows.value(St,jt))},hiddenUnresolved:()=>U(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>U(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function gt(He,pt){for(const[ct,ot]of Object.entries(f||{}))He.register("editor",ct,ot);for(const[ct,ot]of Object.entries(o||{}))He.register("filter",ct,ot);for(const[ct,ot]of Object.entries(pt.components||{}))He.register("component",ct,ot);for(const[ct,ot]of Object.entries(pt.pipes||{}))He.register("pipe",ct,ot);for(const[ct,ot]of Object.entries(pt.totalFns||{}))He.register("totalFn",ct,ot)}function wt(He,pt,ct,ot,St,jt){const ht=[],Nt=pt.viewport;let Dt=null;if(ct.maximise!==!1&&(Dt=new Se({element:jt,document:ot,onChange:()=>pt.invalidate("all"),captureScroll:()=>pt.scrollState(),restoreScroll:lt=>pt.restoreScroll(lt)}),He.maximise=Dt,ht.push(()=>Dt.destroy())),ct.statusBar){const lt=typeof ct.statusBar=="object"?ct.statusBar:{},vt=new c;vt.init({document:ot,host:it(He),panels:lt.panels,registry:lt.registry,locale:He.get("locale"),messages:He.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`)},Vt=()=>{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=>He.on(on,Vt));Vt(),Rt(),ht.push(()=>{for(const on of Gt)on();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const _t=ie(ct.selection);if(_t.ranges){const lt=new se({grid:He,renderer:pt,document:ot});lt.mount(),He.ranges=lt,ht.push(()=>lt.destroy())}if(ct.import){const lt=new he({grid:He,renderer:pt,document:ot,settings:typeof ct.import=="object"?ct.import:{}});He.importer=lt,ht.push(()=>lt.destroy())}if(ct.historyBar){const lt=typeof ct.historyBar=="object"?ct.historyBar.element:null,vt=new Ee;vt.init({document:ot,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Vt=>He.history.peek(Vt),list:()=>He.history.list()},props:typeof ct.historyBar=="object"?ct.historyBar:{}}),(lt||Nt.root).appendChild(vt.element());const Rt=[He.on("history:changed",()=>vt.refresh())];He.historyBar=vt,ht.push(()=>{for(const Vt of Rt)Vt();vt.destroy()})}if(ct.diff){const lt=new Ae({grid:He,renderer:pt});lt.mount(),He.diffPainter=lt,ht.push(()=>lt.destroy())}if(ct.ai&&U(ct.ai.ask)){const lt=new Pe;lt.init({document:ot,grid:He,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()),He.promptBar=lt,ht.push(()=>lt.destroy())}if(ct.groupPanel){const lt=typeof ct.groupPanel=="object"?ct.groupPanel:{},vt=new p;vt.init({document:ot,grid:He,host:J(He,ot,(Rt,Vt)=>pt.announce?.(Rt,Vt)),props:{header:Nt.header,hint:lt.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),He.groupPanel=vt;for(const Rt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(He.on)&&ht.push(He.on(Rt,()=>vt.refresh()));ht.push(()=>vt.destroy())}if(ct.kpis){const lt=new ze({grid:He,document:ot,kpis:ct.kpis});lt.active&&(lt.mount(),Nt.root.insertBefore(lt.element(),Nt.header),He.kpiStrip=lt,ht.push(()=>lt.destroy()))}if(ct.toolPanel){const lt=typeof ct.toolPanel=="object"?ct.toolPanel:{},vt=new Z({grid:He,document:ot,root:Nt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:xe(He,lt,Dt,pt),announce:(Rt,Vt)=>pt.announce?.(Rt,Vt)});vt.mount(),He.toolPanel=vt,ht.push(()=>vt.destroy()),lt.annotate===void 0&&(ht.push(He.on("presentation:started",()=>{for(const Rt of Be(He,pt))vt.addAction(Rt)})),ht.push(He.on("presentation:ended",()=>{for(const Rt of at)vt.removeAction(Rt)})))}if(!!ct.pagination&&(()=>{const lt=typeof ct.pagination=="object"?ct.pagination:{};return He.pagination.set({pageSize:Number(lt.pageSize)||100}),He.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:He.get("locale"),messages:He.messages,onChange:({page:Gt,pageSize:on})=>He.pagination.set({page:Gt,pageSize:on})});const Rt=()=>{const Gt=He.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()};He.pagination.set({pageSize:vt.pageSize}),Rt();const Vt=["rows:changed","filter:changed","model:changed"].map(Gt=>He.on(Gt,Rt));Nt.statusBar.appendChild(vt.element()),ht.push(()=>{for(const Gt of Vt)Gt();vt.destroy?.()})}if(ct.edit!==!1)if(ct.editBar){const lt=new le({grid:He,document:ot,root:Nt.root});lt.mount(),He.editBar=lt,ht.push(()=>lt.destroy())}else{const lt=new ne({grid:He,document:ot,renderer:pt,registry:St,cellLayer:pt.cellLayer});lt.mount(),ht.push(()=>lt.destroy())}const cn=new y({grid:He,document:ot,layer:Nt.overlays,registry:St});cn.mount(),ht.push(()=>cn.destroy());const qt=new R({grid:He,document:ot,host:Nt.root,cellMenu:ct.contextMenu!==!1,headerMenu:ct.columnMenu!==!1,items:U(ct.contextMenu)?ct.contextMenu:void 0,headerItems:U(ct.columnMenu)?ct.columnMenu:void 0});if(qt.mount(),ht.push(()=>qt.destroy()),Array.isArray(ct.alignedGrids)&&ct.alignedGrids.length){const lt=new P;lt.add(He);for(const vt of ct.alignedGrids)vt&&vt!==He&<.add(vt);ht.push(()=>lt.destroy())}const Wt=new G({grid:He,renderer:pt,document:ot,registry:St});Wt.active&&(Wt.mount(),ht.push(()=>Wt.destroy())),Object.defineProperty(He,"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}})}),ht.push(()=>{delete He.form}),Object.defineProperty(He,"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 r()}})}),ht.push(()=>{delete He.icons});const Mt=new I({grid:He,renderer:pt,document:ot});Mt.active&&(Mt.mount(),ht.push(()=>Mt.destroy()));const xt=new O({grid:He,renderer:pt,document:ot});xt.active&&(xt.mount(),ht.push(()=>xt.destroy()));const Bt=new T({grid:He,renderer:pt,document:ot});if(Bt.active){Bt.mount(),Bt.paint();const lt=He.on("render:done",()=>Bt.paint());ht.push(()=>{lt(),Bt.destroy()})}if(ct.shortcuts!==!1){const lt=new x({grid:He,renderer:pt});lt.mount(),ht.push(()=>lt.destroy())}const Kt=new Ne({grid:He,renderer:pt,window:ot.defaultView||void 0});Kt.mount(),ht.push(()=>Kt.destroy());const Qt=new Ve({grid:He,renderer:pt,window:ot.defaultView||void 0});if(Qt.mount(),ht.push(()=>Qt.destroy()),ct.find!==!1){const lt=new je({grid:He,renderer:pt,document:ot,settings:ct.find});lt.mount(),ht.push(()=>lt.destroy())}const Yt=new Ze({grid:He,renderer:pt});Yt.mount(),ht.push(()=>Yt.destroy());const Jt=new st({grid:He,renderer:pt});Jt.mount(),ht.push(()=>Jt.destroy());const nn=new yt({grid:He,renderer:pt,maximiser:Dt});nn.mount(),ht.push(()=>nn.destroy());const en=new It({grid:He,renderer:pt});en.mount(),ht.push(()=>en.destroy()),ct.environment||He.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"]])ht.push(He.on(lt,()=>{un=vt}));ht.push(He.on("render:done",lt=>{He.diagnostics.render(un||lt.cause,lt.phases),un=null}));const an=ot.defaultView;if(an&&U(an.requestAnimationFrame)){let lt=an.requestAnimationFrame(function vt(Rt){He.diagnostics.frame(Rt),lt=an.requestAnimationFrame(vt)});ht.push(()=>{U(an.cancelAnimationFrame)&&an.cancelAnimationFrame(lt)})}const gn=new ke({grid:He,renderer:pt});if(gn.mount(),ht.push(()=>gn.destroy()),ht.push(He.on("presence:lockRefused",lt=>gn.announceRefusal(lt.peer))),He.presence&&He.presence.enabled){for(const Rt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ht.push(He.on(Rt,()=>He.presence.publish()));let lt="";ht.push(He.on("render:done",()=>{const Rt=pt.focusState&&pt.focusState(),Vt=Rt?`${Rt.rowKey}${Rt.colId}`:"";Vt!==lt&&(lt=Vt,He.presence.publish())}));const vt=jt.ownerDocument;if(vt&&U(vt.addEventListener)){const Rt=()=>He.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Rt),Rt(),ht.push(()=>vt.removeEventListener("visibilitychange",Rt))}}const yn=new nt({grid:He,renderer:pt});yn.mount(),ht.push(()=>yn.destroy());const bn=new We({grid:He,renderer:pt});bn.mount(),ht.push(()=>bn.destroy()),ht.push(He.on("facet:computed",()=>pt.refreshHeader?.())),_t&&_t.headerCheckbox===!0&&ht.push(He.on("selection:changed",()=>pt.refreshHeader?.())),ht.push(He.on("facet:expanded",()=>pt.invalidate("columns"))),ht.push(He.on("model:changed",()=>pt.invalidate("rows")));const Zt=(lt,vt)=>pt.announce?.(lt,vt),dn=He.messages,Ht=(lt,vt)=>dn.t(lt,vt),mn=lt=>Ht("count.rows",{count:lt});ht.push(He.on("sort:changed",()=>{const lt=He.sort.get();if(!lt.length){Zt(Ht("a11y.sort.cleared"));return}const vt=lt.map(Rt=>{const Vt=He.columns.get(Rt.col);return Ht("a11y.sort.column",{column:Vt&&Vt.title||Rt.col,direction:Ht(Rt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Ht("a11y.sort.by",{columns:dn.list(vt)}))})),ht.push(He.on("filter:changed",()=>{const lt=He.rows.matchCount?He.rows.matchCount():He.rows.count();if(lt===null)return;const vt=He.rows.totalCount?He.rows.totalCount():lt;Zt(lt===vt?Ht("a11y.filter.cleared",{rows:mn(vt)}):Ht("a11y.filter.applied",{shown:mn(lt),total:mn(vt)}))})),ht.push(He.on("selection:changed",()=>{const lt=He.selection.keys().length;Zt(lt===0?Ht("a11y.selection.cleared"):Ht("a11y.selection.count",{count:lt}))})),ht.push(He.on("group:toggled",lt=>{const vt=He.rows.byKey?He.rows.byKey(lt.key):null,Rt=(vt&&(vt.groupLabel??vt.groupValue))??lt.key;Zt(Ht(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Rt,rows:mn(He.rows.count())}))})),ht.push(He.on("column:grouped",lt=>{const vt=Array.isArray(lt.columns)?lt.columns:[];if(!vt.length){Zt(Ht("a11y.group.cleared"));return}const Rt=vt.map(Vt=>{const Gt=He.columns.get(Vt);return Gt&&Gt.title||Vt});Zt(Ht("a11y.group.by",{columns:dn.list(Rt)}))})),ht.push(He.on("page:changed",lt=>{const vt=Number(lt.size)||0,Rt=Number(lt.total)||0,Vt=vt>0?Math.max(1,Math.ceil(Rt/vt)):1;Zt(Ht("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Vt}))}));let rn={added:0,removed:0},Xt=null;const xn=()=>{Xt=null;const lt=[];rn.added&<.push(Ht("count.rowsAdded",{count:rn.added})),rn.removed&<.push(Ht("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},lt.length&&Zt(dn.list(lt))};ht.push(He.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(xn,Oe)))})),ht.push(()=>{Xt&&clearTimeout(Xt)}),ht.push(He.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),rn={added:0,removed:0},Zt(Ht("a11y.updates.paused"),{repeat:!0})})),ht.push(He.on("rows:resumed",()=>Zt(Ht("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Cn=()=>{hn=null;const{count:lt,first:vt}=fn;if(fn={count:0,first:null},!lt||!vt)return;const Rt=He.columns.get(vt.colId),Vt=Rt&&Rt.title||vt.colId,Gt=vt.reason?Ht("a11y.edit.reason",{reason:vt.reason}):"";if(lt===1){const on=vt.restored===void 0||vt.restored===null||vt.restored===""?Ht("value.empty"):String(vt.restored);Zt(Ht("a11y.edit.refusedOne",{column:Vt,value:on,reason:Gt}),{repeat:!0});return}Zt(Ht("a11y.edit.refusedMany",{count:lt,reason:Gt}),{repeat:!0})};ht.push(He.on("cell:reverted",lt=>{!lt||!lt.applied||(fn.count+=1,fn.first||(fn.first=lt),hn||(hn=setTimeout(Cn,150)))})),ht.push(()=>{hn&&clearTimeout(hn)}),ht.push(He.on("history:applied",lt=>{const vt=!!(lt&<.direction==="redo"),Rt=lt&<.step&<.step.label;Zt(Rt?Ht(vt?"a11y.history.redo":"a11y.history.undo",{label:Rt}):Ht(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Et({grid:He,renderer:pt,seed:ct.state&&Array.isArray(ct.state.annotations)?ct.state.annotations:null});wn.mount(),ht.push(()=>wn.destroy()),He.annotate=wn,He.capture=async(lt={})=>{const{blob:vt,width:Rt,height:Vt}=await Ct(pt.viewport.root,lt);return(lt.download===!0||lt.download!==!1&<.fileName)&&X(vt,lt.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Rt,height:Vt,bytes:vt.size,mimeType:vt.type,fileName:lt.fileName||null},"api"),vt};const En=new qe({grid:He,document:ot,element:Nt.overlays,window:ot.defaultView||void 0});En.mount(),ht.push(()=>En.destroy());const $n=new h({grid:He,document:ot,element:Nt.overlays});$n.mount?.(),ht.push(()=>$n.destroy?.());const Tn=new A({grid:He,host:He.rendererHost(),viewport:Nt,document:ot});return Tn.mount(),ht.push(()=>Tn.destroy()),ht}function dt(He){const pt=[],ct=ot=>{if(ot&&(ot.__lattice&&pt.push(ot),ot.children))for(const St of ot.children)ct(St)};return ct(He),pt}function At(He,pt={}){(!He||typeof He!="object"||!("appendChild"in He))&&H("createGrid needs a host element as its first argument."),pt=$(pt);const ct=He.ownerDocument||(typeof document<"u"?document:null);ct||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ot=ct.documentElement&&ct.documentElement.lang,St=!pt.licence&&U(ct.querySelector)?ct.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,jt={...pt};if(!pt.locale&&ot&&(jt.locale=ot),St&&(jt.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;jt.views={...pt.views,storage:v(qt)}}const ht=F(jt),Nt=ht.rendererHost();Nt.document=ct,gt(Nt.registry,pt),Nt.cellLayer=a(Nt),Nt.detailHost=new we({grid:ht,document:He.ownerDocument||globalThis.document,createGrid:(qt,Wt)=>At(qt,Wt)});const Dt=new l(He,Nt),_t=ht.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),pn=ht.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});ht.on("destroy",()=>{_t(),pn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),ht.attachRenderer(Dt),Dt.mount();const sn=wt(ht,Dt,pt,ct,Nt.registry,He),cn=ht.destroy.bind(ht);return ht.destroy=()=>{for(const qt of sn)try{qt()}catch{}He.__lattice===ht&&(He.__lattice=null),cn()},He.__lattice=ht,ht}}),Le("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),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 h}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,$=K("packages/core/src/columns/datatypes.js"),_=$.BUILTIN_TYPES,X=$.parseNumberText,H=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"),v=w.toIsoDate,g=w.toIsoDateTime,d=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(H)]);function n(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 r(s,p){const b=F(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function i(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 f(s,p){return p==="text"?s===""?null:s:p==="boolean"?z(s):p==="number"?X(s):p==="date"||p==="dateString"?v(s):p==="datetime"?g(s):i(s)}function u(s){const p=n(s,"thead"),b=n(p||s,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((j,x)=>{const E=r(j,x),T={id:E,field:E,title:String(j.textContent||"").trim()||E},L=F(j.getAttribute)?j.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 P=F(j.getAttribute)?j.getAttribute("data-format"):null;return P&&(T.format=P),T}),y=n(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(j=>j!==b)).map((j,x)=>{const E=t(j,"td"),L={__row:(F(j.getAttribute)?j.getAttribute("data-id"):null)||`row${x}`};return k.forEach((P,D)=>{L[P.field]=E[D]?P.type?f(String(E[D].textContent||""),P.type):i(String(E[D].textContent||"")):null}),L});return{columns:k,rows:R}}function o(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}=u(p);return d(s,{rowKey:"__row",...b,columns:o(A,b.columns),rows:b.rows!==void 0?b.rows:k})}function h(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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,v){const g=[];return F(w.hasAttribute)&&w.hasAttribute(v)&&g.push(w),F(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${v}]`)),g}function H(w){const v=w.parentNode;if(!v||!v.children)return null;const g=[...v.children],l=g.indexOf(w),d=[g[l+1],g[l-1]];for(const a of d)if(a&&a.tagName==="SCRIPT"&&F(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function U(w){const v=H(w);if(!v)return{};try{return JSON.parse(v.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const v=w||(typeof document<"u"?document:null);if(!v)return[];const g=[];for(const l of W(v,"data-lattice-grid")){if(l.__lattice)continue;const d=U(l);g.push(l.tagName==="TABLE"?X(l,d):$(l,d))}return g}}),Le("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Q=K("packages/dom/src/createGrid.js"),F=Q.createGrid,B=K("packages/dom/src/hydrate.js"),$=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),H=W.createLocalViewStorage,U=K("packages/core/src/index.js"),z=U.createHeadlessGrid,w=U.registerModules,v=U.setLicence,g=U.version,l=U.getVersion,d=U.serialiseState,a=U.restoreState,n=U.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 U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),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}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const i=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return i.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return i.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return i.branchFor}});const f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const o=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return o.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return o.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return o.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 h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.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 j=Object.freeze({createGrid:F,createHeadlessGrid:z,defaults:n,registerModules:w,setLicence:v,version:g,autoInit:X,hydrateTable:$,serialiseState:d,restoreState:a,createLocalViewStorage:H}),x=j}),Le("packages/modules/shared/adapter.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return z}});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","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","validation:failed","validation:cleared","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"]),F=Object.freeze({sort:(w,v)=>w.sort.set(v||[]),filters:(w,v)=>w.filters.set(v||null),quickFilter:(w,v)=>{if(v&&typeof v=="object"){w.filters.quick(v.text||"",{mode:v.mode});return}w.filters.quick(typeof v=="string"?v:"")},selectedKeys:(w,v)=>w.selection.set(Array.isArray(v)?v:[])});function B(w){return`on${String(w).split(":").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join("")}`}function $(w){return String(w).replace(/:/g,"-")}const _=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function X(w){return Object.hasOwn(_,w)?_[w]:w}const W=Object.freeze(Object.fromEntries(Q.map(w=>[B(w),w])));function H(w){return Object.hasOwn(W,w)}function U(w){const v={},g={},l={};for(const[d,a]of Object.entries(w||{})){if(H(d)){l[d]=a;continue}if(Object.hasOwn(F,d)){g[d]=a;continue}v[d]=a}return{config:v,imperative:g,handlers:l}}function z(w){const v=w.createGrid;if(typeof v!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const g=U(w.props||{}),l=v(w.element,{...g.config});let d=g.handlers,a=g.config,n={};const t=f=>{if(!f||typeof f.type!="string")return;const u=d[B(f.type)];typeof u=="function"&&u(f)},r=l.on("*",t);for(const[f,u]of Object.entries(g.imperative))u!==void 0&&(F[f](l,u),n[f]=u);let i=!1;return{grid:l,update(f){if(i)return;const u=U(f||{});d=u.handlers;const o={};for(const[m,c]of Object.entries(u.config))Object.is(a[m],c)||(o[m]=c);for(const m of Object.keys(a))Object.hasOwn(u.config,m)||(o[m]=void 0);Object.keys(o).length&&l.setAll(o),a=u.config;for(const[m,c]of Object.entries(F)){const h=u.imperative[m];Object.is(n[m],h)||h===void 0&&!Object.hasOwn(n,m)||(c(l,h),n[m]=h)}},destroy(){i||(i=!0,r(),l.destroy())}}}}),Le("packages/modules/react/viewers.js",function(e,K){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/internal/util.js").warnOnce,B=Object.freeze({kpi:Object.freeze(["tile:click","tile:dblclick","tile:contextmenu","node:toggle","change","tile:status"]),kanban:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:move","card:reverted","card:confirmed","selection:changed","column:collapse","card:add","drag:start","drag:end","swimlane:collapse","swimlane:reorder","column:reorder","filter:changed","sprint:changed","epic:changed","card:expand","card:drill","card:edit","card:sla","beforeMove","beforeAdd","beforeEdit","beforeLaneReorder","beforeColumnReorder","beforeColumnChange","move:cancelled","add:cancelled","edit:cancelled","laneReorder:cancelled","columnReorder:cancelled","columnChange:cancelled"]),tabs:Object.freeze(["beforeTabChange","tab:changed","tabChange:cancelled"]),calendar:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:mount","range:change","beforeMove","card:move"]),chart:Object.freeze(["click","hover","leave","draw","legend"]),gantt:Object.freeze(["schedule","error","history"]),layout:Object.freeze(["layout:changed","window:moved","window:resized","window:closed","beforeWindowClose","windowClose:cancelled"]),router:Object.freeze(["metrics","fields:changed"])}),$=Object.freeze({kpi:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[])}),kanban:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),quickFilter:(z,w)=>z.setQuickFilter(typeof w=="string"?w:""),sprint:(z,w)=>z.setSprint(w),epic:(z,w)=>z.setEpic(w),loading:(z,w)=>z.setLoading(!!w),error:(z,w)=>z.setError(w??null)}),gantt:Object.freeze({tasks:(z,w)=>z.setTasks(Array.isArray(w)?w:[]),dependencies:(z,w)=>z.setDependencies(Array.isArray(w)?w:[])}),tabs:Object.freeze({active:(z,w)=>{typeof w=="string"&&z.activate(w)}}),calendar:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),view:(z,w)=>z.setView(w),date:(z,w)=>z.goTo(w),move:(z,w,v)=>z.move(w,v)}),chart:Object.freeze({}),layout:Object.freeze({})}),_=Object.freeze({chart:"update"});function X(z){return`on${String(z).split(":").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join("")}`}const W=Object.freeze(Object.fromEntries(Object.entries(B).map(([z,w])=>[z,Object.freeze(Object.fromEntries(w.map(v=>[X(v),v])))])));function H(z,w){const v=W[z]||{},g=$[z]||{},l={},d={},a={};for(const[n,t]of Object.entries(w||{})){if(Object.hasOwn(v,n)){a[n]=t;continue}if(Object.hasOwn(g,n)){d[n]=t,l[n]=t;continue}l[n]=t}return{config:l,live:d,handlers:a}}function U(z){const w=String(z.viewer),v=z.mount,g=z.name||w;if(typeof v!="function")throw new TypeError(`createViewerController needs a mount factory for "${w}"; pass the module's own factory in, e.g. { createKPI } from lattice-grid/modules/kpi.`);const l=H(w,z.props||{}),d=v(z.element,{...l.config});if(!d||typeof d!="object")throw new TypeError(`the ${g} factory returned no instance; nothing can be driven.`);let a=l.handlers,n=l.config;const t={...l.live},r=[];if(typeof d.on=="function")for(const o of B[w]||[]){const m=X(o),c=d.on(o,h=>{const s=a[m];typeof s=="function"&&s(h)});typeof c=="function"&&r.push(c)}const i=_[w],f=$[w]||{};let u=!1;return{instance:d,update(o){if(u)return;const m=H(w,o||{});a=m.handlers;const c={};for(const[s,p]of Object.entries(m.config))Object.is(n[s],p)||(c[s]=p);if(n=m.config,!Object.keys(c).length)return;const h=[];for(const s of Object.keys(c)){const p=f[s];if(p){p(d,c[s]),t[s]=c[s];continue}i&&typeof d[i]=="function"||h.push(s)}if(i&&typeof d[i]=="function"){const s={};for(const p of Object.keys(c))f[p]||(s[p]=c[p]);Object.keys(s).length&&d[i](s)}h.length&&F(`react.viewer.${w}.mountOnly.${h.join(".")}`,`${g}: ${h.map(s=>`\`${s}\``).join(", ")} changed, but ${g} takes ${h.length===1?"it":"them"} only when the viewer is created. Nothing was applied and the viewer was NOT rebuilt — rebuilding it silently would throw away scroll position, selection and expansion. Give the component a \`key\` that changes when this must take effect, so the rebuild is yours and visible, or drive the instance through the ref.`)},destroy(){if(!u){u=!0;for(const o of r)try{o()}catch{}r.length=0,typeof d.destroy=="function"&&d.destroy()}}}}}),Le("packages/modules/webcomponent/controller.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return a}});const F=K("packages/core/src/internal/util.js").warnOnce,B="lattice-",$="lattice-grid-element-styles",_=Object.freeze({theme:"theme",density:"density",locale:"locale","row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight","filter-row":"filterRow",selection:"selection",rows:"rows",columns:"columns"}),X=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),H=new Set(["rows","columns"]);function U(){return Object.keys(_)}function z(n){return B+String(n).replace(/:/g,"-")}function w(n,t){if(W.has(n))return t!==null&&t!=="false";if(t!==null){if(X.has(n)){const r=Number(t);return Number.isFinite(r)?r:void 0}if(H.has(n))try{return JSON.parse(t)}catch{return}return t}}function v(n){if(!n||!n.createElement||n.getElementById&&n.getElementById($))return;const t=n.createElement("style");t.setAttribute("id",$),t.appendChild(n.createTextNode(`lattice-grid{display:block}
|
|
57
|
+
`)||(o.preventDefault(),this.fromText(m))})))}openFile(){const u=v(this.#n,"input",{attrs:{type:"file",accept:r}});u.style.display="none",this.#o.push(l(u,"change",()=>{const o=u.files&&u.files[0];o&&this.#c(o),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(F(u.arrayBuffer)){u.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(z(c)){this.fromXlsx(c,u.name);return}this.fromText(new TextDecoder().decode(c),u.name)});return}if(F(u.text)){u.text().then(m=>this.fromText(m,u.name));return}const o=new this.#n.defaultView.FileReader;o.onload=()=>this.fromText(String(o.result||""),u.name),o.readAsText(u)}async fromXlsx(u,o){const{header:m,rows:c}=await U(u);if(!m.length)return;const h=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:h,delimiter:null,name:o,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(u,o){const{header:m,rows:c,delimiter:h}=X(u);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:h,name:o,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 u=this.#i.querySelector(t);u&&F(u.focus)&&u.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(u,o){const m=this.#t&&this.#t.announce;F(m)&&m.call(this.#t,u,o)}#h(u,o){return(this.#e&&this.#e.messages?this.#e.messages:$).t(u,o)}#p(){const u=this.#n,o=v(u,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),m=v(u,"div",{class:`${n}__panel`});m.appendChild(v(u,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=v(u,"div",{class:`${n}__body`}),m.appendChild(this.#s);const c=v(u,"div",{class:`${n}__footer`}),h=v(u,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),s=v(u,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(l(h,"click",()=>this.close())),this.#o.push(l(s,"click",()=>this.#g())),c.appendChild(h),c.appendChild(s),m.appendChild(c),o.appendChild(m),this.#o.push(l(o,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const A=[...o.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(o),this.#i=o}#m(){const u=this.#n,o=g(this.#s),{rows:m,columns:c,name:h,warnings:s}=this.#l;o.appendChild(v(u,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:m.length,name:h||this.#h("import.clipboard")})}));for(const S of s)o.appendChild(v(u,"p",{class:`${n}__warning`,text:S}));const p=this.#e.columns.all().map(S=>S.field||S.id).filter(Boolean),b=v(u,"table",{class:`${n}__map`}),A=v(u,"tr",{});for(const S of["import.colSource","import.colField","import.colType"])A.appendChild(v(u,"th",{text:this.#h(S)}));b.appendChild(A),c.forEach((S,R)=>{const j=v(u,"tr",{});j.appendChild(v(u,"td",{text:S.source}));const x=v(u,"select",{attrs:{"data-col":String(R),"aria-label":this.#h("import.mapLabel",{source:S.source})}});x.appendChild(v(u,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const T of p)x.appendChild(v(u,"option",{text:T,attrs:{value:T,selected:T===S.field?!0:null}}));S.field&&!p.includes(S.field)&&x.appendChild(v(u,"option",{text:S.field,attrs:{value:S.field,selected:!0}}));const E=v(u,"td",{});E.appendChild(x),j.appendChild(E),j.appendChild(v(u,"td",{class:`${n}__type`,text:S.type})),b.appendChild(j)}),o.appendChild(b);const k=v(u,"div",{class:`${n}__mode`}),y=v(u,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});y.appendChild(v(u,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(v(u,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),k.appendChild(v(u,"label",{text:this.#h("import.modeLabel")})),k.appendChild(y),o.appendChild(k)}#g(){const{rows:u,columns:o}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));o[b]&&p.value!==void 0&&p.value!==null&&(o[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,h=c==="replace"||c==="append"?c:this.#r.mode,s=H(u,o);this.#e.import.apply(s,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&F(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();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 v}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H=_.clear,U=_.documentFor,z="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(l,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:$).t(l,d)}init(l){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||$;const d=l||{};if(this.doc=U(d),this.host=d.host||{},this.props=d.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(l,d,a){const n=X(this.doc,"button",{class:`${z}__${l}`,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:d})]});return this.off.push(W(n,"click",()=>{const t=this.host[l];F(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const l=this.host,d=F(l.canUndo)?l.canUndo():!1,a=F(l.canRedo)?l.canRedo():!1,n=F(l.peek)?l.peek("undo"):null,t=F(l.peek)?l.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(l,d,a,n){if(!l)return;l.disabled=!a;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),i=l.querySelector(`.${z}__label`);i&&(i.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;l.setAttribute("title",a?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),l.setAttribute("aria-label",a?f: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 l=this.menu;if(!l)return;H(l);const d=F(this.host.list)?this.host.list():[];if(!d.length){l.appendChild(X(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((a,n)=>{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 r=n+1;for(let i=0;i<r;i++)F(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),l.appendChild(t)})}destroy(){for(const l of this.off)l();this.off=[],this.root&&F(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const v=w}),Le("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),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"),F=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",H="lat-cell--added-column";class U{#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 l=this.#e.diff,d=l&&l.enabled;for(const a of g.querySelectorAll("[data-key]")){const n=a.getAttribute("data-key"),t=d?l.statusOf(n):"unchanged";for(const i of Object.values(X))a.classList.remove(i);d&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const i of a.querySelectorAll("[data-col]")){const f=i.getAttribute("data-col");if(i.classList.remove(W,H),i.removeAttribute("data-before"),!r)continue;const u=l.cellStatus(n,f);if(u==="changed"){i.classList.add(W);const o=this.#r(l,n,f);o===null?i.removeAttribute("title"):(i.setAttribute("data-before",o),i.setAttribute("title",this.#o("diff.before",{value:o})))}else u==="added-column"&&i.classList.add(H)}}}#r(g,l,d){const a=this.#e,n=a&&a.columns,t=n&&F(n.get)?n.get(d):null,r=a&&a.permissions;if(t&&r&&F(r.isSecret)&&r.isSecret(t))return null;const i=g.before(l,d);if(i==null)return this.#o("diff.empty");if(!t||!F(t.formatValue))return String(i);const f=F(g.beforeRow)?g.beforeRow(l):void 0,o={...(a.rows&&F(a.rows.byKey)?a.rows.byKey(l):null)||{},data:f===void 0?{}:f};try{const m=t.formatValue(i,o,o.data);return m==null?"":String(m)}catch(m){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(i)}}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:_).t(g,l)}destroy(){for(const l of this.#n)l();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const l of g.querySelectorAll("[data-key]")){for(const d of Object.values(X))l.classList.remove(d);l.removeAttribute("data-diff")}for(const l of g.querySelectorAll("[data-col]"))l.classList.remove(W,H),l.removeAttribute("data-before")}}}function z(v){return!!(v&&v.diff&&(F(v.diff)||typeof v.diff=="object"))}const w=U}),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 F=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",$="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.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 H=()=>{this.#o=!1,this.paint()};F(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):F(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const z of H.querySelectorAll("[data-key]")){const w=z.getAttribute("data-key");for(const v of z.querySelectorAll("[data-col]")){const g=U.active?U.colourFor(w,v.getAttribute("data-col")):null;g?(v.classList.add(B),v.style.setProperty($,g)):v.classList.contains(B)&&(v.classList.remove(B),v.style.removeProperty($))}}this.#s(U)}}#s(H){this.#r!==null&&F(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!F(this.#i.setTimeout))return;const z=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&F(H.model)?H.model():null}destroy(){this.#r!==null&&F(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty($)}}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 $}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const F=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",$="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.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 H=()=>{this.#r=!1,this.paint()};F(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):F(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!F(U.stateFor))return;const z=F(U.model)?U.model():null,w=!!z&&z.active;if(!w&&!this.#o)return;let v=!1;for(const g of H.querySelectorAll("[data-key]")){const l=g.getAttribute("data-key");for(const d of g.querySelectorAll("[data-col]")){const a=w?U.stateFor(l,d.getAttribute("data-col")):null;a?(v=!0,d.classList.add(B),d.classList.toggle($,a==="current")):d.classList.contains(B)&&d.classList.remove(B,$)}}this.#o=v}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,$);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 l}});const Q=K("packages/dom/src/editors/common.js"),F=Q.el,B=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z="lat-find",w=12,v=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!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,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:W).t(a,n)}mount(){const a=this.#j();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 n=this.#t.viewport?.root;if(n&&U(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const i=r.target;if(this.#s&&i===this.#s){r.preventDefault(),r.stopPropagation(),U(this.#s.select)&&this.#s.select();return}_(i)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.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 n=this.#k();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#y(),this.#j().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#E()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#V();const a=this.#j();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),a&&(a.clear(),a.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const i=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(i.focus)&&i.focus()}search(){this.#E()}destroy(){this.#O=!0,this.#V();for(const n of this.#g)n();this.#g=[];const a=this.#j();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&&U(a.invalidate)&&a.invalidate("size")}#j(){const a=this.#e&&this.#e.find;return a&&U(a.model)?a.model():null}#k(){if(this.#i)return this.#i;const a=this.#t.viewport,n=a?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=F(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=F(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=F(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=F(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=F(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const i=F(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=F(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=F(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=F(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=F(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=F(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),o=F(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const c of[this.#s,this.#l,this.#a,this.#u,i,f,u,o])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(i,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),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.#f,"change",()=>{const c=this.#f.value;this.#m=c?String(c):null,this.#E()})),this.#g.push(B(u,"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 r.addEventListener("keydown",m),this.#g.push(()=>r.removeEventListener("keydown",m)),r.style.display="none",n.insertBefore(r,a.header||n.firstChild),this.#i=r,this.#C(),r}#C(){const a=this.#f;if(!a)return;const n=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(F(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let i=!1;for(const f of r){if(!f||f.id===void 0)continue;const u=String(f.id);a.appendChild(F(n,"option",{text:f.title||u,attrs:{value:u}})),u===this.#m&&(i=!0)}i||(this.#m=null),a.value=this.#m||""}#S(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):v;if(this.#$(),a===0||!U(this.#r.setTimeout)){this.#E();return}this.#b=this.#r.setTimeout(()=>{this.#b=null,this.#E()},a)}#E(){const a=this.#j();if(!a||this.#O)return;const n=this.#s?this.#s.value:"";if(!n){this.#z(),a.clear();return}a.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#T()}),this.#P()}#T(){const a=this.#t&&this.#t.window,n=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,n)}#P(){if(this.#w!==null||this.#O)return;const a=()=>{this.#w=null,this.#M()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(a):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(a,0):a()}#M(){const a=this.#j();!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(),n=this.#j().active;let t="",r="idle";n&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),r=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),r=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const i=n&&a.windowed;this.#a.textContent=i?this.t("find.loadedRows"):"",this.#a.style.display=i?"":"none",n?a.complete&&(this.#u.textContent=a.total===0?this.t(i?"a11y.find.noneLoaded":"a11y.find.none"):this.t(i?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#$(){this.#b!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null}#z(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#V(){this.#$(),this.#z()}}const l=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 $}});const Q="lat-cell--redacted",F="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 H=W.active;for(const U of X.querySelectorAll(`.${F}[data-col]`))H&&W.has(U.getAttribute("data-col"))?U.classList.add(Q):U.classList.contains(Q)&&U.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const $=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 F=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function $(W,H){let U=W;for(;U;){if(H(U))return U;U=U.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const U=$(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${B}[data-col]`)){const w=z.getAttribute("data-col"),v=this.#r(z),g=v?H.errorFor(v,w):null;F(z,g?g.message:null)}}destroy(){for(const H of this.#n)H();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 v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",z="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class v{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),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&&F(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 d=this.#t.viewport?.root;if(d&&F(d.addEventListener)){const a=n=>this.#l(n);d.addEventListener("keydown",a),this.#r.push(()=>d.removeEventListener("keydown",a))}}#l(d){const a=this.#e.presentation;if(!a?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(a.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(a.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),d.preventDefault?.()):t==="0"&&(a.setScale(1.5),d.preventDefault?.());return}if(!a.views.length||$(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),d.preventDefault?.()):t==="Home"?(a.goTo(0),d.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const n=a.ownerDocument;if(!n?.createElement)return;if(!this.#i){const i=n.createElement("div");i.className=U,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),a.appendChild(i),this.#i=i}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#h();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of w){if(a.has(r)||r==="toolPanel"&&this.#O())continue;const i=this.#y(r);i&&i.style&&i.style.display!=="none"&&(i.style.display="none",n.push(i))}const t=this.#b();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(W),this.#h(),this.#m()}#f(){const d=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(H),this.#p(),d){const n=this.#e.toolPanel;n&&F(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const i=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!a||i&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#b(){const d=this.#e.element;return!d||!F(d.querySelector)?null:d.querySelector(`.${X.statusBar}`)}#w(d){const a=d.children||[];for(const n of a)if(!n.style||n.style.display!=="none")return!1;return!0}#O(){const d=this.#e.toolPanel;return!!(d&&F(d.presentOnly)&&d.presentOnly())}#y(d){const a=this.#e.element;if(!a||!F(a.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?a.querySelector(n):null}destroy(){this.#o&&this.#f();for(const d of this.#r)d();this.#r=[]}}const g=v}),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 H}});const F=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function $(U,z,w){const v=w.getComputedStyle(U),g=z.style;if(g)for(let l=0;l<v.length;l++){const d=v[l];B.has(d)||g.setProperty(d,v.getPropertyValue(d),v.getPropertyPriority(d))}}function _(U,z,w){if($(U,z,w),U.tagName==="CANVAS"&&F(U.toDataURL))try{const l=U.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${l})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const v=U.children||[],g=z.children||[];for(let l=0;l<v.length&&l<g.length;l++)_(v[l],g[l],w)}function X(U,z){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,z).origin===z}catch{return!0}}async function W(U,z={}){const w=U.ownerDocument,v=w?.defaultView;if(!v||typeof v.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=U.getBoundingClientRect(),l=Math.max(1,Math.ceil(g.width)),d=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(z.scale)||2),n=v.location?.origin||"";for(const m of U.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,n))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=U.cloneNode(!0);_(U,t,v),t.style.width=`${l}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new v.XMLSerializer().serializeToString(t),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new v.Image;await new Promise((m,c)=>{f.onload=()=>m(void 0),f.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`});const u=w.createElement("canvas");u.width=Math.round(l*a),u.height=Math.round(d*a);const o=u.getContext("2d");if(!o)throw new Error("capture could not get a 2d context");return o.fillStyle=z.background||v.getComputedStyle(U).backgroundColor||"#ffffff",o.fillRect(0,0,u.width,u.height),o.drawImage(f,0,0,u.width,u.height),new Promise((m,c)=>{u.toBlob(h=>h?m({blob:h,width:u.width,height:u.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=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 H}}),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"),F=Q.isFunction,B=Q.uid,$=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=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,v="system-ui, -apple-system, sans-serif";function g(h,s){if(!h||typeof h!="object")return null;const p=U[h.type];if(!p)return null;const b=typeof h.id=="string"&&h.id?h.id:B("mark"),A=Array.isArray(h.points)?h.points:[],k=[];for(const S of A){const R=Number(S&&S.x),j=Number(S&&S.y);Number.isFinite(R)&&Number.isFinite(j)&&k.push({x:R,y:j})}const y=typeof h.colour=="string"&&h.colour?h.colour:s;if(p==="text"){const S=typeof h.text=="string"?h.text:"";if(!k.length||!S)return null;const R={id:b,tool:p,colour:y,points:[k[0]],text:S,region:l(h.region)},j=Number(h.fontSize);return Number.isFinite(j)&&j>0&&(R.fontSize=j),typeof h.background=="string"&&h.background&&(R.background=h.background),R}return k.length<2?null:{id:b,tool:p,colour:y,points:k,region:l(h.region)}}function l(h){return h==="start"||h==="end"?h:"centre"}function d(h){const s={id:h.id,type:z[h.tool]||h.tool,colour:h.colour,points:h.points.map(p=>({x:p.x,y:p.y}))};return(h.region==="start"||h.region==="end")&&(s.region=h.region),h.tool==="text"&&(s.text=h.text,h.fontSize!==void 0&&(s.fontSize=h.fontSize),h.background!==void 0&&(s.background=h.background)),s}const a="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,s){return{id:h,count:s,valueOf(){return this.count}}}const i=10;function f(h,s,p){const b=p.x-s.x,A=p.y-s.y,k=b*b+A*A;let y=k?((h.x-s.x)*b+(h.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(h.x-S,h.y-R)}function u(h){const s=h.points;if(!s.length)return null;if(h.tool==="text"){const y=h.fontSize||w,S=(h.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 o(h,s){const p=u(h);if(!p)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(h.tool==="text")return 1/0}const b=h.points;if(h.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,f(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,f(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(),r(p.id,this.#s.length)):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?($("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||!F(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.#f(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#h(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#f(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})}#h(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||!F(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()};F(k.addEventListener)?k.addEventListener("change",y,{once:!0}):F(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=>l(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(!F(b?.getBoundingClientRect)||!F(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=j=>{if(!F(j?.getBoundingClientRect))return null;const x=j.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.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 j of[A,k]){if(!j)continue;const x=j.left+j.width;j.left+j.width/2<R?y=Math.max(y,x):S=Math.min(S,j.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(!F(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(!F(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=(n[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 ${v}`,s.textBaseline="top";const R=p.text||"";if(p.background){let j=R.length*S*.6;if(typeof s.measureText=="function"){const x=s.measureText(R);x&&Number.isFinite(x.width)&&(j=x.width)}s.fillStyle=p.background,s.fillRect(k.x-S*.15,k.y-S*.1,j+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.#j(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}#j(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=u(p);if(!b||!F(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=i*b;for(let k=this.#s.length-1;k>=0;k--){const y=this.#s[k];if(l(y.region)===p&&o(y,s)<=A)return y}return null}#S(){const s=F(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 j=s.getBoundingClientRect(),{left:x,top:E}=this.#S();return{x:S.clientX-j.left+(R==="centre"?x:0),y:S.clientY-j.top+E}},b=S=>{if(!this.#o||!this.#O(S))return;const R=this.#w(S.clientX);if(this.#o==="erase"){const j=this.#C(p(S,R),R);j&&(this.remove(j.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 j=!1;S.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=S.deltaY,j=!0),S.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=S.deltaX,j=!0),j&&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&&F(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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/internal/util.js").isFunction,$=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 v=Math.round(w/60);return v<60?`${v}m ago`:`${Math.round(v/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 H{#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,v=w.depth,g=w.position;this.#r.max=String(Math.max(1,v)),this.#r.value=String(Math.max(0,v-g)),this.#r.disabled=v===0;const l=w.at(),d=w.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):X(Date.now()-(l||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=v===0?this.#l("timeline.recording"):W(l,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(w,v){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,v)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,v=w?.ownerDocument;if(!w||!v?.createElement)return;const g=v.createElement("div");g.className=_;const l=v.createElement("span");l.className=`${_}__ago`,l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const d=v.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const a=v.createElement("span");a.className=`${_}__clock`;const n=v.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(l),g.appendChild(d),g.appendChild(a),g.appendChild(n),w.appendChild(g),this.#n=g,this.#r=d,this.#o=l,this.#i=a;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const i=f=>f.stopPropagation();d.addEventListener("keydown",i),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",i)})}#u(){this.#n&&(F(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 U=H}),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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",H="lat-cell--commented",U="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 l=this.#t.viewport?.root;if(!l||!l.querySelectorAll)return;const d=[];for(const a of l.querySelectorAll("[data-key]")){const n=a.getAttribute("data-key");if(n){d.push(n);for(const t of a.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),i=g.at(n,r),f=!!(i&&i.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&i.unresolved>0),this.#i(t,i,r)}}}(d.length!==this.#r.length||d.some((a,n)=>a!==this.#r[n]))&&(this.#r=d,g.request(d))}#o(g,l){const d=this.#e;return(d&&d.messages?d.messages:$).t(g,l)}#i(g,l,d){if(!l||!l.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=l.count,n=l.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!F(g.addEventListener))return;const l=a=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=a.target&&F(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,a))return;const r=t.closest("[data-key]"),i=r&&r.getAttribute("data-key");i&&(a.stopPropagation(),a.preventDefault(),n.open(i,t.getAttribute("data-col")))},d=a=>{const n=this.#e.comments;if(!n||!n.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&&F(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),i=r&&r.getAttribute("data-key");i&&(a.preventDefault(),a.stopPropagation(),n.open(i,t.getAttribute("data-col")))};g.addEventListener("click",l,!0),g.addEventListener("keydown",d,!0),this.#n.push(()=>{g.removeEventListener("click",l,!0),g.removeEventListener("keydown",d,!0)})}#l(g,l){if(!F(g.getBoundingClientRect))return!1;const d=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,d.height*.6));return(X(g)?l.clientX<=d.left+a:l.clientX>=d.right-a)&&l.clientY<=d.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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="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 l of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(l,d=>this.#l(l,d)));this.#a(),this.paint()}}#l(g,l){if(this.#f(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=l&&l.peer;a&&(this.#r.textContent=this.#h(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,l=g?.ownerDocument;if(!g||!l?.createElement)return;const d=this.#e.get("presence")||{},a=l.createElement("span");if(a.className=`${U}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,d.roster===!1)return;const n=l.createElement("div");n.className=U,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",g.appendChild(n),this.#n=n}paint(){const g=this.#e.presence,l=this.#t.viewport?.root;if(!g||!g.enabled||!l?.querySelectorAll)return;this.#d(l);const d=g.peers(),a=[...d].sort((n,t)=>n.at-t.at);for(const n of a)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const i of t.columns||[])this.#c(l,r,i,n,"range");for(const n of a)n.cursor&&this.#c(l,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of a)n.editing&&this.#c(l,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(d)}#u(g){if(this.#s!==null)return;const l=g.filter(n=>n.cursorFresh);if(!l.length)return;const a=Math.max(...l.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,l,d,a,n){const t=g.querySelector(`[data-key="${X(l)}"]`),r=t&&t.querySelector(`[data-col="${X(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",a.colour),r.setAttribute("data-peer-name",a.name),r.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&a.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${l}${d}`))}#d(g){if(this.#o.size){for(const l of g.querySelectorAll("[data-presence]"))l.removeAttribute("data-presence"),l.removeAttribute("data-peer-name"),l.removeAttribute("data-peer-initial"),l.removeAttribute("data-peer-fresh"),l.removeAttribute("data-peer-idle"),l.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const g=this.#n.ownerDocument,l=this.#e.presence.peers();if(this.#n.textContent="",!l.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of l){const n=g.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",a.colour),n.toggleAttribute("data-idle",!!a.idle),n.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:a.name}));const r=g.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const i=g.createElement("span");i.className=`${U}__name`,i.textContent=a.name,n.appendChild(i),n.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(n)}const d=l.filter(a=>a.hidden).length;if(d){const a=g.createElement("span");a.className=`${U}__hidden`,a.textContent=this.#h("presence.hidden",{count:d}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const l=g&&g.name?g.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:l})}#h(g,l){const d=this.#e;return(d&&d.messages?d.messages:$).t(g,l)}destroy(){for(const l of this.#i)l();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&F(this.#n.remove)&&this.#n.remove(),this.#r&&F(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 v}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",z=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function v(a,n){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((n-a)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function g(a,n,t,r){n.textContent="";const i=String(t??"");if(!r){n.textContent=i;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,o=f.exec(i);for(;o;){o.index>u&&n.appendChild(a.createTextNode(i.slice(u,o.index)));const m=o[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),n.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),n.appendChild(c)}else{const c=m.indexOf("]("),h=m.slice(1,c),s=m.slice(c+2,-1);if(z.test(s)){const p=a.createElement("a");p.href=s,p.textContent=h,p.rel="noopener noreferrer",p.target="_blank",n.appendChild(p)}else n.appendChild(a.createTextNode(h))}u=o.index+m.length,o=f.exec(i)}u<i.length&&n.appendChild(a.createTextNode(i.slice(u)))}class l{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),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(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#y(),this.#o&&F(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&F(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);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(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const i=r.querySelector(`[data-key="${X(n)}"]`);return i?i.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:$).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const i=n.createElement("div");i.className=`${U}__title`,r.appendChild(i);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const u=n.createElement("button");u.className=`${U}__close`,u.type="button",u.setAttribute("aria-label",this.#h("comments.close")),u.textContent="×",r.appendChild(u);const o=n.createElement("div");o.className=`${U}__list`,o.setAttribute("role","log"),o.setAttribute("aria-live","polite");const m=n.createElement("form");m.className=`${U}__composer`;const c=n.createElement("textarea");c.className=`${U}__input`,c.rows=2,c.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),m.appendChild(c),m.appendChild(h),t.appendChild(r),t.appendChild(o),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=o,this.#o=c,this.#m=i,this.#g=f;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(x=>x.offsetParent!==null||x===c);if(!y.length)return;const S=y[0],R=y[y.length-1],j=t.ownerDocument.activeElement;k.shiftKey&&j===S?(k.preventDefault(),R.focus()):!k.shiftKey&&j===R&&(k.preventDefault(),S.focus())};m.addEventListener("submit",s),u.addEventListener("click",p),f.addEventListener("click",b),t.addEventListener("keydown",A),this.#l.push(()=>{m.removeEventListener("submit",s),u.removeEventListener("click",p),f.removeEventListener("click",b),t.removeEventListener("keydown",A)})}#m=null;#g=null;#b(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},i=Date.now(),f=n.openKey,{rowId:u,field:o}=H(f),m=this.#e.columns.get(o),c=this.#e.rows.byKey(u),h=F(r.rowLabel)&&c?r.rowLabel(c):u;if(this.#m.textContent=this.#h("comments.cellTitle",{column:m&&(m.title??m.id)||o,row:h}),this.#g.textContent=this.#b()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const s=n.thread||[];if(!s.length){this.#d(this.#h("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,i,p,r))}#O(n,t,r,i,f){const u=n.createElement("article");u.className=`${U}__item`,t.pending&&u.setAttribute("data-pending","true"),t.resolved&&u.setAttribute("data-resolved","true");const o=n.createElement("div");o.className=`${U}__meta`;const m=n.createElement("span");m.className=`${U}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),o.appendChild(m);const c=n.createElement("time");c.className=`${U}__time`;const h=v(t.at,r);c.textContent=t.edited?this.#h("comments.edited",{time:h}):h,o.appendChild(c),u.appendChild(o);const s=n.createElement("div");if(s.className=`${U}__body`,g(n,s,t.body,!!f.markdown),u.appendChild(s),t.value!==void 0&&!Object.is(t.value,i)){const A=n.createElement("p");A.className=`${U}__moved`,A.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(i)}),u.appendChild(A)}const p=t.can||{},b=A=>p[A]!==!1;if(b("edit")||b("delete")){const A=n.createElement("div");if(A.className=`${U}__actions`,b("delete")){const k=n.createElement("button");k.type="button",k.className=`${U}__action`,k.textContent=this.#h("comments.delete"),k.addEventListener("click",()=>this.#e.comments.remove(t.id)),A.appendChild(k)}u.appendChild(A)}return u}#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:r,field:i}=H(t),f=this.#f(r,i)||this.#i,u=this.#t.viewport?.root;if(!f||!u||!F(f.getBoundingClientRect))return;const o=f.getBoundingClientRect(),m=u.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let h=o.bottom-m.top+4;h+c.height>m.height&&o.top-m.top>c.height&&(h=o.top-m.top-c.height-4);let s=o.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=o.bottom<m.top||o.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&F(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=l}),Le("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,H="lat-watermark",U="https://www.latticegrid.dev",z=["br","bl","tl","tr"],w=4e3;class v{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),F(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&F(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#f(),this.#u()):!d&&this.#r&&(this.#h(),this.#c())}#a(){const d=this.#i;if(!d||!F(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),F(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%z.length,this.#h(),this.#f(),this.#u()},w)))}#c(){this.#l!==null&&F(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&F(d.watermark)&&d.watermark())}#f(){const d=this.grid&&this.grid.messages?this.grid.messages:$,a=X(this.#t,"a",{class:`${H}__link`,text:d.t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}}),n=X(this.#t,"span",{class:`${H}__free`,text:d.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,n]}),this.#o.push(W(this.#r,"pointerdown",t=>{F(t.stopPropagation)&&t.stopPropagation()})),this.#n&&F(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&F(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#h()}}const g=v}),Le("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),F=Q.warnOnce,B=Q.isFunction,$=K("packages/dom/src/editors/common.js"),_=$.el,X=$.on,H=K("packages/dom/src/themeof.js").themeOf,U="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",v="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 F("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:v}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,i=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(a):null;i&&(this.#e.setAttribute("data-theme",i),this.#u=!0),a.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,u]of Object.entries(z))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=u;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(U),this.#t.body.classList&&this.#t.body.classList.add(w),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const a=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,i]of Object.entries(this.#a))this.#e.style[r]=i;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(U),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.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(a){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;a(),t&&B(t.focus)&&t.focus()}#f(a){!a||a.key!=="Escape"||a.defaultPrevented||this.exit()}#h(){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 l=g}),Le("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),F=Q.documentFor,B=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),w=z.describeGrid,v=z.promptText,g=K("packages/core/src/ai/intent.js"),l=g.applyPlan,d=g.buildPrompt,a=g.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#b="idle";#w=0;#O=!1;#y=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(u,o)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||W,this.#e=F(u),this.#t=u.grid||null,this.#n=U(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:U(u.onPlan)?u.onPlan:null,onApply:U(u.onApply)?u.onApply:null,onError:U(u.onError)?u.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#j(u)}element(){return this.#s}refresh(){this.#O||!this.#s||this.#b!=="busy"&&this.#E()}destroy(){this.#O=!0,this.#w++;for(const u of this.#y)u();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.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(u){if(this.#O||this.#b==="busy")return null;const o=String(u??(this.#l&&this.#l.value)??"").trim();if(!o)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 h=w(this.#t,this.#r),s=v(h);if(c=await this.#n({prompt:o,schema:h,schemaText:s,message:d(o,s),context:this.#o}),this.#O||m!==this.#w)return null;const p=a(c,h);return this.#C(p),p}catch(h){return this.#O||m!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#P(h instanceof Error?h.message:String(h))),null}}apply(){const u=this.#g;if(this.#O||!u||!u.ok)return null;const o=this.#t?.ai,m=U(o?.apply)?o.apply(u):l(u,this.#t);return this.#i.onApply&&this.#i.onApply(m,u),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: ${u.describe()}`),m}discard(){this.#O||(this.#E(),this.#T("Discarded."))}#j(u){const o=this.#e,m=B(o,"div",{class:`${n}__row`});this.#l=B(o,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push($(this.#l,"keydown",h=>{const s=h&&h.key;s==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=B(o,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push($(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=B(o,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(o,"p",{class:`${n}__summary`}),this.#d=B(o,"ul",{class:`${n}__notes`});const c=B(o,"div",{class:`${n}__buttons`});this.#f=B(o,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(o,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push($(this.#f,"click",()=>{this.apply()})),this.#y.push($(this.#h,"click",()=>{this.discard()})),c.appendChild(this.#f),c.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(o,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(o,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#k(u){if(this.#b=u,!this.#s)return;this.#s.setAttribute("data-state",u);const o=u==="busy";r(this.#l,o),r(this.#a,o),this.#a&&(this.#a.textContent=this.t(o?"prompt.asking":"prompt.ask")),i(this.#u,u!=="preview"),i(this.#m,u!=="error")}#C(u){const o=u;if(this.#i.onPlan&&this.#i.onPlan(u),!o.ok){this.#g=null;const m=o.rejected.length?o.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#P(`I could not turn that into a change: ${m}`);return}this.#g=u,this.#T(""),this.#c&&(this.#c.textContent=o.describe()),this.#S(o.rejected),this.#k("preview")}#S(u){const o=this.#d;if(o){_(o),i(o,!u.length);for(const m of u.slice(0,6))o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:m.reason}));u.length>6&&o.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#k("idle")}#T(u){this.#p&&(this.#p.textContent=u)}#P(u){this.#g=null,this.#T(""),this.#m&&(this.#m.textContent=u),this.#k("error")}}function r(f,u){f&&(f.disabled=u,u?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function i(f,u){f&&(f.hidden=u,u?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),Le("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.isObject,$=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,v=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"},l="unknown",d=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 n(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 r(s,p,b=null){if(F(p)){const j=p(s,b);return j==="good"||j==="warn"||j==="bad"?j: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=j=>S?A<=j:A>=j;return k!==null&&R(k)?"good":y!==null&&R(y)?"warn":k===null&&y===null?null:"bad"}function i(s){return!(F(s.value)||s.value!==void 0&&!B(s.value))}function f(s){return!s||!s.rows||!F(s.rows.totalCount)?!0:s.rows.totalCount()>0}function u(s){const p=B(s)?s:{},b=p.grid||null,A=c(p.container,b);if(!A)return $("stat.container","createStat needs a `container`: an element or a selector."),h();const k=A.ownerDocument||(typeof document>"u"?null:document);if(!k)return $("stat.document","createStat needs a document; it draws DOM."),h();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 j=k.createElement("div");j.className=g.interval;const x=k.createElement("div");x.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 te=k.createElement("span");te.className=g.icon,te.setAttribute("aria-hidden","true"),v(te,p.icon,`stat:${p.title||"stat"}`),y.appendChild(te);const ne=k.createElement("div");ne.className=g.body,ne.appendChild(S),ne.appendChild(R),ne.appendChild(T),ne.appendChild(j),ne.appendChild(x),ne.appendChild(E),y.appendChild(ne)}else y.appendChild(S),y.appendChild(R),y.appendChild(T),y.appendChild(j),y.appendChild(x),y.appendChild(E);A.appendChild(y);let P=null;const D=[];let I=!1;function C(){if(F(p.value))return p.value(b);if(p.value!==void 0&&!B(p.value))return p.value;const te=B(p.value)?p.value:p,ne=te.of,oe=te.fn||"sum",le=te.show;return b?oe==="count"?N().length:ne?le?G(String(ne),String(oe),String(le)):O()==="filtered"&&b.statistics&&F(b.statistics.reduce)?b.statistics.reduce(String(ne),String(oe)):X(N().map(ae=>m(ae,String(ne))),String(oe)):null:null}function O(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const te=O();if(te==="all"){const oe=[];return F(b.rows.forEachAll)&&b.rows.forEachAll(le=>{le.group||oe.push(o(le))}),oe}if(te==="selected")return(b.selection&&F(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(o);const ne=[];return F(b.rows.forEach)&&b.rows.forEach(oe=>{oe.group||ne.push(o(oe))}),ne}function G(te,ne,oe){if(ne!=="min"&&ne!=="max")return $(`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 le=null,ae=null;for(const se of N()){const ee=Number(m(se,te));Number.isFinite(ee)&&(le===null||(ne==="max"?ee>le:ee<le))&&(le=ee,ae=se)}return ae===null?null:m(ae,oe)}function q(te){if(F(p.format))return String(p.format(te,b));if(te==null)return p.empty??"—";const ne=B(p.value)?p.value:p,oe=ne.show||ne.of;if((ne.show?!0:d.has(String(ne.fn||"sum")))&&b&&oe&&F(b.columns?.get)){const ae=b.columns.get(String(oe));if(ae&&F(ae.formatValue))return ae.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(p.decimals??2):String(te)}function Z(te){return te?(b&&b.messages||z).t(`stat.tone.${te}`):""}function J(){if(I)return;const te=C(),ne=i(p)&&!!b&&!f(b),oe=ne?null:te,le=F(p.baseline)?p.baseline(b):p.baseline;P=oe,S.textContent=p.title??"",S.hidden=!p.title,R.textContent=q(oe),T.hidden=!ne,ne&&(T.textContent=b.messages.t("stat.noData"));const ae=ne||le===void 0||le===null?a:n(typeof oe=="number"?oe:null,Number(le)),se=t(ae.direction,p.goodWhen||"up");if(x.hidden=ae.change===null,ae.change!==null){const he=ae.direction==="up"?"↑":ae.direction==="down"?"↓":"→",ge=ae.percent===null?q(Math.abs(ae.change)):`${Math.abs(ae.percent).toFixed(1)}%`;x.textContent=`${he} ${ge}`,x.setAttribute("data-tone",se),x.setAttribute("data-direction",ae.direction)}const ee=F(p.interval)?p.interval(oe,b):null,ie=!!ee&&Number.isFinite(ee.lower)&&Number.isFinite(ee.upper);j.hidden=!ie,ie&&(j.textContent=`${q(ee.lower)} – ${q(ee.upper)}`,Number.isFinite(ee.confidence)&&j.setAttribute("title",`${Math.round(ee.confidence*100)}%`));const ce=ne?l:p.bands?r(oe,p.bands,b):null;ce?y.setAttribute("data-tone",ce):y.removeAttribute("data-tone"),E.textContent=F(p.footer)?String(p.footer(oe,b)):p.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[p.title,R.textContent,ne?T.textContent:"",ie?j.textContent:"",ae.change===null?"":x.textContent,ae.change===null?"":Z(se),E.textContent].filter(Boolean).join(", "))}if(b&&F(b.on)&&p.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ne=oe=>{te==="model:changed"&&!H(oe)||J()};b.on(te,ne),D.push(()=>F(b.off)&&b.off(te,ne))}return J(),{element:()=>y,value:()=>P,refresh:J,destroy(){I=!0;for(const te of D)try{te()}catch{}D.length=0,y.remove()}}}function o(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 h(){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 F=K("packages/core/src/internal/util.js").isObject,$=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:z}){this.#e=H,this.#t=U,this.#n=Array.isArray(z)?z.filter(F):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${_.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const z of this.#n){const w=$({...z,grid:this.#e,container:U});this.#o.push(w)}}destroy(){for(const H of this.#o)try{H.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 At}});const F=K("packages/core/src/index.js").createHeadlessGrid,$=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),H=W.fail,U=W.isFunction,z=W.warnOnce,v=K("packages/dom/src/localviews.js").createLocalViewStorage,l=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,o=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,h=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,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,P=K("packages/dom/src/alignedgrids.js").AlignedGrids,I=K("packages/dom/src/columntagbar.js").ColumnTagBar,O=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,le=K("packages/dom/src/editbar.js").EditBar,se=K("packages/dom/src/rangeselect.js").RangeController,ie=K("packages/core/src/model/selection.js").resolveSelectionConfig,he=K("packages/dom/src/importer.js").ImportController,Ee=K("packages/dom/src/historybar.js").HistoryBar,Ae=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,Ve=K("packages/dom/src/findpaint.js").FindPainter,je=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,ke=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,Se=K("packages/dom/src/maximise.js").Maximiser,Pe=K("packages/dom/src/promptbar.js").PromptBar,ze=K("packages/dom/src/kpistrip.js").KpiStrip;function _e(He,pt,ct){const ot=pt==="redo"?"toolbar.redo":"toolbar.undo";return!ct||!ct.label?He(ot):He(pt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:ct.label})}const De=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Oe=2e3;function xe(He,pt,ct,ot){const St=pt.annotate===!0?Be(He,ot):[];if(pt.actions===!1)return[];if(pt.actions===void 0&&pt.side!=="left")return St;const jt=Array.isArray(pt.actions)?pt.actions:De,ht=(Dt,_t)=>He.messages.t(Dt,_t),Nt={undo:{name:"undo",title:()=>_e(ht,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>_e(ht,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>ht("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:pt.exportName})},excel:{name:"excel",title:()=>ht("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:pt.exportName})},clipboard:{name:"clipboard",title:()=>ht("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>ht("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return ht("toolbar.pause");const Dt=He.updates.stats().pending;return Dt?ht("toolbar.applyHeld",{count:Dt}):ht("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>ht("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>ht(ct&&ct.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>ct&&ct.active()?"minimise":"maximise",run:()=>ct.toggle()}};return ct||delete Nt.maximise,jt.map(Dt=>Dt==="-"?{name:"-",separator:!0}:typeof Dt=="string"?Nt[Dt]:!Dt||typeof Dt!="object"||!Dt.name?null:{...Dt,run:U(Dt.run)?()=>Dt.run({grid:He,keys:He.selection&&U(He.selection.keys)?He.selection.keys():[],cells:He.selection&&U(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(St)}function Be(He,pt){const ct={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ot=(jt,ht)=>He.messages.t(jt,ht),St=["pen","arrow","rect","highlight","erase"].map(jt=>({name:jt,title:()=>ot(`toolbar.annotate.${jt}`),icon:ct[jt],run:()=>He.annotate?.use(jt),active:()=>He.annotate?.tool===jt,annotation:!0}));return St.push(Je(He,ot,pt)),St}function Je(He,pt,ct){return{name:"clearAll",title:()=>pt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>Qe(He,pt,ct)}}function Qe(He,pt,ct){const ot=He.toolPanel;if(!ot)return;const St=ht=>ct?.announce?.(pt(ht),{repeat:!0});ot.removeAction("clearAll");const jt=()=>{ot.removeAction("clearAllConfirm"),ot.removeAction("clearAllKeep"),ot.addAction(Je(He,pt,ct))};ot.addAction({name:"clearAllConfirm",title:()=>pt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),jt(),St("a11y.annotate.cleared")}}),ot.addAction({name:"clearAllKeep",title:()=>pt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>jt()}),St("a11y.annotate.confirmClear")}const at=["pen","arrow","rect","highlight","erase","clearAll"];function it(He){let pt=null,ct=null;return He.on("source:error",ot=>{const St=ot&&ot.error;ct=String(St&&St.message||"").replace(/^\[lattice\]\s*/,"")||(He.messages?He.messages.t("overlay.error"):"Something went wrong")}),He.on("rows:changed",()=>{ct=null}),{loadError:()=>ct,rowCount:()=>{if(U(He.rows.matchCount))return He.rows.matchCount();const ot=He.pagination&&U(He.pagination.get)?He.pagination.get():null;return ot&&Number.isFinite(ot.total)?ot.total:He.rows.count()},totalRowCount:()=>U(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{pt||(pt=U(He.rendererHost)?He.rendererHost():{});const ot=U(pt.selectionSummary)?pt.selectionSummary():null;return ot&&ot.predicate?{count:ot.count}:null},selectedCount:()=>{const ot=He.selection&&He.selection.keys?He.selection.keys():null;return ot?ot.length:0},rangeValues:()=>{const ot=He.selection;return!ot||!U(ot.cells)?[]:ot.cells().map(({key:St,colId:jt})=>He.rows.value(St,jt))},hiddenUnresolved:()=>U(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>U(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function gt(He,pt){for(const[ct,ot]of Object.entries(f||{}))He.register("editor",ct,ot);for(const[ct,ot]of Object.entries(o||{}))He.register("filter",ct,ot);for(const[ct,ot]of Object.entries(pt.components||{}))He.register("component",ct,ot);for(const[ct,ot]of Object.entries(pt.pipes||{}))He.register("pipe",ct,ot);for(const[ct,ot]of Object.entries(pt.totalFns||{}))He.register("totalFn",ct,ot)}function wt(He,pt,ct,ot,St,jt){const ht=[],Nt=pt.viewport;let Dt=null;if(ct.maximise!==!1&&(Dt=new Se({element:jt,document:ot,onChange:()=>pt.invalidate("all"),captureScroll:()=>pt.scrollState(),restoreScroll:lt=>pt.restoreScroll(lt)}),He.maximise=Dt,ht.push(()=>Dt.destroy())),ct.statusBar){const lt=typeof ct.statusBar=="object"?ct.statusBar:{},vt=new c;vt.init({document:ot,host:it(He),panels:lt.panels,registry:lt.registry,locale:He.get("locale"),messages:He.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`)},Vt=()=>{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=>He.on(on,Vt));Vt(),Rt(),ht.push(()=>{for(const on of Gt)on();Nt.root.style.removeProperty("--lattice-status-height"),vt.destroy?.()})}const _t=ie(ct.selection);if(_t.ranges){const lt=new se({grid:He,renderer:pt,document:ot});lt.mount(),He.ranges=lt,ht.push(()=>lt.destroy())}if(ct.import){const lt=new he({grid:He,renderer:pt,document:ot,settings:typeof ct.import=="object"?ct.import:{}});He.importer=lt,ht.push(()=>lt.destroy())}if(ct.historyBar){const lt=typeof ct.historyBar=="object"?ct.historyBar.element:null,vt=new Ee;vt.init({document:ot,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Vt=>He.history.peek(Vt),list:()=>He.history.list()},props:typeof ct.historyBar=="object"?ct.historyBar:{}}),(lt||Nt.root).appendChild(vt.element());const Rt=[He.on("history:changed",()=>vt.refresh())];He.historyBar=vt,ht.push(()=>{for(const Vt of Rt)Vt();vt.destroy()})}if(ct.diff){const lt=new Ae({grid:He,renderer:pt});lt.mount(),He.diffPainter=lt,ht.push(()=>lt.destroy())}if(ct.ai&&U(ct.ai.ask)){const lt=new Pe;lt.init({document:ot,grid:He,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()),He.promptBar=lt,ht.push(()=>lt.destroy())}if(ct.groupPanel){const lt=typeof ct.groupPanel=="object"?ct.groupPanel:{},vt=new p;vt.init({document:ot,grid:He,host:J(He,ot,(Rt,Vt)=>pt.announce?.(Rt,Vt)),props:{header:Nt.header,hint:lt.hint}}),Nt.root.insertBefore(vt.element(),Nt.header),He.groupPanel=vt;for(const Rt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(He.on)&&ht.push(He.on(Rt,()=>vt.refresh()));ht.push(()=>vt.destroy())}if(ct.kpis){const lt=new ze({grid:He,document:ot,kpis:ct.kpis});lt.active&&(lt.mount(),Nt.root.insertBefore(lt.element(),Nt.header),He.kpiStrip=lt,ht.push(()=>lt.destroy()))}if(ct.toolPanel){const lt=typeof ct.toolPanel=="object"?ct.toolPanel:{},vt=new Z({grid:He,document:ot,root:Nt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:xe(He,lt,Dt,pt),announce:(Rt,Vt)=>pt.announce?.(Rt,Vt)});vt.mount(),He.toolPanel=vt,ht.push(()=>vt.destroy()),lt.annotate===void 0&&(ht.push(He.on("presentation:started",()=>{for(const Rt of Be(He,pt))vt.addAction(Rt)})),ht.push(He.on("presentation:ended",()=>{for(const Rt of at)vt.removeAction(Rt)})))}if(!!ct.pagination&&(()=>{const lt=typeof ct.pagination=="object"?ct.pagination:{};return He.pagination.set({pageSize:Number(lt.pageSize)||100}),He.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:He.get("locale"),messages:He.messages,onChange:({page:Gt,pageSize:on})=>He.pagination.set({page:Gt,pageSize:on})});const Rt=()=>{const Gt=He.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()};He.pagination.set({pageSize:vt.pageSize}),Rt();const Vt=["rows:changed","filter:changed","model:changed"].map(Gt=>He.on(Gt,Rt));Nt.statusBar.appendChild(vt.element()),ht.push(()=>{for(const Gt of Vt)Gt();vt.destroy?.()})}if(ct.edit!==!1)if(ct.editBar){const lt=new le({grid:He,document:ot,root:Nt.root});lt.mount(),He.editBar=lt,ht.push(()=>lt.destroy())}else{const lt=new ne({grid:He,document:ot,renderer:pt,registry:St,cellLayer:pt.cellLayer});lt.mount(),ht.push(()=>lt.destroy())}const cn=new y({grid:He,document:ot,layer:Nt.overlays,registry:St});cn.mount(),ht.push(()=>cn.destroy());const qt=new R({grid:He,document:ot,host:Nt.root,cellMenu:ct.contextMenu!==!1,headerMenu:ct.columnMenu!==!1,items:U(ct.contextMenu)?ct.contextMenu:void 0,headerItems:U(ct.columnMenu)?ct.columnMenu:void 0});if(qt.mount(),ht.push(()=>qt.destroy()),Array.isArray(ct.alignedGrids)&&ct.alignedGrids.length){const lt=new P;lt.add(He);for(const vt of ct.alignedGrids)vt&&vt!==He&<.add(vt);ht.push(()=>lt.destroy())}const Wt=new G({grid:He,renderer:pt,document:ot,registry:St});Wt.active&&(Wt.mount(),ht.push(()=>Wt.destroy())),Object.defineProperty(He,"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}})}),ht.push(()=>{delete He.form}),Object.defineProperty(He,"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 r()}})}),ht.push(()=>{delete He.icons});const Mt=new I({grid:He,renderer:pt,document:ot});Mt.active&&(Mt.mount(),ht.push(()=>Mt.destroy()));const xt=new O({grid:He,renderer:pt,document:ot});xt.active&&(xt.mount(),ht.push(()=>xt.destroy()));const Bt=new T({grid:He,renderer:pt,document:ot});if(Bt.active){Bt.mount(),Bt.paint();const lt=He.on("render:done",()=>Bt.paint());ht.push(()=>{lt(),Bt.destroy()})}if(ct.shortcuts!==!1){const lt=new x({grid:He,renderer:pt});lt.mount(),ht.push(()=>lt.destroy())}const Kt=new Ne({grid:He,renderer:pt,window:ot.defaultView||void 0});Kt.mount(),ht.push(()=>Kt.destroy());const Qt=new Ve({grid:He,renderer:pt,window:ot.defaultView||void 0});if(Qt.mount(),ht.push(()=>Qt.destroy()),ct.find!==!1){const lt=new je({grid:He,renderer:pt,document:ot,settings:ct.find});lt.mount(),ht.push(()=>lt.destroy())}const Yt=new Ze({grid:He,renderer:pt});Yt.mount(),ht.push(()=>Yt.destroy());const Jt=new st({grid:He,renderer:pt});Jt.mount(),ht.push(()=>Jt.destroy());const nn=new yt({grid:He,renderer:pt,maximiser:Dt});nn.mount(),ht.push(()=>nn.destroy());const en=new It({grid:He,renderer:pt});en.mount(),ht.push(()=>en.destroy()),ct.environment||He.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"]])ht.push(He.on(lt,()=>{un=vt}));ht.push(He.on("render:done",lt=>{He.diagnostics.render(un||lt.cause,lt.phases),un=null}));const an=ot.defaultView;if(an&&U(an.requestAnimationFrame)){let lt=an.requestAnimationFrame(function vt(Rt){He.diagnostics.frame(Rt),lt=an.requestAnimationFrame(vt)});ht.push(()=>{U(an.cancelAnimationFrame)&&an.cancelAnimationFrame(lt)})}const gn=new ke({grid:He,renderer:pt});if(gn.mount(),ht.push(()=>gn.destroy()),ht.push(He.on("presence:lockRefused",lt=>gn.announceRefusal(lt.peer))),He.presence&&He.presence.enabled){for(const Rt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ht.push(He.on(Rt,()=>He.presence.publish()));let lt="";ht.push(He.on("render:done",()=>{const Rt=pt.focusState&&pt.focusState(),Vt=Rt?`${Rt.rowKey}${Rt.colId}`:"";Vt!==lt&&(lt=Vt,He.presence.publish())}));const vt=jt.ownerDocument;if(vt&&U(vt.addEventListener)){const Rt=()=>He.presence.setPaused(vt.visibilityState==="hidden");vt.addEventListener("visibilitychange",Rt),Rt(),ht.push(()=>vt.removeEventListener("visibilitychange",Rt))}}const yn=new nt({grid:He,renderer:pt});yn.mount(),ht.push(()=>yn.destroy());const bn=new We({grid:He,renderer:pt});bn.mount(),ht.push(()=>bn.destroy()),ht.push(He.on("facet:computed",()=>pt.refreshHeader?.())),_t&&_t.headerCheckbox===!0&&ht.push(He.on("selection:changed",()=>pt.refreshHeader?.())),ht.push(He.on("facet:expanded",()=>pt.invalidate("columns"))),ht.push(He.on("model:changed",()=>pt.invalidate("rows")));const Zt=(lt,vt)=>pt.announce?.(lt,vt),dn=He.messages,Ht=(lt,vt)=>dn.t(lt,vt),mn=lt=>Ht("count.rows",{count:lt});ht.push(He.on("sort:changed",()=>{const lt=He.sort.get();if(!lt.length){Zt(Ht("a11y.sort.cleared"));return}const vt=lt.map(Rt=>{const Vt=He.columns.get(Rt.col);return Ht("a11y.sort.column",{column:Vt&&Vt.title||Rt.col,direction:Ht(Rt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Ht("a11y.sort.by",{columns:dn.list(vt)}))})),ht.push(He.on("filter:changed",()=>{const lt=He.rows.matchCount?He.rows.matchCount():He.rows.count();if(lt===null)return;const vt=He.rows.totalCount?He.rows.totalCount():lt;Zt(lt===vt?Ht("a11y.filter.cleared",{rows:mn(vt)}):Ht("a11y.filter.applied",{shown:mn(lt),total:mn(vt)}))})),ht.push(He.on("selection:changed",()=>{const lt=He.selection.keys().length;Zt(lt===0?Ht("a11y.selection.cleared"):Ht("a11y.selection.count",{count:lt}))})),ht.push(He.on("group:toggled",lt=>{const vt=He.rows.byKey?He.rows.byKey(lt.key):null,Rt=(vt&&(vt.groupLabel??vt.groupValue))??lt.key;Zt(Ht(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Rt,rows:mn(He.rows.count())}))})),ht.push(He.on("column:grouped",lt=>{const vt=Array.isArray(lt.columns)?lt.columns:[];if(!vt.length){Zt(Ht("a11y.group.cleared"));return}const Rt=vt.map(Vt=>{const Gt=He.columns.get(Vt);return Gt&&Gt.title||Vt});Zt(Ht("a11y.group.by",{columns:dn.list(Rt)}))})),ht.push(He.on("page:changed",lt=>{const vt=Number(lt.size)||0,Rt=Number(lt.total)||0,Vt=vt>0?Math.max(1,Math.ceil(Rt/vt)):1;Zt(Ht("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Vt}))}));let rn={added:0,removed:0},Xt=null;const xn=()=>{Xt=null;const lt=[];rn.added&<.push(Ht("count.rowsAdded",{count:rn.added})),rn.removed&<.push(Ht("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},lt.length&&Zt(dn.list(lt))};ht.push(He.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(xn,Oe)))})),ht.push(()=>{Xt&&clearTimeout(Xt)}),ht.push(He.on("rows:paused",()=>{Xt&&(clearTimeout(Xt),Xt=null),rn={added:0,removed:0},Zt(Ht("a11y.updates.paused"),{repeat:!0})})),ht.push(He.on("rows:resumed",()=>Zt(Ht("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Cn=()=>{hn=null;const{count:lt,first:vt}=fn;if(fn={count:0,first:null},!lt||!vt)return;const Rt=He.columns.get(vt.colId),Vt=Rt&&Rt.title||vt.colId,Gt=vt.reason?Ht("a11y.edit.reason",{reason:vt.reason}):"";if(lt===1){const on=vt.restored===void 0||vt.restored===null||vt.restored===""?Ht("value.empty"):String(vt.restored);Zt(Ht("a11y.edit.refusedOne",{column:Vt,value:on,reason:Gt}),{repeat:!0});return}Zt(Ht("a11y.edit.refusedMany",{count:lt,reason:Gt}),{repeat:!0})};ht.push(He.on("cell:reverted",lt=>{!lt||!lt.applied||(fn.count+=1,fn.first||(fn.first=lt),hn||(hn=setTimeout(Cn,150)))})),ht.push(()=>{hn&&clearTimeout(hn)}),ht.push(He.on("history:applied",lt=>{const vt=!!(lt&<.direction==="redo"),Rt=lt&<.step&<.step.label;Zt(Rt?Ht(vt?"a11y.history.redo":"a11y.history.undo",{label:Rt}):Ht(vt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Et({grid:He,renderer:pt,seed:ct.state&&Array.isArray(ct.state.annotations)?ct.state.annotations:null});wn.mount(),ht.push(()=>wn.destroy()),He.annotate=wn,He.capture=async(lt={})=>{const{blob:vt,width:Rt,height:Vt}=await Ct(pt.viewport.root,lt);return(lt.download===!0||lt.download!==!1&<.fileName)&&X(vt,lt.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Rt,height:Vt,bytes:vt.size,mimeType:vt.type,fileName:lt.fileName||null},"api"),vt};const En=new qe({grid:He,document:ot,element:Nt.overlays,window:ot.defaultView||void 0});En.mount(),ht.push(()=>En.destroy());const $n=new h({grid:He,document:ot,element:Nt.overlays});$n.mount?.(),ht.push(()=>$n.destroy?.());const Tn=new A({grid:He,host:He.rendererHost(),viewport:Nt,document:ot});return Tn.mount(),ht.push(()=>Tn.destroy()),ht}function dt(He){const pt=[],ct=ot=>{if(ot&&(ot.__lattice&&pt.push(ot),ot.children))for(const St of ot.children)ct(St)};return ct(He),pt}function At(He,pt={}){(!He||typeof He!="object"||!("appendChild"in He))&&H("createGrid needs a host element as its first argument."),pt=$(pt);const ct=He.ownerDocument||(typeof document<"u"?document:null);ct||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ot=ct.documentElement&&ct.documentElement.lang,St=!pt.licence&&U(ct.querySelector)?ct.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,jt={...pt};if(!pt.locale&&ot&&(jt.locale=ot),St&&(jt.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;jt.views={...pt.views,storage:v(qt)}}const ht=F(jt),Nt=ht.rendererHost();Nt.document=ct,gt(Nt.registry,pt),Nt.cellLayer=a(Nt),Nt.detailHost=new we({grid:ht,document:He.ownerDocument||globalThis.document,createGrid:(qt,Wt)=>At(qt,Wt)});const Dt=new l(He,Nt),_t=ht.on("detail:toggled",()=>{Nt.detailHost.syncTarget(),Nt.detailHost.prune()}),pn=ht.on("config:changed",qt=>{qt&&qt.key==="detail"&&Nt.detailHost.reconfigure()});ht.on("destroy",()=>{_t(),pn(),Nt.detailHost.destroy()}),Nt.detailHost.syncTarget(),ht.attachRenderer(Dt),Dt.mount();const sn=wt(ht,Dt,pt,ct,Nt.registry,He),cn=ht.destroy.bind(ht);return ht.destroy=()=>{for(const qt of sn)try{qt()}catch{}He.__lattice===ht&&(He.__lattice=null),cn()},He.__lattice=ht,ht}}),Le("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),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 h}});const Q=K("packages/core/src/internal/util.js"),F=Q.isFunction,B=Q.warnOnce,$=K("packages/core/src/columns/datatypes.js"),_=$.BUILTIN_TYPES,X=$.parseNumberText,H=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"),v=w.toIsoDate,g=w.toIsoDateTime,d=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(H)]);function n(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 r(s,p){const b=F(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function i(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 f(s,p){return p==="text"?s===""?null:s:p==="boolean"?z(s):p==="number"?X(s):p==="date"||p==="dateString"?v(s):p==="datetime"?g(s):i(s)}function u(s){const p=n(s,"thead"),b=n(p||s,"tr"),k=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((j,x)=>{const E=r(j,x),T={id:E,field:E,title:String(j.textContent||"").trim()||E},L=F(j.getAttribute)?j.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 P=F(j.getAttribute)?j.getAttribute("data-format"):null;return P&&(T.format=P),T}),y=n(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(j=>j!==b)).map((j,x)=>{const E=t(j,"td"),L={__row:(F(j.getAttribute)?j.getAttribute("data-id"):null)||`row${x}`};return k.forEach((P,D)=>{L[P.field]=E[D]?P.type?f(String(E[D].textContent||""),P.type):i(String(E[D].textContent||"")):null}),L});return{columns:k,rows:R}}function o(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}=u(p);return d(s,{rowKey:"__row",...b,columns:o(A,b.columns),rows:b.rows!==void 0?b.rows:k})}function h(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 F=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,v){const g=[];return F(w.hasAttribute)&&w.hasAttribute(v)&&g.push(w),F(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${v}]`)),g}function H(w){const v=w.parentNode;if(!v||!v.children)return null;const g=[...v.children],l=g.indexOf(w),d=[g[l+1],g[l-1]];for(const a of d)if(a&&a.tagName==="SCRIPT"&&F(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function U(w){const v=H(w);if(!v)return{};try{return JSON.parse(v.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function z(w){const v=w||(typeof document<"u"?document:null);if(!v)return[];const g=[];for(const l of W(v,"data-lattice-grid")){if(l.__lattice)continue;const d=U(l);g.push(l.tagName==="TABLE"?X(l,d):$(l,d))}return g}}),Le("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Q=K("packages/dom/src/createGrid.js"),F=Q.createGrid,B=K("packages/dom/src/hydrate.js"),$=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),H=W.createLocalViewStorage,U=K("packages/core/src/index.js"),z=U.createHeadlessGrid,w=U.registerModules,v=U.setLicence,g=U.version,l=U.getVersion,d=U.serialiseState,a=U.restoreState,n=U.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 U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),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}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const i=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return i.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return i.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return i.branchFor}});const f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const u=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return u.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return u.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return u.layoutState}});const o=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return o.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return o.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return o.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 h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.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 j=Object.freeze({createGrid:F,createHeadlessGrid:z,defaults:n,registerModules:w,setLicence:v,version:g,autoInit:X,hydrateTable:$,serialiseState:d,restoreState:a,createLocalViewStorage:H}),x=j}),Le("packages/modules/shared/adapter.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return z}});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","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","validation:failed","validation:cleared","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"]),F=Object.freeze({sort:(w,v)=>w.sort.set(v||[]),filters:(w,v)=>w.filters.set(v||null),quickFilter:(w,v)=>{if(v&&typeof v=="object"){w.filters.quick(v.text||"",{mode:v.mode});return}w.filters.quick(typeof v=="string"?v:"")},selectedKeys:(w,v)=>w.selection.set(Array.isArray(v)?v:[])});function B(w){return`on${String(w).split(":").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join("")}`}function $(w){return String(w).replace(/:/g,"-")}const _=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function X(w){return Object.hasOwn(_,w)?_[w]:w}const W=Object.freeze(Object.fromEntries(Q.map(w=>[B(w),w])));function H(w){return Object.hasOwn(W,w)}function U(w){const v={},g={},l={};for(const[d,a]of Object.entries(w||{})){if(H(d)){l[d]=a;continue}if(Object.hasOwn(F,d)){g[d]=a;continue}v[d]=a}return{config:v,imperative:g,handlers:l}}function z(w){const v=w.createGrid;if(typeof v!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const g=U(w.props||{}),l=v(w.element,{...g.config});let d=g.handlers,a=g.config,n={};const t=f=>{if(!f||typeof f.type!="string")return;const u=d[B(f.type)];typeof u=="function"&&u(f)},r=l.on("*",t);for(const[f,u]of Object.entries(g.imperative))u!==void 0&&(F[f](l,u),n[f]=u);let i=!1;return{grid:l,update(f){if(i)return;const u=U(f||{});d=u.handlers;const o={};for(const[m,c]of Object.entries(u.config))Object.is(a[m],c)||(o[m]=c);for(const m of Object.keys(a))Object.hasOwn(u.config,m)||(o[m]=void 0);Object.keys(o).length&&l.setAll(o),a=u.config;for(const[m,c]of Object.entries(F)){const h=u.imperative[m];Object.is(n[m],h)||h===void 0&&!Object.hasOwn(n,m)||(c(l,h),n[m]=h)}},destroy(){i||(i=!0,r(),l.destroy())}}}}),Le("packages/modules/react/viewers.js",function(e,K){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return U}});const F=K("packages/core/src/internal/util.js").warnOnce,B=Object.freeze({kpi:Object.freeze(["tile:click","tile:dblclick","tile:contextmenu","node:toggle","change","tile:status"]),kanban:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:move","card:reverted","card:confirmed","selection:changed","column:collapse","card:add","drag:start","drag:end","swimlane:collapse","swimlane:reorder","column:reorder","filter:changed","sprint:changed","epic:changed","card:expand","card:drill","card:edit","card:sla","beforeMove","beforeAdd","beforeEdit","beforeLaneReorder","beforeColumnReorder","beforeColumnChange","move:cancelled","add:cancelled","edit:cancelled","laneReorder:cancelled","columnReorder:cancelled","columnChange:cancelled"]),tabs:Object.freeze(["beforeTabChange","tab:changed","tabChange:cancelled"]),calendar:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:mount","range:change","beforeMove","card:move"]),chart:Object.freeze(["click","hover","leave","draw","legend"]),gantt:Object.freeze(["schedule","error","history","columnResize"]),layout:Object.freeze(["layout:changed","window:moved","window:resized","window:closed","beforeWindowClose","windowClose:cancelled"]),router:Object.freeze(["metrics","fields:changed"])}),$=Object.freeze({kpi:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[])}),kanban:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),quickFilter:(z,w)=>z.setQuickFilter(typeof w=="string"?w:""),sprint:(z,w)=>z.setSprint(w),epic:(z,w)=>z.setEpic(w),loading:(z,w)=>z.setLoading(!!w),error:(z,w)=>z.setError(w??null)}),gantt:Object.freeze({tasks:(z,w)=>z.setTasks(Array.isArray(w)?w:[]),dependencies:(z,w)=>z.setDependencies(Array.isArray(w)?w:[])}),tabs:Object.freeze({active:(z,w)=>{typeof w=="string"&&z.activate(w)}}),calendar:Object.freeze({rows:(z,w)=>z.setRows(Array.isArray(w)?w:[]),view:(z,w)=>z.setView(w),date:(z,w)=>z.goTo(w),move:(z,w,v)=>z.move(w,v)}),chart:Object.freeze({}),layout:Object.freeze({})}),_=Object.freeze({chart:"update"});function X(z){return`on${String(z).split(":").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join("")}`}const W=Object.freeze(Object.fromEntries(Object.entries(B).map(([z,w])=>[z,Object.freeze(Object.fromEntries(w.map(v=>[X(v),v])))])));function H(z,w){const v=W[z]||{},g=$[z]||{},l={},d={},a={};for(const[n,t]of Object.entries(w||{})){if(Object.hasOwn(v,n)){a[n]=t;continue}if(Object.hasOwn(g,n)){d[n]=t,l[n]=t;continue}l[n]=t}return{config:l,live:d,handlers:a}}function U(z){const w=String(z.viewer),v=z.mount,g=z.name||w;if(typeof v!="function")throw new TypeError(`createViewerController needs a mount factory for "${w}"; pass the module's own factory in, e.g. { createKPI } from lattice-grid/modules/kpi.`);const l=H(w,z.props||{}),d=v(z.element,{...l.config});if(!d||typeof d!="object")throw new TypeError(`the ${g} factory returned no instance; nothing can be driven.`);let a=l.handlers,n=l.config;const t={...l.live},r=[];if(typeof d.on=="function")for(const o of B[w]||[]){const m=X(o),c=d.on(o,h=>{const s=a[m];typeof s=="function"&&s(h)});typeof c=="function"&&r.push(c)}const i=_[w],f=$[w]||{};let u=!1;return{instance:d,update(o){if(u)return;const m=H(w,o||{});a=m.handlers;const c={};for(const[s,p]of Object.entries(m.config))Object.is(n[s],p)||(c[s]=p);if(n=m.config,!Object.keys(c).length)return;const h=[];for(const s of Object.keys(c)){const p=f[s];if(p){p(d,c[s]),t[s]=c[s];continue}i&&typeof d[i]=="function"||h.push(s)}if(i&&typeof d[i]=="function"){const s={};for(const p of Object.keys(c))f[p]||(s[p]=c[p]);Object.keys(s).length&&d[i](s)}h.length&&F(`react.viewer.${w}.mountOnly.${h.join(".")}`,`${g}: ${h.map(s=>`\`${s}\``).join(", ")} changed, but ${g} takes ${h.length===1?"it":"them"} only when the viewer is created. Nothing was applied and the viewer was NOT rebuilt — rebuilding it silently would throw away scroll position, selection and expansion. Give the component a \`key\` that changes when this must take effect, so the rebuild is yours and visible, or drive the instance through the ref.`)},destroy(){if(!u){u=!0;for(const o of r)try{o()}catch{}r.length=0,typeof d.destroy=="function"&&d.destroy()}}}}}),Le("packages/modules/webcomponent/controller.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return a}});const F=K("packages/core/src/internal/util.js").warnOnce,B="lattice-",$="lattice-grid-element-styles",_=Object.freeze({theme:"theme",density:"density",locale:"locale","row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight","filter-row":"filterRow",selection:"selection",rows:"rows",columns:"columns"}),X=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),H=new Set(["rows","columns"]);function U(){return Object.keys(_)}function z(n){return B+String(n).replace(/:/g,"-")}function w(n,t){if(W.has(n))return t!==null&&t!=="false";if(t!==null){if(X.has(n)){const r=Number(t);return Number.isFinite(r)?r:void 0}if(H.has(n))try{return JSON.parse(t)}catch{return}return t}}function v(n){if(!n||!n.createElement||n.getElementById&&n.getElementById($))return;const t=n.createElement("style");t.setAttribute("id",$),t.appendChild(n.createTextNode(`lattice-grid{display:block}
|
|
58
58
|
`));const r=n.head||n.documentElement||null;r&&r.appendChild(t)}const g=new Set(["quickFilter","quickFilterText","sort","filters","selectedKeys"]);function l(n,t,r){let i;if(t==="quickFilter"||t==="quickFilterText"){if(!n.filters||typeof n.filters.quick!="function")return d(t);i=()=>n.filters.quick(r==null?"":String(r))}else if(t==="sort"){if(!n.sort||typeof n.sort.set!="function")return d(t);i=()=>n.sort.set(Array.isArray(r)?r:[])}else if(t==="filters"){if(!n.filters||typeof n.filters.set!="function")return d(t);i=()=>n.filters.set(r??{})}else{if(!n.selection||typeof n.selection.set!="function")return d(t);i=()=>n.selection.set(Array.isArray(r)?r:[])}i()}function d(n){F(`webcomponent.write:${n}`,`<lattice-grid>: \`${n}\` could not be written to the grid (it has no API for it), so it had no effect.`)}class a{#e;#t;#n=null;#r={};#o=null;#i=!1;#s=!1;constructor(t,r){this.#e=t,this.#t=r.createGrid}get grid(){return!this.#n&&this.#s&&this.settleCreate(),this.#n}get teardownPending(){return this.#i}config(){return{...this.#r}}configure(t){if(!(!t||typeof t!="object"))for(const[r,i]of Object.entries(t))this.#l(r,i)}attributeChanged(t,r){const i=_[t];if(!i)return;const f=w(i,r);f===void 0&&!W.has(i)||this.#l(i,f)}connect(){this.#i=!1,this.#s=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#s||this.#n)return;v(this.#e.ownerDocument||null);const t={},r=[];for(const[f,u]of Object.entries(this.#r))g.has(f)&&f!=="quickFilterText"?r.push([f,u]):t[f]=u;const i=this.#t(this.#e,t);this.#n=i;for(const[f,u]of r)l(i,f,u);this.#a(i)}disconnect(){this.#s=!1,this.#n&&(this.#i=!0,queueMicrotask(()=>this.settleTeardown()))}settleTeardown(){this.#i&&(this.#i=!1,this.destroy())}destroy(){this.#o&&(this.#o(),this.#o=null);const t=this.#n;this.#n=null,t&&typeof t.destroy=="function"&&t.destroy()}#l(t,r){if(this.#r[t]=r,!!this.#n){if(g.has(t)){l(this.#n,t,r);return}typeof this.#n.set=="function"&&this.#n.set(t,r)}}#a(t){!t||typeof t.on!="function"||(this.#o=t.on("*",r=>{const i=this.#e;if(!i||typeof i.dispatchEvent!="function")return;const f={...r};delete f.grid,i.dispatchEvent(this.#u(z(r.type),f))}))}#u(t,r){const i=globalThis.CustomEvent;return typeof i=="function"?new i(t,{detail:r,bubbles:!0,composed:!0}):{type:t,detail:r,bubbles:!0,composed:!0}}}}),Le("packages/modules/webcomponent/styles.js",function(e,K){"use strict";Object.defineProperty(e,"constructableStyleSheets",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isLatticeStyleNode",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"sheetText",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"latticeStyleNodes",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return g}});const Q=Symbol.for("lattice.webcomponent.styleMirror"),F=/--lattice-|\.lat-/,B=new WeakMap,$=new WeakMap;function _(){const l=globalThis.CSSStyleSheet;if(typeof l!="function")return!1;try{return typeof new l().replaceSync=="function"}catch{return!1}}function X(l){if(!l||typeof l.getAttribute!="function")return!1;const d=String(l.tagName||"").toLowerCase();if(d!=="style"&&d!=="link"||d==="link"&&!String(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const a=String(l.getAttribute("id")||"");if(a.startsWith("lattice")||a.startsWith("lat-")||l.hasAttribute&&l.hasAttribute("data-lattice"))return!0;if(d==="link"){const n=String(l.getAttribute("href")||"");return/lattice/i.test(n)?!0:F.test(W(l))}return F.test(String(l.textContent||""))}function W(l){if(String(l&&l.tagName||"").toLowerCase()==="style")return String(l.textContent||"");try{const a=l&&l.sheet;if(!a||!a.cssRules)return"";let n="";for(const t of a.cssRules)n+=`${t.cssText}
|
|
59
|
-
`;return n}catch{return""}}function H(l,d){const a=B.get(l);if(a)return a.sheet;const n=W(l);if(!n)return null;const t=d.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[Q]=!0;let i=null;const f=d.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(i=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),i.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>i&&i.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const d=l||globalThis.document;return!d||typeof d.querySelectorAll!="function"?[]:[...d.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const d=l.document||globalThis.document,a=d&&d.defaultView||globalThis,n=[];for(const t of z(d)){const r=H(t,a);r&&!n.includes(r)&&n.push(r)}return n}function v(l,d={}){const a=()=>{};if(!l||typeof l!="object")return a;const n=d.document||U(l);if(!n)return a;const t=n.defaultView||globalThis;let r=$.get(l);r||(r=new Map,$.set(l,r));const i=[],f=_(),u=s=>{if(r.has(s))return;const p=f?H(s,t):null;if(p){r.set(s,p);const A=l.adoptedStyleSheets||[];A.includes(p)||(l.adoptedStyleSheets=[...A,p]);return}if(String(s.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const b=n.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("href",s.getAttribute("href")||""),b.setAttribute("data-lattice","adopted"),l.appendChild(b),i.push(b),r.set(s,b)};for(const s of z(n))u(s);let o=null;const m=t.MutationObserver,c=n.head||n.documentElement;typeof m=="function"&&c&&(o=new m(s=>{for(const p of s)for(const b of p.addedNodes||[])X(b)&&u(b)}),o.observe(c,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const s=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=s.filter(b=>!p.has(b));for(const b of i)b.parentNode&&b.parentNode.removeChild(b);r.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const d=l.getRootNode();return!d||d.nodeType!==11||!d.host?null:v(d)}}),Le("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return le}});const F=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/modules/shared/adapter.js").aliasConfigKey,_=K("packages/modules/react/viewers.js"),X=_.VIEWER_EVENTS,W=_.viewerHandlerName,H=_.createViewerController,U=K("packages/modules/webcomponent/controller.js"),z=U.GridElementController,w=U.observedAttributeNames,v=U.domEventName,g=U.ATTRIBUTE_CONFIG,d=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,a="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ae=>{if("data"in ae){const se=ae.data;delete ae.data,se!=null&&ae.rows===void 0&&(ae.rows=se)}if("stacked"in ae){const se=ae.stacked;delete ae.stacked,se!=null&&ae.stack===void 0&&(ae.stack=se)}if("horizontal"in ae){const se=ae.horizontal;delete ae.horizontal,se&&ae.type==="bar"&&(ae.type="horizontalBar")}},kanban:ae=>{if(!("titleProperty"in ae))return;const se=ae.titleProperty;if(delete ae.titleProperty,typeof se!="string"||!se)return;const ee=ae.card&&typeof ae.card=="object"?ae.card:null;ee&&ee.title!==void 0||(ae.card={title:se,...ee||{}})},gantt:ae=>{if(!("scale"in ae))return;const se=ae.scale;if(delete ae.scale,se==null||se==="")return;const ee=ae.render&&typeof ae.render=="object"?{...ae.render}:{};ee.zoom===void 0&&(ee.zoom=se),ae.render=ee}}),i=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),calendar:Object.freeze({label:"lattice-calendar",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","card","header","colorMap","labels","renderCard"]),scalars:Object.freeze(["rowKey","view","date","startProperty","endProperty","allDayProperty","firstDay","locale","timeZone","colorProperty","eventOrder","dayMaxEvents","readonly","ariaLabel"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),o=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function c(ae){if(ae==null)return;if(ae===""||ae==="true")return!0;if(ae==="false")return!1;const se=String(ae).trim();if(se.startsWith("[")||se.startsWith("{"))try{return JSON.parse(se)}catch{return ae}return se!==""&&Number.isFinite(Number(se))?Number(se):ae}function h(ae,se){const ee={},ie=ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[];for(const ce of ie){if(f.has(ce)||u.has(ce)||se&&se.has(ce)||ce.startsWith("data-")||ce.startsWith("aria-"))continue;const he=c(ae.getAttribute(ce));he!==void 0&&(ee[s(ce)]=he)}return ee}function s(ae){const se=$(ae);return se!==ae||!ae.includes("-")?se:ae.replace(/-([a-z0-9])/g,(ee,ie)=>ie.toUpperCase())}function p(ae){return ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[]}function b(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(s(ee));return se}function A(){const ae=new Map,se=new Set;return{publish(ee,ie){const ce=ee||a;ie?ae.set(ce,ie):ae.delete(ce);for(const he of[...se])he()},get(ee){return ae.get(ee||a)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function k(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:A(),get router(){return ee},attach(he,ge,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,ge,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function y(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[o])return se[o];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let ce=m.get(ie);return ce||(ce=k(),m.set(ie,ce)),ce}function S(ae,se,ee){const ie=se&&typeof se=="object"?se:{},ce=ee&&typeof ee=="object"?ee:{};for(const[he,ge]of Object.entries(ie))Object.is(ce[he],ge)||ae.filters.where(he,typeof ge=="function"?ge:null);for(const he of Object.keys(ce))Object.hasOwn(ie,he)||ae.filters.where(he,null)}function R(ae,se){if(!Object.hasOwn(ae,se))return;const ee=ae[se];delete ae[se],ae[se]=ee}const j=new Set(["instance","config","grid","gridName","router"]);function x(ae,se){let ee=Object.getPrototypeOf(ae);for(;ee;){const ie=Object.getOwnPropertyDescriptor(ee,se);if(ie)return typeof ie.get=="function";ee=Object.getPrototypeOf(ee)}return!1}function E(ae,se){if(!se||j.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(x(ae,se)){ee&&R(ae,se);return}const ie=ee?ee.value:void 0;ee&&delete ae[se],Object.defineProperty(ae,se,{get(){return this.__props[se]},set(ce){this.__write(se,ce)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function T(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||j.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(E(ae,ee),se=!0)}return se}function L(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,ce={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,ce):{type:se,...ce})}function P(ae){const se=ae.viewer,ee=i[se],ie=ae.label||ee.label,ce=ae.mount,he=X[se]||[];class ge extends ae.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const ye of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ye);T(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ye,Ae){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ye,Ae):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ye){this.__write("grid",ye)}get gridName(){const ye=this.__props.gridName;if(typeof ye=="string")return ye;const Ae=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Ae===null?void 0:Ae}set gridName(ye){this.__write("gridName",ye)}get config(){return{...this.__props}}set config(ye){if(!(!ye||typeof ye!="object")){for(const[Ae,pe]of Object.entries(ye))this.__props[Ae]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ye=d(this);ye&&this.__release.push(ye);const Ae=y(this);this.__scope=Ae,ee.fromContext&&this.__release.push(Ae.grids.subscribe(()=>this.__settle()));const pe=globalThis.MutationObserver;if(typeof pe=="function"){const we=new pe(()=>this.__settle());we.observe(this,{attributes:!0}),this.__release.push(()=>we.disconnect())}}T(this);for(const ye of b(this))E(this,ye);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const ye of this.__release.splice(0))try{ye()}catch{}this.__tearDown()}}__write(ye,Ae){this.__props[ye]=Ae,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ee.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const ye=this.__scope;return ye?ye.grids.get(this.gridName):null}__resolve(){const ye={...h(this,this.__ownAttributes),...this.__props};if(delete ye.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ye[ee.fromContext]=pe:delete ye[ee.fromContext]}const Ae=r[se];Ae&&Ae(ye);for(const pe of he)ye[W(pe)]=we=>L(this,v(pe),we);return ye}__settle(){if(!this.__connected)return;T(this);const ye=this.__resolve(),Ae=ee.fromContext&&ye[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Ae)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ye[we]===void 0||ye[we]===null)return;if(ee.fromContext&&!Ae&&ye.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:ce,element:this,props:ye,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=Ae,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ye)}__tearDown(){const ye=this.__controller;this.__controller=null,this.__builtAgainst=null,ye&&(L(this,"destroyed",{instance:ye.instance}),ye.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(ge.prototype,Ee,{get(){return this.__props[Ee]},set(ye){this.__write(Ee,ye)},configurable:!0,enumerable:!0});return ge}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function I(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function C(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=I();return se?P({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function O(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=I();return se?P({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function N(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=I();return se?P({viewer:"kanban",Base:se,mount:(ee,ie)=>ae.createKanban(ee,ie)}):null}function G(ae){D(ae&&ae.createCalendar,"createLatticeCalendarElement","createCalendar");const se=I();return se?P({viewer:"calendar",Base:se,mount:(ee,ie)=>ae.createCalendar(ee,ie)}):null}function q(ae){D(ae&&ae.createGantt,"createLatticeGanttElement","createGantt");const se=I();return se?P({viewer:"gantt",Base:se,mount:(ee,ie)=>ae.createGantt({...ie,element:ee})}):null}function Z(ae){D(ae&&ae.createLayout,"createLatticeLayoutElement","createLayout");const se=I();return se?P({viewer:"layout",Base:se,mount:(ee,ie)=>ae.createLayout(ee,ie)}):null}function J(ae){D(ae&&ae.createTabs,"createLatticeTabsElement","createTabs");const se=I();return se?P({viewer:"tabs",Base:se,mount:(ie,ce)=>{const he=new Map,ge=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const Ae of ge)Ae.parentNode===ie&&he.set(Ae.getAttribute("data-tab"),Ae);const ye=(Array.isArray(ce.tabs)&&ce.tabs.length?ce.tabs:[...he.keys()].map(Ae=>({id:Ae,label:he.get(Ae).getAttribute("data-label")||Ae}))).map(Ae=>{const pe=Ae,we=he.get(pe.id);return we?{...pe,view:be=>{const Ne=we.content.cloneNode(!0),$e=[...Ne.childNodes];return be.appendChild(Ne),{destroy(){for(const Ve of $e)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...ce,tabs:ye,createGrid:ae.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ae){D(ae&&ae.createDataRouter,"createLatticeRouterElement","createDataRouter");const se=I();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(ce){!ce||typeof ce!="object"||(this.__config={...this.__config,...ce},this.__scope&&this.__scope.router&&F("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const ce=h(this);this.__scope=k({createDataRouter:ae.createDataRouter,config:{...ce,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const ce=this.__scope;if(this.__scope=null,this[o]=null,!ce)return;const he=ce.router;ce.destroy(),he&&L(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,ce,he)=>{if(typeof ce!="function")return;const ge=he();ge&&(se[ie]=ge)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>C({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>O({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>N({createKanban:ae.createKanban})),ee("LatticeCalendarElement",ae.createCalendar,()=>G({createCalendar:ae.createCalendar})),ee("LatticeGanttElement",ae.createGantt,()=>q({createGantt:ae.createGantt})),ee("LatticeLayoutElement",ae.createLayout,()=>Z({createLayout:ae.createLayout})),ee("LatticeTabsElement",ae.createTabs,()=>J({createTabs:ae.createTabs,createGrid:ae.createGrid})),ee("LatticeRouterElement",ae.createDataRouter,()=>te({createDataRouter:ae.createDataRouter})),se}function oe(ae={}){const se=globalThis.customElements,ee={};if(!se||typeof se.define!="function")return ee;const ie=typeof ae.prefix=="string"?ae.prefix:n,ce=ne(ae),he={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeCalendarElement:t.calendar,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[ge,Ee]of Object.entries(ce)){const ye=ie+he[ge],Ae=se.get?se.get(ye):void 0;if(Ae){ee[ye]=Ae;continue}se.define(ye,Ee),ee[ye]=Ee}return ee}function le(ae){const se=I();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=a;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const ce of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,ce)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ce){this.__controller.configure({rows:ce})}get columns(){return this.__controller.config().columns}set columns(ce){this.__controller.configure({columns:ce})}get config(){return this.__controller.config()}set config(ce){this.__controller.configure(ce)}get predicates(){return this.__predicates}set predicates(ce){const he=this.__published?this.__controller.grid:null;he&&S(he,ce,this.__predicates),this.__predicates=ce}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ce){if(Object.is(ce,this.__rowUpdates))return;this.__rowUpdates=ce;const he=this.__published?this.__controller.grid:null;he&&ce&&he.rows.apply(ce)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ce=d(this);ce&&this.__release.push(ce),this.__scope=y(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ce,he,ge){this.__controller.attributeChanged(ce,ge)}__publish(){if(!this.__connected||this.__published)return;const ce=this.__controller.grid;if(!ce)return;this.__published=!0,this.__predicates&&S(ce,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||a;const ge=this.__scope;ge&&ge.grids.publish(this.__publishedAs,ce);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(ge&&Ee!==null){const ye=this.getAttribute("route-options");ge.attach(ce,c(Ee),ye===null?{}:c(ye))}this.__rowUpdates&&ce.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:ce})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ce=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const ge of this.__release.splice(0))try{ge()}catch{}ce&&he&&(L(this,"grid-destroyed",{grid:ce}),he.detach(ce),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const ie of Object.values(g))Object.getOwnPropertyDescriptor(ee.prototype,ie)||ie in se.prototype||Object.defineProperty(ee.prototype,ie,{get(){return this.__controller.config()[ie]},set(ce){this.__controller.configure({[ie]:ce})},configurable:!0,enumerable:!0});return ee}}),Le("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=K("packages/dom/src/index.js"),F=Q.createGrid,B=K("packages/modules/webcomponent/elements.js"),$=B.gridElementClass,_=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return _.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return _.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return _.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return _.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return B.createLatticeCalendarElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const X=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return X.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return X.latticeStyleSheets}});const W=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return W.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return W.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return W.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return W.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return Q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return Q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return Q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return Q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return Q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return Q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q.createPushdownSource}});const U="lattice-grid";function z(g=F){return $(g)}function w(g={}){const l=globalThis.customElements,d=g.tagName||U;if(!l||typeof l.define!="function")return null;const a=l.get?l.get(d):void 0;if(a)return a;const n=z(g.createGrid||F);return n?(l.define(d,n),n):null}w();const v=w});try{Ln("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 Pn=Ln("packages/modules/webcomponent/index.js");if(typeof module=="object"&&module.exports)module.exports=Pn;else if(typeof define=="function"&&define.amd)define(function(){return Pn});else{var mr=_n.LatticeGrid||(_n.LatticeGrid={});for(var Fn in Pn)Fn!=="default"&&(mr[Fn]=Pn[Fn])}})(typeof globalThis<"u"?globalThis:this);
|
|
59
|
+
`;return n}catch{return""}}function H(l,d){const a=B.get(l);if(a)return a.sheet;const n=W(l);if(!n)return null;const t=d.CSSStyleSheet,r=new t;try{r.replaceSync(n)}catch{return null}r[Q]=!0;let i=null;const f=d.MutationObserver;return typeof f=="function"&&String(l.tagName).toLowerCase()==="style"&&(i=new f(()=>{try{r.replaceSync(String(l.textContent||""))}catch{}}),i.observe(l,{childList:!0,characterData:!0,subtree:!0})),B.set(l,{sheet:r,stop:()=>i&&i.disconnect()}),r}function U(l){return l?l.nodeType===9?l:l.ownerDocument||globalThis.document||null:globalThis.document||null}function z(l){const d=l||globalThis.document;return!d||typeof d.querySelectorAll!="function"?[]:[...d.querySelectorAll("style,link[rel]")].filter(X)}function w(l={}){if(!_())return[];const d=l.document||globalThis.document,a=d&&d.defaultView||globalThis,n=[];for(const t of z(d)){const r=H(t,a);r&&!n.includes(r)&&n.push(r)}return n}function v(l,d={}){const a=()=>{};if(!l||typeof l!="object")return a;const n=d.document||U(l);if(!n)return a;const t=n.defaultView||globalThis;let r=$.get(l);r||(r=new Map,$.set(l,r));const i=[],f=_(),u=s=>{if(r.has(s))return;const p=f?H(s,t):null;if(p){r.set(s,p);const A=l.adoptedStyleSheets||[];A.includes(p)||(l.adoptedStyleSheets=[...A,p]);return}if(String(s.tagName).toLowerCase()!=="link"||typeof l.appendChild!="function")return;const b=n.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("href",s.getAttribute("href")||""),b.setAttribute("data-lattice","adopted"),l.appendChild(b),i.push(b),r.set(s,b)};for(const s of z(n))u(s);let o=null;const m=t.MutationObserver,c=n.head||n.documentElement;typeof m=="function"&&c&&(o=new m(s=>{for(const p of s)for(const b of p.addedNodes||[])X(b)&&u(b)}),o.observe(c,{childList:!0}));let h=!1;return()=>{if(h)return;h=!0,o&&o.disconnect();const s=l.adoptedStyleSheets||[],p=new Set([...r.values()]);l.adoptedStyleSheets=s.filter(b=>!p.has(b));for(const b of i)b.parentNode&&b.parentNode.removeChild(b);r.clear()}}function g(l){if(!l||typeof l.getRootNode!="function"||typeof l.getAttribute=="function"&&String(l.getAttribute("lattice-styles")||"")==="off")return null;const d=l.getRootNode();return!d||d.nodeType!==11||!d.host?null:v(d)}}),Le("packages/modules/webcomponent/elements.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return le}});const F=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/modules/shared/adapter.js").aliasConfigKey,_=K("packages/modules/react/viewers.js"),X=_.VIEWER_EVENTS,W=_.viewerHandlerName,H=_.createViewerController,U=K("packages/modules/webcomponent/controller.js"),z=U.GridElementController,w=U.observedAttributeNames,v=U.domEventName,g=U.ATTRIBUTE_CONFIG,d=K("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,a="default",n="lattice-",t=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",calendar:"calendar",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),r=Object.freeze({chart:ae=>{if("data"in ae){const se=ae.data;delete ae.data,se!=null&&ae.rows===void 0&&(ae.rows=se)}if("stacked"in ae){const se=ae.stacked;delete ae.stacked,se!=null&&ae.stack===void 0&&(ae.stack=se)}if("horizontal"in ae){const se=ae.horizontal;delete ae.horizontal,se&&ae.type==="bar"&&(ae.type="horizontalBar")}},kanban:ae=>{if(!("titleProperty"in ae))return;const se=ae.titleProperty;if(delete ae.titleProperty,typeof se!="string"||!se)return;const ee=ae.card&&typeof ae.card=="object"?ae.card:null;ee&&ee.title!==void 0||(ae.card={title:se,...ee||{}})},gantt:ae=>{if(!("scale"in ae))return;const se=ae.scale;if(delete ae.scale,se==null||se==="")return;const ee=ae.render&&typeof ae.render=="object"?{...ae.render}:{};ee.zoom===void 0&&(ee.zoom=se),ae.render=ee}}),i=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),calendar:Object.freeze({label:"lattice-calendar",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","card","header","colorMap","labels","renderCard"]),scalars:Object.freeze(["rowKey","view","date","startProperty","endProperty","allDayProperty","firstDay","locale","timeZone","colorProperty","eventOrder","dayMaxEvents","readonly","ariaLabel"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),f=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),u=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),o=Symbol.for("lattice.webcomponent.routerScope"),m=new WeakMap;function c(ae){if(ae==null)return;if(ae===""||ae==="true")return!0;if(ae==="false")return!1;const se=String(ae).trim();if(se.startsWith("[")||se.startsWith("{"))try{return JSON.parse(se)}catch{return ae}return se!==""&&Number.isFinite(Number(se))?Number(se):ae}function h(ae,se){const ee={},ie=ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[];for(const ce of ie){if(f.has(ce)||u.has(ce)||se&&se.has(ce)||ce.startsWith("data-")||ce.startsWith("aria-"))continue;const he=c(ae.getAttribute(ce));he!==void 0&&(ee[s(ce)]=he)}return ee}function s(ae){const se=$(ae);return se!==ae||!ae.includes("-")?se:ae.replace(/-([a-z0-9])/g,(ee,ie)=>ie.toUpperCase())}function p(ae){return ae&&typeof ae.getAttributeNames=="function"?ae.getAttributeNames():[]}function b(ae){const se=[];for(const ee of p(ae))f.has(ee)||u.has(ee)||ee.startsWith("data-")||ee.startsWith("aria-")||se.push(s(ee));return se}function A(){const ae=new Map,se=new Set;return{publish(ee,ie){const ce=ee||a;ie?ae.set(ce,ie):ae.delete(ce);for(const he of[...se])he()},get(ee){return ae.get(ee||a)||null},names(){return[...ae.keys()]},subscribe(ee){return se.add(ee),()=>{se.delete(ee)}}}}function k(ae={}){const se=typeof ae.createDataRouter=="function"?ae.createDataRouter:null;let ee=null,ie=!1;return{grids:A(),get router(){return ee},attach(he,ge,Ee){ie||!se||(ee||(ee=se(ae.config||{})),ee.attach(he,ge,Ee||{}))},detach(he){if(!(ie||!ee))try{ee.detach(he)}catch{}},destroy(){ie=!0;const he=ee;ee=null,he&&he.destroy()}}}function y(ae){let se=ae&&ae.parentNode||null;for(;se;){if(se[o])return se[o];se=se.parentNode||se.host||null}const ie=(ae&&typeof ae.getRootNode=="function"?ae.getRootNode():ae&&ae.ownerDocument||null)||globalThis.document||globalThis;let ce=m.get(ie);return ce||(ce=k(),m.set(ie,ce)),ce}function S(ae,se,ee){const ie=se&&typeof se=="object"?se:{},ce=ee&&typeof ee=="object"?ee:{};for(const[he,ge]of Object.entries(ie))Object.is(ce[he],ge)||ae.filters.where(he,typeof ge=="function"?ge:null);for(const he of Object.keys(ce))Object.hasOwn(ie,he)||ae.filters.where(he,null)}function R(ae,se){if(!Object.hasOwn(ae,se))return;const ee=ae[se];delete ae[se],ae[se]=ee}const j=new Set(["instance","config","grid","gridName","router"]);function x(ae,se){let ee=Object.getPrototypeOf(ae);for(;ee;){const ie=Object.getOwnPropertyDescriptor(ee,se);if(ie)return typeof ie.get=="function";ee=Object.getPrototypeOf(ee)}return!1}function E(ae,se){if(!se||j.has(se)||se.startsWith("__"))return;const ee=Object.getOwnPropertyDescriptor(ae,se);if(ee&&typeof ee.get=="function")return;if(x(ae,se)){ee&&R(ae,se);return}const ie=ee?ee.value:void 0;ee&&delete ae[se],Object.defineProperty(ae,se,{get(){return this.__props[se]},set(ce){this.__write(se,ce)},configurable:!0,enumerable:!0}),ee&&(ae[se]=ie)}function T(ae){let se=!1;for(const ee of Object.getOwnPropertyNames(ae)){if(ee.startsWith("__")||j.has(ee))continue;const ie=Object.getOwnPropertyDescriptor(ae,ee);!ie||typeof ie.get=="function"||!ie.enumerable||(E(ae,ee),se=!0)}return se}function L(ae,se,ee){if(!ae||typeof ae.dispatchEvent!="function")return;const ie=globalThis.CustomEvent,ce={detail:ee,bubbles:!0,composed:!0};ae.dispatchEvent(typeof ie=="function"?new ie(se,ce):{type:se,...ce})}function P(ae){const se=ae.viewer,ee=i[se],ie=ae.label||ee.label,ce=ae.mount,he=X[se]||[];class ge extends ae.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const ye of["config","grid","gridName",...ee.properties,...ee.scalars])R(this,ye);T(this)}get instance(){return this.__controller?this.__controller.instance:null}move(ye,Ae){const pe=this.instance;return pe&&typeof pe.move=="function"?pe.move(ye,Ae):Promise.resolve(!1)}get grid(){return this.__props.grid}set grid(ye){this.__write("grid",ye)}get gridName(){const ye=this.__props.gridName;if(typeof ye=="string")return ye;const Ae=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Ae===null?void 0:Ae}set gridName(ye){this.__write("gridName",ye)}get config(){return{...this.__props}}set config(ye){if(!(!ye||typeof ye!="object")){for(const[Ae,pe]of Object.entries(ye))this.__props[Ae]=pe;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const ye=d(this);ye&&this.__release.push(ye);const Ae=y(this);this.__scope=Ae,ee.fromContext&&this.__release.push(Ae.grids.subscribe(()=>this.__settle()));const pe=globalThis.MutationObserver;if(typeof pe=="function"){const we=new pe(()=>this.__settle());we.observe(this,{attributes:!0}),this.__release.push(()=>we.disconnect())}}T(this);for(const ye of b(this))E(this,ye);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const ye of this.__release.splice(0))try{ye()}catch{}this.__tearDown()}}__write(ye,Ae){this.__props[ye]=Ae,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!ee.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const ye=this.__scope;return ye?ye.grids.get(this.gridName):null}__resolve(){const ye={...h(this,this.__ownAttributes),...this.__props};if(delete ye.gridName,ee.fromContext){const pe=this.__boundGrid();pe?ye[ee.fromContext]=pe:delete ye[ee.fromContext]}const Ae=r[se];Ae&&Ae(ye);for(const pe of he)ye[W(pe)]=we=>L(this,v(pe),we);return ye}__settle(){if(!this.__connected)return;T(this);const ye=this.__resolve(),Ae=ee.fromContext&&ye[ee.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Ae)&&this.__tearDown(),!this.__controller){for(const we of ee.requires)if(ye[we]===void 0||ye[we]===null)return;if(ee.fromContext&&!Ae&&ye.rows===void 0)return;const pe=new Set(p(this));this.__controller=H({viewer:se,mount:ce,element:this,props:ye,name:ie});for(const we of p(this))pe.has(we)||this.__ownAttributes.add(we);this.__builtAgainst=Ae,L(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(ye)}__tearDown(){const ye=this.__controller;this.__controller=null,this.__builtAgainst=null,ye&&(L(this,"destroyed",{instance:ye.instance}),ye.destroy())}}for(const Ee of[...ee.properties,...ee.scalars])Ee in ae.Base.prototype||Object.defineProperty(ge.prototype,Ee,{get(){return this.__props[Ee]},set(ye){this.__write(Ee,ye)},configurable:!0,enumerable:!0});return ge}function D(ae,se,ee){if(typeof ae!="function")throw new TypeError(`${se} needs ${ee}: ${se}({ ${ee} }).`)}function I(){const ae=globalThis.HTMLElement;return typeof ae=="function"?ae:null}function C(ae){D(ae&&ae.createKPI,"createLatticeKPIElement","createKPI");const se=I();return se?P({viewer:"kpi",Base:se,mount:(ee,ie)=>ae.createKPI(ee,ie)}):null}function O(ae){D(ae&&ae.createChart,"createLatticeChartElement","createChart");const se=I();return se?P({viewer:"chart",Base:se,mount:(ee,ie)=>ae.createChart({...ie,container:ee})}):null}function N(ae){D(ae&&ae.createKanban,"createLatticeKanbanElement","createKanban");const se=I();return se?P({viewer:"kanban",Base:se,mount:(ee,ie)=>ae.createKanban(ee,ie)}):null}function G(ae){D(ae&&ae.createCalendar,"createLatticeCalendarElement","createCalendar");const se=I();return se?P({viewer:"calendar",Base:se,mount:(ee,ie)=>ae.createCalendar(ee,ie)}):null}function q(ae){D(ae&&ae.createGantt,"createLatticeGanttElement","createGantt");const se=I();return se?P({viewer:"gantt",Base:se,mount:(ee,ie)=>ae.createGantt({...ie,element:ee})}):null}function Z(ae){D(ae&&ae.createLayout,"createLatticeLayoutElement","createLayout");const se=I();return se?P({viewer:"layout",Base:se,mount:(ee,ie)=>ae.createLayout(ee,ie)}):null}function J(ae){D(ae&&ae.createTabs,"createLatticeTabsElement","createTabs");const se=I();return se?P({viewer:"tabs",Base:se,mount:(ie,ce)=>{const he=new Map,ge=typeof ie.querySelectorAll=="function"?[...ie.querySelectorAll("template[data-tab]")]:[];for(const Ae of ge)Ae.parentNode===ie&&he.set(Ae.getAttribute("data-tab"),Ae);const ye=(Array.isArray(ce.tabs)&&ce.tabs.length?ce.tabs:[...he.keys()].map(Ae=>({id:Ae,label:he.get(Ae).getAttribute("data-label")||Ae}))).map(Ae=>{const pe=Ae,we=he.get(pe.id);return we?{...pe,view:be=>{const Ne=we.content.cloneNode(!0),$e=[...Ne.childNodes];return be.appendChild(Ne),{destroy(){for(const Ve of $e)Ve.parentNode&&Ve.parentNode.removeChild(Ve)}}}}:pe});return ae.createTabs(ie,{...ce,tabs:ye,createGrid:ae.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ae){D(ae&&ae.createDataRouter,"createLatticeRouterElement","createDataRouter");const se=I();if(!se)return null;class ee extends se{__scope=null;__config={};constructor(){super(),R(this,"config")}get config(){return{...this.__config}}set config(ce){!ce||typeof ce!="object"||(this.__config={...this.__config,...ce},this.__scope&&this.__scope.router&&F("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const ce=h(this);this.__scope=k({createDataRouter:ae.createDataRouter,config:{...ce,...this.__config}}),this[o]=this.__scope}disconnectedCallback(){const ce=this.__scope;if(this.__scope=null,this[o]=null,!ce)return;const he=ce.router;ce.destroy(),he&&L(this,"destroyed",{instance:he})}}return ee}function ne(ae={}){const se={},ee=(ie,ce,he)=>{if(typeof ce!="function")return;const ge=he();ge&&(se[ie]=ge)};return ee("LatticeGridElement",ae.createGrid,()=>le(ae.createGrid)),ee("LatticeKPIElement",ae.createKPI,()=>C({createKPI:ae.createKPI})),ee("LatticeChartElement",ae.createChart,()=>O({createChart:ae.createChart})),ee("LatticeKanbanElement",ae.createKanban,()=>N({createKanban:ae.createKanban})),ee("LatticeCalendarElement",ae.createCalendar,()=>G({createCalendar:ae.createCalendar})),ee("LatticeGanttElement",ae.createGantt,()=>q({createGantt:ae.createGantt})),ee("LatticeLayoutElement",ae.createLayout,()=>Z({createLayout:ae.createLayout})),ee("LatticeTabsElement",ae.createTabs,()=>J({createTabs:ae.createTabs,createGrid:ae.createGrid})),ee("LatticeRouterElement",ae.createDataRouter,()=>te({createDataRouter:ae.createDataRouter})),se}function oe(ae={}){const se=globalThis.customElements,ee={};if(!se||typeof se.define!="function")return ee;const ie=typeof ae.prefix=="string"?ae.prefix:n,ce=ne(ae),he={LatticeGridElement:t.grid,LatticeKPIElement:t.kpi,LatticeChartElement:t.chart,LatticeKanbanElement:t.kanban,LatticeCalendarElement:t.calendar,LatticeGanttElement:t.gantt,LatticeLayoutElement:t.layout,LatticeTabsElement:t.tabs,LatticeRouterElement:t.router};for(const[ge,Ee]of Object.entries(ce)){const ye=ie+he[ge],Ae=se.get?se.get(ye):void 0;if(Ae){ee[ye]=Ae;continue}se.define(ye,Ee),ee[ye]=Ee}return ee}function le(ae){const se=I();if(!se)return null;class ee extends se{static get observedAttributes(){return w()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=a;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new z(this,{createGrid:ae});for(const ce of["rows","columns","config","predicates","rowUpdates",...Object.values(g)])R(this,ce)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(ce){this.__controller.configure({rows:ce})}get columns(){return this.__controller.config().columns}set columns(ce){this.__controller.configure({columns:ce})}get config(){return this.__controller.config()}set config(ce){this.__controller.configure(ce)}get predicates(){return this.__predicates}set predicates(ce){const he=this.__published?this.__controller.grid:null;he&&S(he,ce,this.__predicates),this.__predicates=ce}get rowUpdates(){return this.__rowUpdates}set rowUpdates(ce){if(Object.is(ce,this.__rowUpdates))return;this.__rowUpdates=ce;const he=this.__published?this.__controller.grid:null;he&&ce&&he.rows.apply(ce)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const ce=d(this);ce&&this.__release.push(ce),this.__scope=y(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(ce,he,ge){this.__controller.attributeChanged(ce,ge)}__publish(){if(!this.__connected||this.__published)return;const ce=this.__controller.grid;if(!ce)return;this.__published=!0,this.__predicates&&S(ce,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||a;const ge=this.__scope;ge&&ge.grids.publish(this.__publishedAs,ce);const Ee=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(ge&&Ee!==null){const ye=this.getAttribute("route-options");ge.attach(ce,c(Ee),ye===null?{}:c(ye))}this.__rowUpdates&&ce.rows.apply(this.__rowUpdates),L(this,"grid-ready",{grid:ce})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const ce=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const ge of this.__release.splice(0))try{ge()}catch{}ce&&he&&(L(this,"grid-destroyed",{grid:ce}),he.detach(ce),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const ie of Object.values(g))Object.getOwnPropertyDescriptor(ee.prototype,ie)||ie in se.prototype||Object.defineProperty(ee.prototype,ie,{get(){return this.__controller.config()[ie]},set(ce){this.__controller.configure({[ie]:ce})},configurable:!0,enumerable:!0});return ee}}),Le("packages/modules/webcomponent/index.js",function(e,K){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=K("packages/dom/src/index.js"),F=Q.createGrid,B=K("packages/modules/webcomponent/elements.js"),$=B.gridElementClass,_=K("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return _.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return _.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return _.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return _.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return _.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return B.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return B.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return B.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return B.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return B.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeCalendarElement",{enumerable:!0,get:function(){return B.createLatticeCalendarElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return B.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return B.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return B.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return B.createLatticeRouterElement}});const X=K("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return X.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return X.latticeStyleSheets}});const W=K("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return W.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return W.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return W.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return W.createViewerController}});const H=K("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return H.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return H.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return Q.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return Q.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return Q.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return Q.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return Q.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return Q.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return Q.createPushdownSource}});const U="lattice-grid";function z(g=F){return $(g)}function w(g={}){const l=globalThis.customElements,d=g.tagName||U;if(!l||typeof l.define!="function")return null;const a=l.get?l.get(d):void 0;if(a)return a;const n=z(g.createGrid||F);return n?(l.define(d,n),n):null}w();const v=w});try{Ln("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 Pn=Ln("packages/modules/webcomponent/index.js");if(typeof module=="object"&&module.exports)module.exports=Pn;else if(typeof define=="function"&&define.amd)define(function(){return Pn});else{var mr=_n.LatticeGrid||(_n.LatticeGrid={});for(var Fn in Pn)Fn!=="default"&&(mr[Fn]=Pn[Fn])}})(typeof globalThis<"u"?globalThis:this);
|
|
60
60
|
|
|
61
61
|
//# sourceMappingURL=webcomponent.min.js.map
|