@toclocoinc/lattice-grid 1.71.0 → 1.71.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +35 -11
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/charts.html +32 -8
- package/docs/api/data-router.html +1 -1
- package/docs/api/gantt.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +1 -1
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +23 -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/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-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-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-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-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-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-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-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-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/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +133 -133
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +133 -133
- package/modules/charts.min.js +133 -133
- package/modules/charts.min.js.map +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/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 +1 -1
- package/modules/gantt.esm.min.js +2 -2
- package/modules/gantt.min.cjs +2 -2
- package/modules/gantt.min.js +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 +8 -0
- package/modules/geo-europe-nuts.min.js +8 -0
- package/modules/geo-europe-nuts.min.js.map +6 -0
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +8 -0
- package/modules/geo-uk.min.js +8 -0
- package/modules/geo-uk.min.js.map +6 -0
- 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 +8 -0
- package/modules/geo-us-states.min.js +8 -0
- package/modules/geo-us-states.min.js.map +6 -0
- 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 +8 -0
- package/modules/geo-world-110m.min.js +8 -0
- package/modules/geo-world-110m.min.js.map +6 -0
- 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 +8 -0
- package/modules/geo-world-50m.min.js +8 -0
- package/modules/geo-world-50m.min.js.map +6 -0
- 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/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/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- 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.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
package/modules/htmx.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.71.
|
|
2
|
+
* Lattice Grid 1.71.1, htmx module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
(function(ir){"use strict";var Un=Object.create(null),Hn=Object.create(null);function ve(e,V){Un[e]=V}function Cn(e){var V=Hn[e];if(V)return V;var Z=Object.create(null);Hn[e]=Z;var N=Un[e];if(!N)throw new Error("[lattice] missing module: "+e);return N(Z,Cn),Z}ve("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Z="1.71.0";async function N(){return Z}const z="1.71.0",F=new Set,W=2e3;function _(re){if(F.add(re),F.size>W){const oe=F.values().next().value;oe!==void 0&&F.delete(oe)}}const U=[],B=500;function H(re,oe,ie){U.push({key:re,level:oe,message:ie.map(te=>typeof te=="string"?te:L(te)).join(" "),at:Date.now()}),U.length>B&&U.shift()}function L(re){if(re instanceof Error)return re.message;try{return JSON.stringify(re)}catch{return String(re)}}function k(){return U.map(re=>({...re}))}function S(re,...oe){F.has(re)||(_(re),H(re,"warn",oe),console.warn("[lattice]",...oe))}function y(re,...oe){F.has(re)||(_(re),H(re,"info",oe),console.info("[lattice]",...oe))}function u(){F.clear(),U.length=0}function o(re,oe){const ie=new Error(`[lattice] ${re}`);throw oe!==void 0&&(ie.cause=oe),ie}function r(re,oe){re||o(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(re){return re!==null&&typeof re=="object"&&!Array.isArray(re)}function i(re){return typeof re=="function"}function s(re){return re==null}function c(re){return re==null||re===""}function d(re){return typeof re!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(re))?!0:!!(re.prototype&&Object.getOwnPropertyNames(re.prototype).length>1)}const f=new Map;function h(re){let oe=f.get(re);if(oe)return oe;if(!re.includes("."))oe=ie=>ie?.[re];else{const ie=re.split("."),te=ie.length;oe=ce=>{let ue=ce;for(let ae=0;ae<te;ae++){if(ue==null)return;ue=ue[ie[ae]]}return ue}}return f.set(re,oe),oe}const g=new Map;function w(re){let oe=g.get(re);if(oe)return oe;if(!re.includes("."))oe=(ie,te)=>{ie!=null&&(ie[re]=te)};else{const ie=re.split("."),te=ie.length-1;oe=(ce,ue)=>{let ae=ce;for(let pe=0;pe<te;pe++){if(ae==null)return;const he=ie[pe];ae[he]==null&&(ae[he]={}),ae=ae[he]}ae!=null&&(ae[ie[te]]=ue)}}return g.set(re,oe),oe}function p(re,oe){return h(oe)(re)}function m(re,oe,ie){w(oe)(re,ie)}function b(re){return re?(re.includes(".")?re.slice(re.lastIndexOf(".")+1):re).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(/^./,ie=>ie.toUpperCase()):""}const v={"&":"&","<":"<",">":">",'"':""","'":"'"};function l(re){const oe=re==null?"":String(re);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,ie=>v[ie]):oe}function a(re){return String(re).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function O(re,oe,ie){if(re!==void 0)return re===!0?{enabled:!0,...ie}:re===!1?{enabled:!1}:n(re)?re:{[oe]:re,enabled:!0}}function T(re){return re==null?[]:Array.isArray(re)?re:[re]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(re,oe){if(!n(re))return n(oe)?{...oe}:oe;if(!n(oe))return oe===void 0?re:oe;const ie={...re};for(const te of Object.keys(oe)){if(A.has(te))continue;const ce=oe[te];ce!==void 0&&(ie[te]=n(ce)&&n(ie[te])?M(ie[te],ce):ce)}return ie}function C(re,oe){if(!n(re)||!n(oe)||re===oe)return oe;const ie=Object.create(Object.getPrototypeOf(re));return Object.assign(ie,re,oe),ie}class P{#e;#t=new Map;#n;constructor(oe=256,ie=null){this.#e=oe,this.#n=ie}get size(){return this.#t.size}get max(){return this.#e}set max(oe){this.#e=oe,this.#r()}has(oe){return this.#t.has(oe)}get(oe){const ie=this.#t;if(!ie.has(oe))return;const te=ie.get(oe);return ie.delete(oe),ie.set(oe,te),te}peek(oe){return this.#t.get(oe)}set(oe,ie){const te=this.#t;return te.has(oe)&&te.delete(oe),te.set(oe,ie),this.#r(),ie}delete(oe){const ie=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(ie,oe),ie}clear(){if(this.#n)for(const[oe,ie]of this.#t)this.#n(ie,oe);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const oe=this.#t;for(;oe.size>this.#e;){const ie=oe.keys().next().value,te=oe.get(ie);oe.delete(ie),this.#n&&this.#n(te,ie)}}}const x=new Map;function K(re,oe){const ie=`${re||""}|${oe?JSON.stringify(oe):""}`;let te=x.get(ie);return te||(te=new Intl.Collator(re||void 0,{numeric:!0,sensitivity:"variant",...oe}),x.set(ie,te)),te}function I(re,oe){if(re===oe)return 0;if(re==null)return 1;if(oe==null)return-1;if(typeof re=="number"&&typeof oe=="number")return Number.isNaN(re)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||re<oe?-1:re>oe?1:0;const ie=String(re),te=String(oe);return ie<te?-1:ie>te?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function E(re){return j?requestAnimationFrame(re):setTimeout(()=>re(D()),16)}function $(re){re!=null&&(j?cancelAnimationFrame(re):clearTimeout(re))}function q(re){let oe=null,ie=null;const te=()=>{oe=null;const ue=ie;ie=null,re(...ue||[])},ce=(...ue)=>{ie=ue,oe===null&&(oe=E(te))};return ce.cancel=()=>{$(oe),oe=null,ie=null},ce.flush=()=>{oe!==null&&($(oe),te())},ce}function X(re,oe){let ie=null,te=null;const ce=()=>{if(ie=null,te===null)return;const pe=te;te=null,re(...pe),ue()},ue=()=>{ie=setTimeout(ce,oe),typeof ie?.unref=="function"&&ie.unref()},ae=(...pe)=>{ie===null?(re(...pe),ue()):(te=pe,clearTimeout(ie),ue())};return ae.flush=()=>{if(ie!==null&&clearTimeout(ie),ie=null,te===null)return;const pe=te;te=null,re(...pe)},ae.cancel=()=>{ie!==null&&clearTimeout(ie),ie=null,te=null},ae.pending=()=>ie!==null||te!==null,ae}function Q(re,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(re,{timeout:oe}):setTimeout(()=>re({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function ne(re="l"){return`${re}${(++J).toString(36)}`}}),ve("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return O}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),_=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 U(T,A){const M=Number(T),C=Number(A);if(T!==null&&T!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const x=String(T??"").toLowerCase(),K=String(A??"").toLowerCase();return x<K?-1:x>K?1:0}function B(T){return T==null||T===""}function H(T,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){case"blank":return B(T);case"notBlank":return!B(T);case"true":return T===!0;case"false":return T===!1;default:break}if(B(T))return!1;switch(M){case"eq":return U(T,C)===0;case"ne":return U(T,C)!==0;case"gt":return U(T,C)>0;case"gte":return U(T,C)>=0;case"lt":return U(T,C)<0;case"lte":return U(T,C)<=0;case"between":return U(T,C)>=0&&U(T,P)<=0;case"outside":return U(T,C)<0||U(T,P)>0;case"contains":return String(T).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function L(T,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(J=>J+J).join(""):X;return[0,2,4].map(J=>parseInt(Q.slice(J,J+2),16)||0)},[P,x,K]=C(T),[I,D,j]=C(A),E=Math.max(0,Math.min(1,M)),$=(q,X)=>Math.round(q+(X-q)*E);return`#${[$(P,I),$(x,D),$(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(T){const A=[];for(const I of T||[]){if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():Number(I);Number.isFinite(D)&&A.push(D)}if(!A.length)return null;A.sort((I,D)=>I-D);let M=0,C=0,P=0;for(const I of A){M++;const D=I-C;C+=D/M,P+=D*(I-C)}const x=S(A,.25),K=S(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:S(A,.5),q1:x,q3:K,iqr:K-x,sorted:A}}function S(T,A){if(!T.length)return 0;const M=(T.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?T[C]:T[C]+(M-C)*(T[P]-T[C])}function y(T){for(const A of Array.isArray(T)?T:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function u(T,A){const M=Number(T.value),C=P=>S(A.sorted,P);switch(T.op){case"topPercent":{const P=o(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=o(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),x=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[x]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),x=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[x]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function o(T,A){const M=Number.isFinite(T)?T:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(T,A){if(T.from==="minmax")return{...T,min:A.min,max:A.max};if(T.from==="quantile")return{...T,min:S(A.sorted,o(Number(T.low),5)),max:S(A.sorted,o(Number(T.high),95))};if(T.from==="stddev"){const M=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return T}function t(T,A){const M=Array.isArray(T)?T:[];return!A||!A.n?M.map(C=>C&&y([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=u(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(T,A){const M=Number.isFinite(Number(T.min))?Number(T.min):void 0,C=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(M!==void 0&&C!==void 0)return{...T,min:M,max:C};if(T.from==="quantile")return{...T,min:M??S(A.sorted,o(Number(T.low),5)),max:C??S(A.sorted,o(Number(T.high),95))};if(T.from==="stddev"){const P=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...T,min:M??A.min,max:C??A.max}}function i(T,A){if(Array.isArray(T.thresholds))return T;const M=s(T),C=[];for(let P=1;P<M;P++)C.push(S(A.sorted,P/M));return{...T,thresholds:C}}function s(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const A=p[T.set];return A?A.length:3}function c(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function d(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function f(T,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function h(T,A){const M="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 C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const x=P<T?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${x}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),w=Object.freeze([d("#d13438"),d("#f5a623"),d("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:w,ratings:Object.freeze([1,2,3,4,5].map(T=>h(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?c(String(C)):String(C));const A=T.set||"arrows";if(A==="ratings"){const C=s(T),P=[];for(let x=1;x<=C;x++)P.push(c(h(x,C)));return P}const M=p[A];return M?M.map(c):(z(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(c))}function v(T){const A=Number(T.min),C=Number(T.max)-A,P=T.colour||T.color||"#5b9bd5",x=T.negativeColour||T.negativeColor||"#d13438",K=T.direction==="rtl"?"left":"right",I=j=>Math.max(0,Math.min(1,(j-A)/C))*100,D=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(B(j))return null;const E=Number(j);if(!Number.isFinite(E)||!C)return null;const $=I(E),q=Math.min($,D),X=Math.max($,D),Q=E>=0?P:x;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function l(T){const A=b(T),M=T.reverse?[...A].reverse():A,C=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(T.size))?Number(T.size):16,x=T.set==="ratings"?P*s(T):P;return K=>{if(B(K))return null;const I=Number(K);if(!Number.isFinite(I))return null;let D=0;for(const E of C)I>=E&&D++;const j=M[Math.min(D,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${x}px ${P}px`,paddingLeft:`${x+4}px`}:null}}function a(T){const A=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],M=Number(T.min),C=Number(T.max),P=C-M,x=A.length-1,K=[];for(let D=0;D<=x;D++)K.push(x?D/x:0);const I=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(A.length%2===0)z("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(I)&&P&&I>Math.min(M,C)&&I<Math.max(M,C)){const D=x/2,j=Math.max(0,Math.min(1,(I-M)/P));for(let E=0;E<=x;E++)K[E]=E<=D?D?E/D*j:j:j+(E-D)/(x-D)*(1-j)}else Number.isFinite(I)&&z("formatting.scale.mid.range",`a scale's "mid" (${I}) is outside its min..max range, so it was ignored.`);return D=>{const j=Number(D);if(!Number.isFinite(j)||!P)return null;const E=Math.max(0,Math.min(1,(j-M)/P));let $=0;for(;$<x-1&&E>K[$+1];)$++;const q=K[$+1]-K[$],X=q>0?(E-K[$])/q:0;return{background:L(A[$],A[$+1],Math.max(0,Math.min(1,X)))}}}function O(T,A=null){const M=y(T)?t(T,A):T,C=(Array.isArray(M)?M:[]).filter(x=>x&&typeof x=="object");if(!C.length)return()=>null;const P=C.map(x=>x.scale?{scale:a(x.scale),enabled:x.enabled!==!1}:x.dataBar?{scale:v(x.dataBar),enabled:x.enabled!==!1}:x.iconSet?{scale:l(x.iconSet),enabled:x.enabled!==!1}:{when:x.when,style:x.style,stop:x.stopIfTrue!==!1,enabled:x.enabled!==!1});return x=>{const K=x?x.value:void 0;let I=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const E=D.scale(K);E&&(I={...I||{},...E});continue}if(!H(K,D.when))continue;const j=N(D.style)?D.style(x):D.style;if(j&&(I={...I||{},...j}),D.stop)break}return I}}}),ve("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const Z="num",N="str",z="ref",F="name",W="op",_="end",U=["<=",">=","<>","!="],B="+-*/^%(),<>=";class H extends Error{constructor(s,c){super(s),this.name="FormulaError",this.at=c}}function L(i){const s=[];let c=0;for(;c<i.length;){const d=i[c];if(d===" "||d===" "||d===`
|
|
6
|
+
(function(ir){"use strict";var Un=Object.create(null),Hn=Object.create(null);function ve(e,V){Un[e]=V}function Cn(e){var V=Hn[e];if(V)return V;var Z=Object.create(null);Hn[e]=Z;var N=Un[e];if(!N)throw new Error("[lattice] missing module: "+e);return N(Z,Cn),Z}ve("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return ne}});const Z="1.71.1";async function N(){return Z}const z="1.71.1",F=new Set,W=2e3;function _(re){if(F.add(re),F.size>W){const oe=F.values().next().value;oe!==void 0&&F.delete(oe)}}const U=[],B=500;function H(re,oe,ie){U.push({key:re,level:oe,message:ie.map(te=>typeof te=="string"?te:L(te)).join(" "),at:Date.now()}),U.length>B&&U.shift()}function L(re){if(re instanceof Error)return re.message;try{return JSON.stringify(re)}catch{return String(re)}}function k(){return U.map(re=>({...re}))}function S(re,...oe){F.has(re)||(_(re),H(re,"warn",oe),console.warn("[lattice]",...oe))}function y(re,...oe){F.has(re)||(_(re),H(re,"info",oe),console.info("[lattice]",...oe))}function u(){F.clear(),U.length=0}function o(re,oe){const ie=new Error(`[lattice] ${re}`);throw oe!==void 0&&(ie.cause=oe),ie}function r(re,oe){re||o(oe)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(re){return re!==null&&typeof re=="object"&&!Array.isArray(re)}function i(re){return typeof re=="function"}function s(re){return re==null}function c(re){return re==null||re===""}function d(re){return typeof re!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(re))?!0:!!(re.prototype&&Object.getOwnPropertyNames(re.prototype).length>1)}const f=new Map;function h(re){let oe=f.get(re);if(oe)return oe;if(!re.includes("."))oe=ie=>ie?.[re];else{const ie=re.split("."),te=ie.length;oe=ce=>{let ue=ce;for(let ae=0;ae<te;ae++){if(ue==null)return;ue=ue[ie[ae]]}return ue}}return f.set(re,oe),oe}const g=new Map;function w(re){let oe=g.get(re);if(oe)return oe;if(!re.includes("."))oe=(ie,te)=>{ie!=null&&(ie[re]=te)};else{const ie=re.split("."),te=ie.length-1;oe=(ce,ue)=>{let ae=ce;for(let pe=0;pe<te;pe++){if(ae==null)return;const he=ie[pe];ae[he]==null&&(ae[he]={}),ae=ae[he]}ae!=null&&(ae[ie[te]]=ue)}}return g.set(re,oe),oe}function p(re,oe){return h(oe)(re)}function m(re,oe,ie){w(oe)(re,ie)}function b(re){return re?(re.includes(".")?re.slice(re.lastIndexOf(".")+1):re).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(/^./,ie=>ie.toUpperCase()):""}const v={"&":"&","<":"<",">":">",'"':""","'":"'"};function l(re){const oe=re==null?"":String(re);return/[&<>"']/.test(oe)?oe.replace(/[&<>"']/g,ie=>v[ie]):oe}function a(re){return String(re).replace(/\w\S*/g,oe=>oe[0].toUpperCase()+oe.slice(1).toLowerCase())}function O(re,oe,ie){if(re!==void 0)return re===!0?{enabled:!0,...ie}:re===!1?{enabled:!1}:n(re)?re:{[oe]:re,enabled:!0}}function T(re){return re==null?[]:Array.isArray(re)?re:[re]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(re,oe){if(!n(re))return n(oe)?{...oe}:oe;if(!n(oe))return oe===void 0?re:oe;const ie={...re};for(const te of Object.keys(oe)){if(A.has(te))continue;const ce=oe[te];ce!==void 0&&(ie[te]=n(ce)&&n(ie[te])?M(ie[te],ce):ce)}return ie}function C(re,oe){if(!n(re)||!n(oe)||re===oe)return oe;const ie=Object.create(Object.getPrototypeOf(re));return Object.assign(ie,re,oe),ie}class P{#e;#t=new Map;#n;constructor(oe=256,ie=null){this.#e=oe,this.#n=ie}get size(){return this.#t.size}get max(){return this.#e}set max(oe){this.#e=oe,this.#r()}has(oe){return this.#t.has(oe)}get(oe){const ie=this.#t;if(!ie.has(oe))return;const te=ie.get(oe);return ie.delete(oe),ie.set(oe,te),te}peek(oe){return this.#t.get(oe)}set(oe,ie){const te=this.#t;return te.has(oe)&&te.delete(oe),te.set(oe,ie),this.#r(),ie}delete(oe){const ie=this.#t.get(oe);return this.#t.delete(oe)&&this.#n&&this.#n(ie,oe),ie}clear(){if(this.#n)for(const[oe,ie]of this.#t)this.#n(ie,oe);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const oe=this.#t;for(;oe.size>this.#e;){const ie=oe.keys().next().value,te=oe.get(ie);oe.delete(ie),this.#n&&this.#n(te,ie)}}}const x=new Map;function K(re,oe){const ie=`${re||""}|${oe?JSON.stringify(oe):""}`;let te=x.get(ie);return te||(te=new Intl.Collator(re||void 0,{numeric:!0,sensitivity:"variant",...oe}),x.set(ie,te)),te}function I(re,oe){if(re===oe)return 0;if(re==null)return 1;if(oe==null)return-1;if(typeof re=="number"&&typeof oe=="number")return Number.isNaN(re)?Number.isNaN(oe)?0:1:Number.isNaN(oe)||re<oe?-1:re>oe?1:0;const ie=String(re),te=String(oe);return ie<te?-1:ie>te?1:0}function D(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function E(re){return j?requestAnimationFrame(re):setTimeout(()=>re(D()),16)}function $(re){re!=null&&(j?cancelAnimationFrame(re):clearTimeout(re))}function q(re){let oe=null,ie=null;const te=()=>{oe=null;const ue=ie;ie=null,re(...ue||[])},ce=(...ue)=>{ie=ue,oe===null&&(oe=E(te))};return ce.cancel=()=>{$(oe),oe=null,ie=null},ce.flush=()=>{oe!==null&&($(oe),te())},ce}function X(re,oe){let ie=null,te=null;const ce=()=>{if(ie=null,te===null)return;const pe=te;te=null,re(...pe),ue()},ue=()=>{ie=setTimeout(ce,oe),typeof ie?.unref=="function"&&ie.unref()},ae=(...pe)=>{ie===null?(re(...pe),ue()):(te=pe,clearTimeout(ie),ue())};return ae.flush=()=>{if(ie!==null&&clearTimeout(ie),ie=null,te===null)return;const pe=te;te=null,re(...pe)},ae.cancel=()=>{ie!==null&&clearTimeout(ie),ie=null,te=null},ae.pending=()=>ie!==null||te!==null,ae}function Q(re,oe=50){return typeof requestIdleCallback=="function"?requestIdleCallback(re,{timeout:oe}):setTimeout(()=>re({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function ne(re="l"){return`${re}${(++J).toString(36)}`}}),ve("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return O}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),_=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 U(T,A){const M=Number(T),C=Number(A);if(T!==null&&T!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const x=String(T??"").toLowerCase(),K=String(A??"").toLowerCase();return x<K?-1:x>K?1:0}function B(T){return T==null||T===""}function H(T,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){case"blank":return B(T);case"notBlank":return!B(T);case"true":return T===!0;case"false":return T===!1;default:break}if(B(T))return!1;switch(M){case"eq":return U(T,C)===0;case"ne":return U(T,C)!==0;case"gt":return U(T,C)>0;case"gte":return U(T,C)>=0;case"lt":return U(T,C)<0;case"lte":return U(T,C)<=0;case"between":return U(T,C)>=0&&U(T,P)<=0;case"outside":return U(T,C)<0||U(T,P)>0;case"contains":return String(T).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function L(T,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(J=>J+J).join(""):X;return[0,2,4].map(J=>parseInt(Q.slice(J,J+2),16)||0)},[P,x,K]=C(T),[I,D,j]=C(A),E=Math.max(0,Math.min(1,M)),$=(q,X)=>Math.round(q+(X-q)*E);return`#${[$(P,I),$(x,D),$(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(T){const A=[];for(const I of T||[]){if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():Number(I);Number.isFinite(D)&&A.push(D)}if(!A.length)return null;A.sort((I,D)=>I-D);let M=0,C=0,P=0;for(const I of A){M++;const D=I-C;C+=D/M,P+=D*(I-C)}const x=S(A,.25),K=S(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:S(A,.5),q1:x,q3:K,iqr:K-x,sorted:A}}function S(T,A){if(!T.length)return 0;const M=(T.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?T[C]:T[C]+(M-C)*(T[P]-T[C])}function y(T){for(const A of Array.isArray(T)?T:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function u(T,A){const M=Number(T.value),C=P=>S(A.sorted,P);switch(T.op){case"topPercent":{const P=o(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=o(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),x=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[x]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),x=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[x]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function o(T,A){const M=Number.isFinite(T)?T:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(T,A){if(T.from==="minmax")return{...T,min:A.min,max:A.max};if(T.from==="quantile")return{...T,min:S(A.sorted,o(Number(T.low),5)),max:S(A.sorted,o(Number(T.high),95))};if(T.from==="stddev"){const M=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return T}function t(T,A){const M=Array.isArray(T)?T:[];return!A||!A.n?M.map(C=>C&&y([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=u(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(T,A){const M=Number.isFinite(Number(T.min))?Number(T.min):void 0,C=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(M!==void 0&&C!==void 0)return{...T,min:M,max:C};if(T.from==="quantile")return{...T,min:M??S(A.sorted,o(Number(T.low),5)),max:C??S(A.sorted,o(Number(T.high),95))};if(T.from==="stddev"){const P=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...T,min:M??A.min,max:C??A.max}}function i(T,A){if(Array.isArray(T.thresholds))return T;const M=s(T),C=[];for(let P=1;P<M;P++)C.push(S(A.sorted,P/M));return{...T,thresholds:C}}function s(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const A=p[T.set];return A?A.length:3}function c(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function d(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function f(T,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function h(T,A){const M="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 C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const x=P<T?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${x}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),w=Object.freeze([d("#d13438"),d("#f5a623"),d("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:w,ratings:Object.freeze([1,2,3,4,5].map(T=>h(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?c(String(C)):String(C));const A=T.set||"arrows";if(A==="ratings"){const C=s(T),P=[];for(let x=1;x<=C;x++)P.push(c(h(x,C)));return P}const M=p[A];return M?M.map(c):(z(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(c))}function v(T){const A=Number(T.min),C=Number(T.max)-A,P=T.colour||T.color||"#5b9bd5",x=T.negativeColour||T.negativeColor||"#d13438",K=T.direction==="rtl"?"left":"right",I=j=>Math.max(0,Math.min(1,(j-A)/C))*100,D=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(B(j))return null;const E=Number(j);if(!Number.isFinite(E)||!C)return null;const $=I(E),q=Math.min($,D),X=Math.max($,D),Q=E>=0?P:x;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function l(T){const A=b(T),M=T.reverse?[...A].reverse():A,C=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(T.size))?Number(T.size):16,x=T.set==="ratings"?P*s(T):P;return K=>{if(B(K))return null;const I=Number(K);if(!Number.isFinite(I))return null;let D=0;for(const E of C)I>=E&&D++;const j=M[Math.min(D,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${x}px ${P}px`,paddingLeft:`${x+4}px`}:null}}function a(T){const A=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],M=Number(T.min),C=Number(T.max),P=C-M,x=A.length-1,K=[];for(let D=0;D<=x;D++)K.push(x?D/x:0);const I=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(A.length%2===0)z("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(I)&&P&&I>Math.min(M,C)&&I<Math.max(M,C)){const D=x/2,j=Math.max(0,Math.min(1,(I-M)/P));for(let E=0;E<=x;E++)K[E]=E<=D?D?E/D*j:j:j+(E-D)/(x-D)*(1-j)}else Number.isFinite(I)&&z("formatting.scale.mid.range",`a scale's "mid" (${I}) is outside its min..max range, so it was ignored.`);return D=>{const j=Number(D);if(!Number.isFinite(j)||!P)return null;const E=Math.max(0,Math.min(1,(j-M)/P));let $=0;for(;$<x-1&&E>K[$+1];)$++;const q=K[$+1]-K[$],X=q>0?(E-K[$])/q:0;return{background:L(A[$],A[$+1],Math.max(0,Math.min(1,X)))}}}function O(T,A=null){const M=y(T)?t(T,A):T,C=(Array.isArray(M)?M:[]).filter(x=>x&&typeof x=="object");if(!C.length)return()=>null;const P=C.map(x=>x.scale?{scale:a(x.scale),enabled:x.enabled!==!1}:x.dataBar?{scale:v(x.dataBar),enabled:x.enabled!==!1}:x.iconSet?{scale:l(x.iconSet),enabled:x.enabled!==!1}:{when:x.when,style:x.style,stop:x.stopIfTrue!==!1,enabled:x.enabled!==!1});return x=>{const K=x?x.value:void 0;let I=null;for(const D of P){if(!D.enabled)continue;if(D.scale){const E=D.scale(K);E&&(I={...I||{},...E});continue}if(!H(K,D.when))continue;const j=N(D.style)?D.style(x):D.style;if(j&&(I={...I||{},...j}),D.stop)break}return I}}}),ve("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const Z="num",N="str",z="ref",F="name",W="op",_="end",U=["<=",">=","<>","!="],B="+-*/^%(),<>=";class H extends Error{constructor(s,c){super(s),this.name="FormulaError",this.at=c}}function L(i){const s=[];let c=0;for(;c<i.length;){const d=i[c];if(d===" "||d===" "||d===`
|
|
7
7
|
`||d==="\r"){c++;continue}if(d>="0"&&d<="9"){c=S(i,c,s);continue}if(d==="."&&i[c+1]>="0"&&i[c+1]<="9"){c=S(i,c,s);continue}if(d==='"'||d==="'"){c=y(i,c,s);continue}if(d==="["){const h=i.indexOf("]",c+1);if(h<0)throw new H("a [column reference] was opened and never closed",c);s.push({kind:z,value:i.slice(c+1,h).trim(),at:c}),c=h+1;continue}if(k(d)){c=u(i,c,s);continue}const f=i.slice(c,c+2);if(U.includes(f)){s.push({kind:W,value:f==="!="?"<>":f,at:c}),c+=2;continue}if(B.includes(d)){s.push({kind:W,value:d,at:c}),c++;continue}throw new H(`unexpected character ${JSON.stringify(d)}`,c)}return s.push({kind:_,value:null,at:i.length}),s}function k(i){return/[A-Za-z_À-]/.test(i)}function S(i,s,c){let d=s,f=!1;for(;d<i.length;){const h=i[d];if(h>="0"&&h<="9"){d++;continue}if(h==="."&&!f){f=!0,d++;continue}if((h==="e"||h==="E")&&/[0-9+-]/.test(i[d+1]||"")){for(d+=2;d<i.length&&i[d]>="0"&&i[d]<="9";)d++;break}break}return c.push({kind:Z,value:Number(i.slice(s,d)),at:s}),d}function y(i,s,c){const d=i[s];let f=s+1,h="";for(;f<i.length;){if(i[f]===d){if(i[f+1]===d){h+=d,f+=2;continue}return c.push({kind:N,value:h,at:s}),f+1}h+=i[f],f++}throw new H("a string was opened and never closed",s)}function u(i,s,c){let d=s;for(;d<i.length&&/[A-Za-z0-9_.À-]/.test(i[d]);)d++;const f=i.slice(s,d);let h=d;for(;h<i.length&&i[h]===" ";)h++;return c.push({kind:i[h]==="("?F:z,value:f,at:s}),d}const o={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function r(i){const s=String(i??"").replace(/^\s*=/,"");if(!s.trim())throw new H("the formula is empty");const c=L(s);let d=0;const f=()=>c[d],h=()=>c[d++],g=a=>{const O=f();if(O.kind!==W||O.value!==a)throw new H(`expected ${JSON.stringify(a)}`,O.at);d++},w=a=>{let O=p();for(;;){const T=f();if(T.kind!==W)break;const A=o[T.value];if(!A||A<a)break;d++;const M=w(T.value==="^"?A:A+1);O={kind:"bin",op:T.value,left:O,right:M}}return O},p=()=>{const a=f();return a.kind===W&&(a.value==="-"||a.value==="+")?(d++,{kind:"unary",op:a.value,arg:p()}):m()},m=()=>{let a=b();for(;f().kind===W&&f().value==="%";)d++,a={kind:"unary",op:"%",arg:a};return a},b=()=>{const a=h();if(a.kind===Z)return{kind:"num",value:a.value};if(a.kind===N)return{kind:"str",value:a.value};if(a.kind===z)return{kind:"ref",name:a.value};if(a.kind===F){g("(");const O=[];if(!(f().kind===W&&f().value===")"))for(;;){if(O.push(w(1)),f().kind===W&&f().value===","){d++;continue}break}return g(")"),{kind:"call",name:String(a.value).toUpperCase(),args:O}}if(a.kind===W&&a.value==="("){const O=w(1);return g(")"),O}throw a.kind===_?new H("the formula ends unexpectedly",a.at):new H(`unexpected ${JSON.stringify(a.value)}`,a.at)},v=w(1),l=f();if(l.kind!==_)throw new H(`unexpected ${JSON.stringify(l.value)}: is an operator missing?`,l.at);return v}function t(i){const s=new Set,c=d=>{if(!(!d||typeof d!="object")){if(d.kind==="ref"){s.add(String(d.name));return}if(d.kind==="bin"){c(d.left),c(d.right);return}if(d.kind==="unary"){c(d.arg);return}if(d.kind==="call")for(const f of d.args)c(f)}};return c(i),[...s]}function n(i){return typeof i=="string"&&/^\s*=/.test(i)&&i.trim()!=="="}}),ve("packages/core/src/formula/evaluate.js",function(e,V){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/formula/parse.js").FormulaError;function z(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const u=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new N(`${JSON.stringify(y)} is not a number`);return u}function F(y){return y==null?"":String(y)}function W(y){if(typeof y=="boolean")return y;if(y==null||y==="")return!1;if(typeof y=="number")return y!==0;const u=String(y).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function _(y){const u=[];for(const o of y){if(Array.isArray(o)){for(const r of o)r!=null&&r!==""&&u.push(z(r));continue}o==null||o===""||u.push(z(o))}return u}function U(y,u){const o=10**u,r=y*o;return Math.sign(r)*Math.round(Math.abs(r)+Number.EPSILON*Math.abs(r))/o}function B(y,u){if(!y.length)return 0;const o=y.slice().sort((i,s)=>i-s),r=(o.length-1)*Math.min(1,Math.max(0,u)),t=Math.floor(r),n=Math.ceil(r);return t===n?o[t]:o[t]+(r-t)*(o[n]-o[t])}function H(y,u){let o=0,r=0,t=0;for(const i of y){o++;const s=i-r;r+=s/o,t+=s*(i-r)}const n=u?o-1:o;return n>0?Math.sqrt(t/n):0}const L={SUM:y=>_(y).reduce((u,o)=>u+o,0),AVERAGE:y=>{const u=_(y);return u.length?u.reduce((o,r)=>o+r,0)/u.length:0},MIN:y=>{const u=_(y);return u.length?Math.min(...u):0},MAX:y=>{const u=_(y);return u.length?Math.max(...u):0},COUNT:y=>_(y).length,PRODUCT:y=>_(y).reduce((u,o)=>u*o,1),ROUND:y=>U(z(y[0]),y.length>1?z(y[1]):0),ROUNDDOWN:y=>{const u=10**(y.length>1?z(y[1]):0),o=z(y[0])*u;return(o<0?Math.ceil(o):Math.floor(o))/u},ROUNDUP:y=>{const u=10**(y.length>1?z(y[1]):0),o=z(y[0])*u;return(o<0?Math.floor(o):Math.ceil(o))/u},ABS:y=>Math.abs(z(y[0])),FLOOR:y=>Math.floor(z(y[0])),CEILING:y=>Math.ceil(z(y[0])),SQRT:y=>Math.sqrt(z(y[0])),POWER:y=>z(y[0])**z(y[1]),MOD:y=>{const u=z(y[1]);if(u===0)throw new N("MOD by zero");return(z(y[0])%u+u)%u},IF:y=>W(y[0])?y[1]:y.length>2?y[2]:!1,AND:y=>y.every(W),OR:y=>y.some(W),NOT:y=>!W(y[0]),COALESCE:y=>y.find(u=>u!=null&&u!=="")??null,CONCAT:y=>y.map(F).join(""),LEN:y=>F(y[0]).length,UPPER:y=>F(y[0]).toUpperCase(),LOWER:y=>F(y[0]).toLowerCase(),TRIM:y=>F(y[0]).trim(),LEFT:y=>F(y[0]).slice(0,y.length>1?z(y[1]):1),RIGHT:y=>{const u=y.length>1?z(y[1]):1;return u<=0?"":F(y[0]).slice(-u)},MEDIAN:y=>B(_(y),.5),PERCENTILE:y=>{const u=z(y[y.length-1]);return B(_(y.slice(0,-1)),u>1?u/100:u)},QUARTILE1:y=>B(_(y),.25),QUARTILE3:y=>B(_(y),.75),STDEV:y=>H(_(y),!0),STDEVP:y=>H(_(y),!1),VAR:y=>{const u=H(_(y),!0);return u*u},VARP:y=>{const u=H(_(y),!1);return u*u},COUNTDISTINCT:y=>{const u=new Set;for(const o of y){const r=Array.isArray(o)?o:[o];for(const t of r)t!=null&&t!==""&&u.add(t)}return u.size},IQR:y=>{const u=_(y);return B(u,.75)-B(u,.25)}};L.AVG=L.AVERAGE,L.CEIL=L.CEILING,L.POW=L.POWER,L.STDEVS=L.STDEV,L.PERCENTILEINC=L.PERCENTILE;function k(y,u){const o=Number(y),r=Number(u);if(y!==null&&y!==""&&u!==null&&u!==""&&Number.isFinite(o)&&Number.isFinite(r))return o<r?-1:o>r?1:0;const n=F(y).toLowerCase(),i=F(u).toLowerCase();return n<i?-1:n>i?1:0}function S(y,u={}){const o=typeof u.lookup=="function"?u.lookup:null,r=u.functions?{...L,...u.functions}:L,t=n=>{switch(n.kind){case"num":return n.value;case"str":return n.value;case"ref":{if(!o)throw new N(`there is no column called ${JSON.stringify(n.name)} here`);const i=o(String(n.name));if(i===void 0)throw new N(`there is no column called ${JSON.stringify(n.name)}`);return i}case"unary":{if(n.op==="%")return z(t(n.arg))/100;const i=z(t(n.arg));return n.op==="-"?-i:i}case"bin":{const i=n.op;if(i==="=")return k(t(n.left),t(n.right))===0;if(i==="<>")return k(t(n.left),t(n.right))!==0;if(i==="<")return k(t(n.left),t(n.right))<0;if(i==="<=")return k(t(n.left),t(n.right))<=0;if(i===">")return k(t(n.left),t(n.right))>0;if(i===">=")return k(t(n.left),t(n.right))>=0;const s=z(t(n.left)),c=z(t(n.right));if(i==="+")return s+c;if(i==="-")return s-c;if(i==="*")return s*c;if(i==="^")return s**c;if(i==="/"){if(c===0)throw new N("division by zero");return s/c}throw new N(`unknown operator ${JSON.stringify(i)}`)}case"call":{const i=r[n.name];if(typeof i!="function")throw new N(`there is no function called ${n.name}`);return i(n.args.map(t),u)}default:throw new N("the formula could not be read")}};return t(y)}}),ve("packages/core/src/formula/index.js",function(e,V){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/formula/parse.js"),N=Z.parseFormula,z=Z.referencesOf,F=Z.looksLikeFormula,W=Z.FormulaError,_=Z.tokenise,U=V("packages/core/src/formula/evaluate.js"),B=U.evaluateAst,H=U.FUNCTIONS;function L(S){const{grid:y,row:u,data:o}=S||{},r=c=>String(c).toLowerCase().replace(/[\s_-]/g,""),t=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],n=y&&y.permissions,i=n&&typeof n.isReadable=="function"?c=>n.isReadable(c):()=>!0,s=new Set;for(const c of t)i(c)||(s.add(r(c.id)),c.field&&s.add(r(c.field)),c.title&&s.add(r(c.title)));return c=>{const d=r(c);if(s.has(d))throw new W(`"${c}" cannot be read`);for(const f of t)if(r(f.id)===d||f.field&&r(f.field)===d||f.title&&r(f.title)===d)return u&&y.rows&&typeof y.rows.value=="function"?y.rows.value(u.key,f.id):o?o[f.field||f.id]:void 0;if(o&&typeof o=="object"){for(const f of Object.keys(o))if(r(f)===d){if(!i(f))throw new W(`"${c}" cannot be read`);return o[f]}}}}function k(S,y={}){try{const u=N(S);return{ok:!0,value:B(u,{lookup:L(y),functions:y.formulaFunctions}),references:z(u)}}catch(u){return{ok:!1,error:u instanceof W?u.message:"the formula could not be read",at:u instanceof W?u.at:void 0}}}}),ve("packages/core/src/defaults.js",function(e,V){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return B}});const Z=V("packages/core/src/internal/util.js"),N=Z.isObject,z=Z.merge,F=Z.warnOnce;let W=null;function _(H){if(Array.isArray(H))return H.map(_);if(!N(H)||Object.getPrototypeOf(H)!==Object.prototype&&Object.getPrototypeOf(H)!==null)return H;const L={};for(const[k,S]of Object.entries(H))L[k]=_(S);return L}function U(H){return H===void 0?_(W??{}):H===null?(W=null,{}):N(H)?(W=_(H),_(W)):(F("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(H)?"an array":typeof H}. The call was ignored and the defaults are unchanged.`),_(W??{}))}function B(H){return W===null?H:z(_(W),H)}}),ve("packages/core/src/events/names.js",function(e,V){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return z}});const Z=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","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"]),N=new Set(Z);function z(F){return F==="*"||N.has(F)}}),ve("packages/core/src/events/bus.js",function(e,V){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return u}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.uid,F=Z.DEV,_=V("packages/core/src/events/names.js").isKnownEvent,U="*";function B(o,r){!F||_(r)||N(`bus.unknown:${r}`,`${o}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const H=new Set(["api","user","init","ai"]),L=new WeakMap;function k(o){let r=L.get(o);return r||(r=z("h"),L.set(o,r)),r}function S(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(o){if(!o||typeof o!="object")return{};const r={};for(const[t,n]of Object.entries(o))t!=="grid"&&(n==null?r[t]=String(n):Array.isArray(n)?r[t]=`[${n.length}]`:typeof n=="object"?r[t]=n.key?`row ${n.key}`:"{…}":typeof n=="function"?r[t]="[function]":r[t]=String(n).slice(0,60));return r}class u{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#a=!1;#s=0;constructor(r=null){this.#i=r}attach(r){this.#i=r}get grid(){return this.#i}get destroyed(){return this.#a}on(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};B("on",r);let n=this.#e.get(r);return n||(n=[],this.#e.set(r,n)),n.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};B("once",r);const n=i=>{this.off(r,t),t(i)};return this.#o.set(t,n),this.on(r,n)}off(r,t){if(t===void 0){this.#e.delete(r);return}const n=this.#e.get(r);if(!n)return;const i=this.#o.get(t),s=i&&n.includes(i)?i:t,c=n.indexOf(s);c>=0&&n.splice(c,1),i&&s===i&&this.#o.delete(t),n.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),n=r===U?null:this.#e.get(U);return(t?t.length:0)+(n?n.length:0)}#l(r,t,n,i,s){this.#n.push({type:r,origin:t,listeners:(i?i.length:0)+(s?s.length:0),payload:y(n),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,n]of this.#e)r[t]=n.length;return r}emit(r,t,n){const i=n??(t&&t.origin),s=H.has(i)?i:"api",c={...t||null,type:r,origin:s,grid:this.#i};if(this.#a)return c;const d=this.#e.get(r),f=r===U?void 0:this.#e.get(U);if(this.#t&&this.#l(r,s,t,d,f),!d&&!f)return c;const h=this.#t?S():0;this.#s++;try{d&&this.#u(d.slice(),c,r),f&&this.#u(f.slice(),c,U)}finally{this.#s--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=S()-h)}return c}emitBefore(r,t,n){const i=n??(t&&t.origin),s=H.has(i)?i:"user";let c=!1,d=null;const f=b=>{c=!0,b!=null&&d===null&&(d=String(b))},h={...t||null,type:r,origin:s,grid:this.#i,get defaultPrevented(){return c},get reason(){return d},preventDefault(b){f(b)}};if(this.#a)return!0;const g=this.#e.get(r);this.#t&&this.#l(r,s,t,g,void 0);const w=g?g.slice():[];if(w.length===0)return!0;const p=()=>(c&&d===null&&(d="prevented"),c&&t&&typeof t=="object"&&(t.reason=d),!c),m=[];for(const b of w)try{const v=b(h);v&&typeof v.then=="function"?m.push(v):v===!1&&f("prevented")}catch(v){f("error"),N(`bus.beforeThrow:${r}:${k(b)}`,`a '${r}' before-handler threw; the action was cancelled.`,v)}return m.length===0?p():Promise.allSettled(m).then(b=>{for(const v of b)v.status==="rejected"?(f("error"),N(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,v.reason)):v.value===!1&&f("prevented");return p()})}#u(r,t,n){for(let i=0;i<r.length;i++)try{r[i](t)}catch(s){N(`bus.throw:${n}:${k(r[i])}`,`a '${n}' handler threw; other handlers were unaffected.`,s)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#a=!0,this.#i=null}}}),ve("packages/core/src/registry/licence.js",function(e,V){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const N=V("packages/core/src/internal/util.js").warnOnce,z="lattice-grid",F=1,W="LG1",_=64,U="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",H=(()=>{const T=new Int16Array(128).fill(-1);for(let A=0;A<B.length;A++)T[B.charCodeAt(A)]=A;return T[43]=62,T[47]=63,T})();function L(T){if(typeof T!="string")return null;let A="";for(let I=0;I<T.length;I++){const D=T.charCodeAt(I);if(D!==61){if(D>127||H[D]<0)return null;A+=T[I]}}const M=A.length;if(M%4===1)return null;const C=new Uint8Array(Math.floor(M*3/4));let P=0,x=0,K=0;for(let I=0;I<M;I++)P=P<<6|H[A.charCodeAt(I)],x+=6,x>=8&&(x-=8,C[K++]=P>>x&255);return K===C.length?C:C.subarray(0,K)}function k(T){let A="",M=0;for(;M+2<T.length;M+=3){const P=T[M]<<16|T[M+1]<<8|T[M+2];A+=B[P>>18&63]+B[P>>12&63]+B[P>>6&63]+B[P&63]}const C=T.length-M;if(C===1){const P=T[M]<<16;A+=B[P>>18&63]+B[P>>12&63]}else if(C===2){const P=T[M]<<16|T[M+1]<<8;A+=B[P>>18&63]+B[P>>12&63]+B[P>>6&63]}return A}function S(T){const A=new Uint8Array(T.length);for(let M=0;M<T.length;M++)A[M]=T.charCodeAt(M)&127;return A}function y(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let A="";for(let M=0;M<T.length;M++)A+=String.fromCharCode(T[M]);return A}function u(T){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...A,reason:"missing"};const M=T.trim(),C=M.split(".");if(C.length!==3)return A;const[P,x,K]=C;if(P!==W)return{...A,reason:"prefix"};const I=L(x),D=L(K);if(!I||!D)return A;let j;try{j=JSON.parse(y(I))}catch{return A}return j===null||typeof j!="object"?A:{ok:!0,reason:null,product:typeof j.p=="string"?j.p:null,issuedTo:typeof j.t=="string"?j.t:null,expires:typeof j.e=="string"?j.e:null,features:Array.isArray(j.f)?j.f.slice():[],deployments:Array.isArray(j.d)?j.d.slice():[],version:typeof j.v=="number"?j.v:0,message:S(x),signature:D,raw:M}}function o(T,A){if(!T)return!1;const M=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(M)?!0:A>M}let r=null,t=null,n=null;function i(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function s(T){if(r&&t===T)return r;const A=i();if(!A)return null;const M=L(T);if(!M)return null;try{const C=await A.importKey("raw",M,{name:"Ed25519"},!1,["verify"]);return r=C,t=T,C}catch{return null}}async function c(){return n!==null||(n=await s(U)!==null),n}async function d(T,A={}){const M=A.warn!==!1,C=A.product||z,P=A.publicKey||U,x=A.now??Date.now(),K=u(T);if(!K.ok){const q=K.reason==="missing"?"missing":"malformed";return M&&N(`licence.${q}`,q==="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.":"licence key could not be read. The grid will render with a watermark."),{valid:!1,reason:q}}const I={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0};if(K.product!==C)return M&&N("licence.product",`licence key is for '${K.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...I,reason:"product"};if(o(K.expires,x))return M&&N("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...I,reason:"expired"};const D=A.host??h(),j=K.deployments||[];if(j.length&&D&&!f(D)&&!g(D,j))return M&&N("licence.domain",`licence key is not valid for ${D}; it covers ${j.join(", ")}. The grid will render with a watermark.`),{valid:!1,...I,reason:"domain"};const E=await s(P);if(!E){const q=!!K.signature&&K.signature.length===_;return M&&N("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...I,reason:"unverified"}:{valid:!1,...I,reason:"signature"}}let $=!1;try{$=await i().verify({name:"Ed25519"},E,K.signature,K.message)}catch{$=!1}return $?{valid:!0,...I}:(M&&N("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...I,reason:"signature"})}function f(T){const A=String(T??h()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function h(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function g(T,A){const M=w(T);return!M||!Array.isArray(A)?!1:A.some(C=>{const P=w(C);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const x=P.slice(2);return M===x||M.endsWith(`.${x}`)}return M===P})}function w(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(A={}){this.#o=A}set(A){this.#e=typeof A=="string"?A.trim():"";const M=u(this.#e);return this.#t=M.ok?{valid:!o(M.expires,Date.now())&&M.product===(this.#o.product||z),product:M.product||void 0,issuedTo:M.issuedTo||void 0,expires:M.expires||void 0,reason:"pending"}:{valid:!1,reason:M.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=d(A,this.#o).then(M=>{if(this.#e===A){this.#t=M;for(const C of this.#i)C(M)}return M}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const m=new p;function b(T){return m.set(T)}function v(){return m.info()}function l(){return m.watermark()}function a(){return m.state()}function O(){return m}}),ve("packages/core/src/registry/registry.js",function(e,V){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return n}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isFunction,F=Z.DEV,W=V("packages/core/src/registry/licence.js"),_=W.LicenceHolder,U=W.sharedLicence,B=["renderer","editor","filter","dataType","totalFn","pipe","component"],H=["all","header","body","totals","panels"];class L{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#a=null;#s=new Set;#l=new Map;constructor(s={}){for(const c of B)this.#t.set(c,new Map);this.#o=s.holder||U(),this.#a=s.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),s.licence&&this.setLicence(s.licence)}registerModules(s,c={}){c.licence&&this.setLicence(c.licence),c.grid!==void 0&&(this.#a=c.grid);const d=Array.isArray(s)?s:[s],f=[];for(const h of d){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){N("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){F&&this.#c(this.#e.get(h.name),h);continue}if(!z(h.install)){N(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const g={registry:this,grid:this.#a};try{h.install(g)}catch(w){N(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,w);continue}this.#e.set(h.name,h);for(const w of k(h))this.#n.add(w);f.push(h.name),this.#d({reason:"module",name:h.name,capabilities:this.capabilities(),regions:u(h)})}return f}unregisterModule(s){const c=this.#e.get(s);if(!c)return!1;if(z(c.uninstall))try{c.uninstall({registry:this,grid:this.#a})}catch(d){N(`registry.module.uninstall:${s}`,`module '${s}' threw during uninstall.`,d)}return this.#e.delete(s),this.#u(),this.#d({reason:"unmodule",name:s,capabilities:this.capabilities(),regions:u(c)}),!0}modules(){return[...this.#e.values()]}has(s){return this.#e.has(s)}#u(){this.#n.clear();for(const s of this.#e.values())for(const c of k(s))this.#n.add(c)}#c(s,c){!s||s===c||S(s,c)||N(`registry.module.reconfigure:${c.name}`,`module '${c.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(s){return this.#n.has(s)}onChange(s){return z(s)?(this.#r.add(s),this.#l.set(s,this.#a),()=>{this.#r.delete(s),this.#l.delete(s)}):()=>{}}#d(s){for(const c of[...this.#r])try{c(s)}catch(d){N("registry.onChange.throw","a registry change handler threw.",d)}}register(s,c,d){const f=this.#t.get(s);if(!f){N(`registry.kind:${s}`,`unknown registry kind '${s}'; expected one of ${B.join(", ")}.`);return}if(!c||typeof c!="string"){N(`registry.name:${s}`,`register('${s}', ...) needs a name.`);return}f.has(c)&&f.get(c)!==d&&N(`registry.replace:${s}:${c}`,`'${c}' was already registered as a ${s} and has been replaced.`),f.set(c,d),this.#d({reason:"register",name:c,kind:s,capabilities:this.capabilities(),regions:o(s)})}registerAll(s,c){if(c)for(const d of Object.keys(c))this.register(s,d,c[d])}get(s,c){const d=this.#t.get(s);return d?d.get(c):void 0}names(s){const c=this.#t.get(s);return c?[...c.keys()]:[]}#h(s,c){const d=this.#t.get(s).get(c);return d!==void 0?d:this.#t.get("component").get(c)}renderer(s){return this.#h("renderer",s)}editor(s){return this.#h("editor",s)}filter(s){return this.#h("filter",s)}dataType(s){return this.get("dataType",s)}totalFn(s){return this.get("totalFn",s)}pipe(s){return this.get("pipe",s)}setLicence(s){return this.#o.set(s)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(s){s!=null&&(this.#s.add(s),this.#a=s)}detach(s){if(s!=null){this.#s.delete(s);for(const[c,d]of[...this.#l])d===s&&(this.#r.delete(c),this.#l.delete(c));if(this.#a===s){const c=this.#s.size?[...this.#s][this.#s.size-1]:null;this.#a=c}this.#s.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(s){if(s!=null){this.detach(s);return}for(const c of[...this.#e.keys()])this.unregisterModule(c);this.#r.clear(),this.#l.clear(),this.#s.clear(),this.#i&&this.#i(),this.#i=null,this.#a=null}}function k(i){const s=i.capabilities,c=Array.isArray(s)?s.filter(d=>typeof d=="string"):[];return[i.name,...c]}function S(i,s){return i.install!==s.install||i.uninstall!==s.uninstall||(i.version||"")!==(s.version||"")?!1:y(k(i),k(s))&&y(u(i),u(s))}function y(i,s){const c=new Set(i),d=new Set(s);if(c.size!==d.size)return!1;for(const f of c)if(!d.has(f))return!1;return!0}function u(i){const s=i.regions;return!Array.isArray(s)||s.length===0?["all"]:s.filter(c=>H.includes(c))}function o(i){switch(i){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new L;function t(){return r}function n(i,s={}){return r.registerModules(i,s)}}),ve("packages/core/src/format/number.js",function(e,V){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/internal/util.js").isNil;function z(F,W){const _=F||{},U=_.locale||W||void 0,B=_.style||"decimal",H=typeof _.scale=="number"?_.scale:1,L=_.nullDisplay??"",k=_.zeroDisplay,S=_.prefix||"",y=_.suffix||"",u=_.negative||"minus",o=_.signed===!0,r={style:B,notation:_.notation||"standard"};B==="currency"&&(r.currency=_.currency||"USD",_.currencyDisplay&&(r.currencyDisplay=_.currencyDisplay)),typeof _.decimals=="number"?(r.minimumFractionDigits=_.decimals,r.maximumFractionDigits=_.decimals):(typeof _.minDecimals=="number"&&(r.minimumFractionDigits=_.minDecimals),typeof _.maxDecimals=="number"&&(r.maximumFractionDigits=_.maxDecimals),r.minimumFractionDigits>(r.maximumFractionDigits??20)&&(r.maximumFractionDigits=r.minimumFractionDigits)),_.thousandsSeparator===!1&&(r.useGrouping=!1),r.notation==="compact"&&(r.compactDisplay=_.compactDisplay||"short");const t=new Intl.NumberFormat(U,r),n=typeof _.thousandsSeparator=="string"?_.thousandsSeparator:null,i=typeof _.decimalSeparator=="string"?_.decimalSeparator:null;let s=",",c=".";if(n||i)for(const p of t.formatToParts(12345.6))p.type==="group"?s=p.value:p.type==="decimal"&&(c=p.value);const d=p=>{let m=p;return n&&(m=m.split(s).join("")),i&&(m=m.split(c).join("")),n&&(m=m.split("").join(n)),i&&(m=m.split("").join(i)),m},f=!!(n||i),h=S!==""&&B==="currency",g=p=>{let m;if(h){const b=t.formatToParts(p);let v=!1;m="";for(const l of b)m+=l.value,!v&&l.type==="currency"&&(m+=S,v=!0);v||(m=S+m)}else m=S+t.format(p);return f&&(m=d(m)),m+y},w=p=>{if(N(p)||p==="")return L;const m=typeof p=="number"?p:Number(p);if(Number.isNaN(m))return L;const b=H===1?m:m*H;return b===0&&k!==void 0?k:b<0?u==="parentheses"?`(${g(-b)})`:u==="suffix"?`${g(-b)}-`:g(b):o&&b>0?`+${g(b)}`:g(b)};return w.negativeClass=_.negativeClass||null,w.spec=_,w}}),ve("packages/core/src/format/date.js",function(e,V){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(n){const i=[];let s=0,c="";const d=()=>{c&&(i.push({token:null,text:c}),c="")};for(;s<n.length;){const f=n[s];if(f==="'"){if(n[s+1]==="'"){c+="'",s+=2;continue}const g=n.indexOf("'",s+1);if(g===-1){c+=n.slice(s+1),s=n.length;continue}c+=n.slice(s+1,g),s=g+1;continue}const h=F.find(g=>n.startsWith(g,s));if(h){d(),i.push({token:h,text:h}),s+=h.length;continue}/[A-Za-z]/.test(f)&&z(`date.pattern.token:${f}`,`the date pattern "${n}" contains '${f}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),c+=f,s+=1}return d(),i}const _=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function U(n){if(N(n)||n==="")return null;if(n instanceof Date)return Number.isNaN(n.getTime())?null:n;if(typeof n=="number")return Number.isNaN(n)?null:new Date(n);if(typeof n=="string"){const i=_.exec(n.trim());if(i){const[,c,d,f,h="0",g="0",w="0"]=i;return new Date(+c,+d-1,+f,+h,+g,+w)}const s=new Date(n);return Number.isNaN(s.getTime())?null:s}return null}function B(n,i){return String(n).padStart(i,"0")}function H(n){if(!n)return c=>({year:c.getFullYear(),month:c.getMonth()+1,day:c.getDate(),hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds(),ms:c.getMilliseconds(),weekday:c.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return c=>{const d={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:c.getMilliseconds(),weekday:0};for(const f of i.formatToParts(c))switch(f.type){case"year":d.year=Number(f.value);break;case"month":d.month=Number(f.value);break;case"day":d.day=Number(f.value);break;case"hour":d.hour=Number(f.value)%24;break;case"minute":d.minute=Number(f.value);break;case"second":d.second=Number(f.value);break;case"weekday":d.weekday=s[f.value]??0;break;default:break}return d}}function L(n,i,s){const c=W(n),d=H(s),f=new Set(c.filter(m=>m.token).map(m=>m.token)),h=f.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,g=f.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,w=f.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,p=f.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const b=d(m);let v="";for(const l of c){if(!l.token){v+=l.text;continue}switch(l.token){case"yyyy":v+=B(b.year,4);break;case"yy":v+=B(b.year%100,2);break;case"MMMM":v+=g.format(m);break;case"MMM":v+=h.format(m);break;case"MM":v+=B(b.month,2);break;case"M":v+=String(b.month);break;case"dd":v+=B(b.day,2);break;case"d":v+=String(b.day);break;case"EEEE":v+=p.format(m);break;case"EEE":v+=w.format(m);break;case"HH":v+=B(b.hour,2);break;case"H":v+=String(b.hour);break;case"hh":v+=B(b.hour%12===0?12:b.hour%12,2);break;case"h":v+=String(b.hour%12===0?12:b.hour%12);break;case"mm":v+=B(b.minute,2);break;case"m":v+=String(b.minute);break;case"ss":v+=B(b.second,2);break;case"s":v+=String(b.second);break;case"SSS":v+=B(b.ms,3);break;case"a":v+=b.hour<12?"AM":"PM";break;default:v+=l.text;break}}return v}}const k=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function S(n,i){const s=n||{},c=s.locale||i||void 0,d=s.nullDisplay??"",f=s.timeZone;let h;if(s.pattern)h=L(s.pattern,c,f);else if(s.dateStyle||s.timeStyle){const b={timeZone:f};s.dateStyle&&(b.dateStyle=s.dateStyle),s.timeStyle&&(b.timeStyle=s.timeStyle);const v=new Intl.DateTimeFormat(c,b);h=l=>v.format(l)}else{const b=new Intl.DateTimeFormat(c,{dateStyle:"medium",timeZone:f});h=v=>b.format(v)}const g=s.relative?new Intl.RelativeTimeFormat(c,{numeric:"auto"}):null,p=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(b,v)=>{const l=U(b);if(!l)return d;if(g){const a=v&&typeof v.now=="number"?v.now:Date.now(),O=l.getTime()-a;if(Math.abs(O)<p){for(const[T,A]of k)if(Math.abs(O)>=A||T==="second")return g.format(Math.round(O/A),T)}}return h(l)};return m.spec=s,m}function y(n){if(N(n)||n==="")return null;if(typeof n=="string"){const c=/^(\d{4}-\d{2}-\d{2})/.exec(n.trim());if(c)return c[1];const d=U(n);return d?y(d):null}const i=U(n);if(!i)return null;const s=c=>String(c).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function u(n,i){if(N(n)||n==="")return null;if(typeof n=="string"){const c=n.trim();if(o.test(c)){const h=U(c);return h?r(h,i):null}const d=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(c);if(d){const[,h,g,w,p]=d;return`${h}T${g}:${w}${p&&p!=="00"?`:${p}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(c))return`${c}T00:00`;const f=U(c);return f?u(f):null}const s=U(n);return s?r(s,i):null}const o=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(n,i){const s=h=>String(h).padStart(2,"0");if(i)try{const h=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(n).reduce((p,m)=>(m.type!=="literal"&&(p[m.type]=m.value),p),{}),g=h.hour==="24"?"00":h.hour,w=Number(h.second);return`${h.year}-${h.month}-${h.day}T${g}:${h.minute}`+(w?`:${h.second}`:"")}catch{}const c=`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}`,d=n.getSeconds(),f=`${s(n.getHours())}:${s(n.getMinutes())}${d?`:${s(d)}`:""}`;return`${c}T${f}`}function t(n,i){const s=N(n)||n===""?null:String(n),c=N(i)||i===""?null:String(i);return s===null?c===null?0:1:c===null||s<c?-1:s>c?1:0}}),ve("packages/core/src/format/boolean.js",function(e,V){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isNil,z={true:"☑",false:"☐",null:""},F={true:"◉",false:"◯",null:""};function W(U){if(N(U)||U==="")return null;if(typeof U=="boolean")return U;if(typeof U=="number")return U!==0;const B=String(U).trim().toLowerCase();return B==="true"||B==="yes"||B==="y"||B==="1"?!0:B==="false"||B==="no"||B==="n"||B==="0"?!1:null}function _(U,B){const H=U||{},L=H.display||"text",k=H.trueLabel??"Yes",S=H.falseLabel??"No",y=H.nullLabel??"";let u=k,o=S;const r=y;L==="checkbox"?(u=z.true,o=z.false):L==="switch"?(u=F.true,o=F.false):L==="icon"&&(u=H.trueIcon??k,o=H.falseIcon??S);const t=n=>{const i=W(n);return i===null?r:i?u:o};return t.display=L,t.labels={true:k,false:S,null:y},t.locale=B,t.spec=H,t}}),ve("packages/core/src/format/text.js",function(e,V){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.titleCase;function F(W,_){const U=W||{},B=U.locale||_||void 0,H=U.nullDisplay??"",L=U.emptyDisplay??"",k=U.transform||"none",S=typeof U.truncate=="number"?{chars:U.truncate}:U.truncate||null,y=S?S.chars:0,u=S?S.ellipsis??"…":"",o=t=>{switch(k){case"upper":return B?t.toLocaleUpperCase(B):t.toUpperCase();case"lower":return B?t.toLocaleLowerCase(B):t.toLowerCase();case"title":return z(t);default:return t}},r=t=>{if(N(t))return H;let n=typeof t=="string"?t:String(t);return n===""?L:(k!=="none"&&(n=o(n)),y>0&&n.length>y&&(n=n.slice(0,y)+u),n)};return r.spec=U,r}}),ve("packages/core/src/format/mask.js",function(e,V){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return _}});const Z=new Set(["0","#","?",",","."]),N="\0";function z(B){const H=[];let L="",k=!1;for(let S=0;S<B.length;S++){const y=B[S];if(y==="\\"){L+=y+(B[S+1]??""),S+=1;continue}if(y==='"'){k=!k,L+=y;continue}if(y===";"&&!k){H.push(L),L="";continue}L+=y}return H.push(L),H}function F(B){let H="",L="",k="",S=1,y=!1,u=!1;const o=h=>{u?L+=h:H+=h};for(let h=0;h<B.length;h++){const g=B[h];if(g==="\\"){o(B[h+1]??""),h+=1;continue}if(g==='"'){const w=B.indexOf('"',h+1);o(w===-1?B.slice(h+1):B.slice(h+1,w)),h=w===-1?B.length:w;continue}if(g==="%"){S*=100,o("%");continue}if(g==="@"){y=!0,o("\0");continue}if(Z.has(g)){k+=g,u=!0;continue}o(g)}let r=-1;for(let h=k.length-1;h>=0;h--){const g=k[h];if(g==="0"||g==="#"||g==="?"){r=h;break}}let t=!1,n="";for(let h=0;h<k.length;h++){const g=k[h];if(g===","){h>r?S/=1e3:t=!0;continue}n+=g}const i=n.indexOf("."),s=i===-1?n:n.slice(0,i),c=i===-1?"":n.slice(i+1);let d=0;for(const h of s)h==="0"&&(d+=1);let f=0;for(const h of c)h==="0"&&(f+=1);return{prefix:H,suffix:L,minInt:d,minDec:f,maxDec:c.length,grouping:t,scale:S,hasNumber:r!==-1,isText:y}}function W(B,H){const L=new Intl.NumberFormat(H,{minimumIntegerDigits:Math.max(B.minInt,1),minimumFractionDigits:B.minDec,maximumFractionDigits:Math.max(B.maxDec,B.minDec),useGrouping:B.grouping}),{prefix:k,suffix:S,scale:y,hasNumber:u}=B;return o=>{if(!u)return k+S;const r=y===1?o:o*y;return k+L.format(r)+S}}function _(B,H){const k=z(String(B)).map(F),S=k.map(n=>W(n,H)),y=0,u=k.length>1?1:-1,o=k.length>2?2:-1,r=k.length>3?3:-1,t=n=>{if(n==null||n==="")return"";if(typeof n!="number"||Number.isNaN(n)){const i=Number(n);if(Number.isNaN(i))return r===-1?String(n):(k[r].prefix+k[r].suffix).split("\0").join(String(n));n=i}return n===0&&o!==-1?S[o](0):n<0&&u!==-1?S[u](-n):S[y](n)};return t.spec={mask:B},{format:t,ooxml:U(String(B))}}function U(B){return B.trim()}}),ve("packages/core/src/format/shorthand.js",function(e,V){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return U}});const Z=["currency","number","percent","date","boolean","text","relative"],N=/[#0?@;"\\]/,z=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function F(B){return typeof B!="string"||B===""||_(B)?!1:N.test(B)}function W(B){return typeof B!="string"||B===""||_(B)?!1:z.test(B)}function _(B){const H=B.indexOf(":"),L=H===-1?B:B.slice(0,H);return Z.includes(L)?L:null}function U(B){const H=_(B);if(!H)return null;const L=B.indexOf(":"),k=L===-1?"":B.slice(L+1),S=k===""?[]:k.split(":");switch(H){case"currency":{const y={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(y.decimals=Number(S[1])),y}case"number":{const y={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"percent":{const y={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"date":return{type:"date",pattern:k||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=k.split("/"),u={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(u.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(u.falseLabel=y[1]),y[2]!==void 0&&(u.nullLabel=y[2]),u}case"text":{const y={type:"text"};return S[0]&&(y.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(y.truncate=Number(S[1])),y}default:return null}}}),ve("packages/core/src/format/index.js",function(e,V){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return m}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.isObject,F=Z.warnOnce,W=V("packages/core/src/format/number.js"),_=W.compileNumber,U=V("packages/core/src/format/date.js"),B=U.compileDate,H=U.scanPattern,L=V("packages/core/src/format/boolean.js"),k=L.compileBoolean,S=V("packages/core/src/format/text.js"),y=S.compileText,u=V("packages/core/src/format/mask.js"),o=u.compileMask,r=V("packages/core/src/format/shorthand.js"),t=r.parseShorthand,n=r.looksLikeMask,i=r.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return U.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return U.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return U.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return U.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return L.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return L.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return S.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return u.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return u.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return u.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const s=new Set(["decimal","currency","percent","unit"]),c=new Set(["type","locale"]),d={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),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"])};function f(a,O,T){const A=d[O],M=T?`"${T}"`:"with no id";for(const C of a){if(c.has(C)||A.has(C))continue;const P=Object.keys(d).find(x=>x!==O&&d[x].has(C));P?F(`format:inapplicable:${T||""}:${C}`,`column ${M} has format key "${C}", which applies to a ${P} column, not the ${O} column it was applied to; it is ignored.`):F(`format:unknown:${T||""}:${C}`,`column ${M} has an unrecognised format key "${C}" for its ${O} format; it is ignored.`)}}function h(a){if(a.type==="number"||a.type==="date"||a.type==="boolean"||a.type==="text")return!0;const O=s.has(String(a.style));return!!(a.pattern||a.dateStyle||a.timeStyle||a.relative||a.timeZone||a.trueLabel||a.falseLabel||a.display||a.trueIcon||a.falseIcon||a.transform||a.truncate||a.emptyDisplay||O||a.currency||a.decimals!==void 0||a.minDecimals!==void 0||a.maxDecimals!==void 0||a.notation||a.negative||a.scale!==void 0||a.prefix||a.suffix||a.zeroDisplay!==void 0)}function g(a,O){if(a.type==="number"||a.type==="date"||a.type==="boolean"||a.type==="text")return a.type;if(a.pattern||a.dateStyle||a.timeStyle||a.relative||a.timeZone)return"date";if(a.trueLabel||a.falseLabel||a.display||a.trueIcon||a.falseIcon)return"boolean";if(a.transform||a.truncate||a.emptyDisplay)return"text";if(a.style||a.currency||a.decimals!==void 0||a.minDecimals!==void 0||a.maxDecimals!==void 0||a.notation||a.negative||a.scale!==void 0||a.prefix||a.suffix||a.zeroDisplay!==void 0)return"number";const T=O&&O.base;return T==="number"?"number":T==="date"||T==="dateString"?"date":T==="boolean"?"boolean":"text"}function w(a,O=null,T=void 0,A=void 0,M=void 0){if(a==null||a==="")return null;const C=z(a)?Object.keys(a):null;if(A&&a&&typeof a=="object"&&a.timeZone===void 0&&(a={...a,timeZone:A}),typeof a=="function"){const K=(I,D)=>String(a({...D||{},value:I,locale:T})??"");return K.ooxml=O&&O.excel||"General",K}if(typeof a=="string"){if(n(a)){const{format:I,ooxml:D}=o(a,T);return I.ooxml=D,I}const K=t(a)||(i(a)?{type:"date",pattern:a}:null);return K?w(K,O,T,A,M):(F(`format:${a}`,`unrecognised format string "${a}"; the value will be stringified`),null)}if(!z(a))return F("format:shape","format must be a spec object or a string; ignoring",a),null;if(O&&N(O.format)&&!h(a))return null;const P=g(a,O);f(C||Object.keys(a),P,M);let x;switch(P){case"number":x=_(a,T);break;case"date":x=B(a,T);break;case"boolean":x=k(a,T);break;default:x=y(a,T);break}return x.ooxml=m(a,P,T,O),x.kind=P,x}const p={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function m(a,O,T=void 0,A=null){if(O==="date"){if(a.pattern){let K="";for(const I of H(a.pattern))K+=I.token?p[I.token]??I.text:I.text;return K}return A&&A.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(a.notation==="compact"||a.notation==="scientific")return"General";const M=typeof a.decimals=="number"?a.decimals:typeof a.minDecimals=="number"?a.minDecimals:a.style==="currency"?2:0;let P=`${a.thousandsSeparator===!1?"":"#,#"}#0${M>0?`.${"0".repeat(M)}`:""}`,x="";return a.style==="currency"&&(x+=b(l(a.currency||"USD",T))),a.prefix&&(x+=b(a.prefix)),P=x+P,a.style==="percent"&&(P=`${P}%`),a.suffix&&(P+=b(a.suffix)),a.negative==="parentheses"?`${P};(${P})`:a.negative==="suffix"?`${P};${P}-`:P}function b(a){return`"${String(a).split('"').join("")}"`}const v=new Map;function l(a,O){const T=`${a}|${O||""}`;let A=v.get(T);if(A!==void 0)return A;A=a;try{const C=new Intl.NumberFormat(O,{style:"currency",currency:a}).formatToParts(0).find(P=>P.type==="currency");C&&(A=C.value)}catch{}return v.set(T,A),A}}),ve("packages/core/src/columns/types/temporal.js",function(e,V){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return at}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.isFunction,F=V("packages/core/src/format/date.js"),W=F.toDate,_=F.compilePattern,U=F.compileDate,B=F.toIsoDateTime,H=F.compareIso,L=864e5,k=Object.freeze({}),S=1e3,y=60*S,u=60*y,o=24*u,r=7*o,t=new WeakMap;function n(Ae,Ke){const Ve=Ae&&Ae.locale||"",Qe=Ae&&Ae.column;if(!Qe)return Ve?{locale:Ve}:k;const lt=t.get(Qe);if(lt&<.locale===Ve)return lt.bag;const wt=Qe.typeOptions||Qe[Ke]||(i(Qe.format)?Qe.format:null),Pt={...wt||k,locale:wt&&wt.locale||Ve||void 0};return t.set(Qe,{locale:Ve,bag:Pt}),Pt}function i(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function s(Ae,Ke){const Ve=Ae===null||Number.isNaN(Ae)?null:Ae,Qe=Ke===null||Number.isNaN(Ke)?null:Ke;return Ve===null?Qe===null?0:1:Qe===null||Ve<Qe?-1:Ve>Qe?1:0}const c=/^(\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,d=/^(\d{3,6})$/;function f(Ae,Ke,Ve,Qe){return!(Ae>=0&&Ae<=23)||!(Ke>=0&&Ke<=59)||!(Ve>=0&&Ve<=59)||!(Qe>=0&&Qe<=999)?null:Ae*u+Ke*y+Ve*S+Qe}function h(Ae){if(N(Ae))return null;const Ke=String(Ae).trim();if(Ke==="")return null;const Ve=d.exec(Ke);if(Ve){const $t=Ve[1];if($t.length===5)return null;const zt=$t.length===3?1:2;return f(Number($t.slice(0,zt)),Number($t.slice(zt,zt+2)),Number($t.slice(zt+2,zt+4)||0),0)}const Qe=c.exec(Ke);if(!Qe)return null;let lt=Number(Qe[1]);const wt=Number(Qe[2]||0),Pt=Number(Qe[3]||0),Lt=Qe[4]?Number(Qe[4].padEnd(3,"0")):0,Rt=Qe[5]?Qe[5][0].toLowerCase():null;if(Rt){if(lt<1||lt>12)return null;lt=lt%12,Rt==="p"&&(lt+=12)}return f(lt,wt,Pt,Lt)}function g(Ae){return N(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%o+o)%o:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*u+Ae.getMinutes()*y+Ae.getSeconds()*S+Ae.getMilliseconds():h(Ae)}const w=new Map;function p(Ae){const Ke=Ae.pattern||"",Ve=Ae.timeStyle||(Ae.seconds?"medium":"short"),Qe=`${Ae.locale||""}|${Ke}|${Ve}`;let lt=w.get(Qe);if(lt)return lt;if(Ke)lt=_(Ke,Ae.locale||void 0,"UTC");else{const wt=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ve,timeZone:"UTC"});lt=Pt=>wt.format(Pt)}return w.set(Qe,lt),lt}function m(Ae,Ke){const Ve=Ke||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ve.nullDisplay??"";const Qe=(Ae%o+o)%o;return p(Ve)(new Date(Qe))}function b(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<o:typeof Ae!="string"||!Ae.includes(":")?!1:h(Ae)!==null}function v(Ae){const Ke=g(Ae);return Ke==null?"":m(Ke,{pattern:Ke%S===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const l=new Map;function a(Ae){const Ke=Ae||"";let Ve=l.get(Ke);return Ve||(Ve=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),l.set(Ke,Ve)),Ve}function O(Ae,Ke){const Ve={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Qe of a(Ke).formatToParts(new Date(Ae)))Qe.type==="year"?Ve.year=Number(Qe.value):Qe.type==="month"?Ve.month=Number(Qe.value):Qe.type==="day"?Ve.day=Number(Qe.value):Qe.type==="hour"?Ve.hour=Number(Qe.value)%24:Qe.type==="minute"?Ve.minute=Number(Qe.value):Qe.type==="second"&&(Ve.second=Number(Qe.value));return Ve}function T(Ae,Ke){const Ve=O(Ae,Ke);return Date.UTC(Ve.year,Ve.month-1,Ve.day,Ve.hour,Ve.minute,Ve.second,0)-Math.floor(Ae/1e3)*1e3}function A(Ae,Ke){const Ve=Ae.hour||0,Qe=Ae.minute||0,lt=Ae.second||0,wt=Ae.ms||0;if(!Ke)return new Date(Ae.year,Ae.month-1,Ae.day,Ve,Qe,lt,wt).getTime();const Pt=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ve,Qe,lt,wt);let Lt=Pt-T(Pt,Ke);return Lt=Pt-T(Lt,Ke),Lt}const M=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,Ke){if(N(Ae))return null;const Ve=String(Ae).trim();if(Ve==="")return null;const Qe=Ke&&Ke.timeZone||void 0;if(!M.test(Ve)){const lt=C.exec(Ve);if(lt){const wt=(lt[4]||"").trim(),Pt=wt===""?0:h(wt);if(Pt===null)return null;const Lt=A({year:Number(lt[1]),month:Number(lt[2]),day:Number(lt[3]),hour:Math.floor(Pt/u),minute:Math.floor(Pt/y)%60,second:Math.floor(Pt/S)%60,ms:Pt%S},Qe);return Number.isNaN(Lt)?null:new Date(Lt)}}return W(Ve)}function x(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const Ke=W(Ae);return Ke?Ke.getTime():null}const K=new Map;function I(Ae){const Ke=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ve=K.get(Ke);if(Ve)return Ve;const Qe=Ae.pattern?{type:"date",pattern:Ae.pattern,timeZone:Ae.timeZone}:{type:"date",dateStyle:Ae.dateStyle||"medium",timeStyle:Ae.timeStyle||(Ae.seconds?"medium":"short"),timeZone:Ae.timeZone};return Ve=U(Qe,Ae.locale||void 0),K.set(Ke,Ve),Ve}function D(Ae,Ke){const Ve=Ke||k,Qe=x(Ae);return Qe==null?Ve.nullDisplay??"":I(Ve)(Qe)}function j(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!C.test(Ae.trim())?!1:P(Ae)!==null}const E=Object.freeze([{key:"w",ms:r,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:o,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:y,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:S,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),$=new Map;for(const Ae of E)for(const Ke of Ae.names)$.set(Ke,Ae);const q=Object.freeze(E.filter(Ae=>Ae.key!=="w")),X=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Q=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ne(Ae){const Ke=Ae&&Ae.defaultUnit?$.get(String(Ae.defaultUnit).toLowerCase()):null;return Ke?Ke.ms:y}function re(Ae){return(Ae&&Ae.defaultUnit?$.get(String(Ae.defaultUnit).toLowerCase()):null)||$.get("m")}function oe(Ae,Ke){if(N(Ae))return null;let Ve=String(Ae).trim().toLowerCase();if(Ve==="")return null;let Qe=1;if(Ve[0]==="-"?(Qe=-1,Ve=Ve.slice(1).trim()):Ve[0]==="+"&&(Ve=Ve.slice(1).trim()),Ve==="")return null;const lt=J.exec(Ve);if(lt){const Rt=lt[3]!==void 0,$t=Number(lt[1])*u+Number(lt[2])*y+(Rt?Number(lt[3])*S:0)+(lt[4]?Number(lt[4].padEnd(3,"0")):0);return Qe*$t}if(Q.test(Ve))return Math.round(Qe*Number(Ve)*ne(Ke||k));let wt=Ve,Pt=0,Lt=0;for(;wt!=="";){const Rt=X.exec(wt);if(!Rt)return null;const $t=$.get(Rt[2]);if(!$t)return null;Pt+=Number(Rt[1])*$t.ms,wt=wt.slice(Rt[0].length),Lt++}return Lt===0?null:Math.round(Qe*Pt)}function ie(Ae){return N(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:oe(Ae)}const te=new Map;function ce(Ae,Ke,Ve){const Qe=`${Ve||""}|${Ke.intl}`;let lt=te.get(Qe);if(lt===void 0){try{lt=new Intl.NumberFormat(Ve||void 0,{style:"unit",unit:Ke.intl,unitDisplay:"long"})}catch{lt=null}te.set(Qe,lt)}return lt?lt.format(Ae):`${Ae} ${Ae===1?Ke.long[0]:Ke.long[1]}`}function ue(Ae,Ke){return String(Ae).padStart(Ke,"0")}function ae(Ae,Ke){const Ve=Ke||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ve.nullDisplay??"";const Qe=Ve.style||"short",lt=Ae<0;let wt=Math.round(Math.abs(Ae));const Pt=lt?"-":"";if(wt===0&&Ve.zeroDisplay!=null)return Ve.zeroDisplay;if(Qe==="clock"){const zt=Math.floor(wt/u),_t=Math.floor(wt/y)%60,Qt=Math.floor(wt/S)%60;return`${Pt}${ue(zt,2)}:${ue(_t,2)}:${ue(Qt,2)}`}if(wt===0){const zt=re(Ve);return Qe==="long"?ce(0,zt,Ve.locale):`0${zt.key}`}const Lt=Ve.weeks===!0?E:q,Rt=typeof Ve.maxUnits=="number"&&Ve.maxUnits>0?Ve.maxUnits:Ve.maxUnits===void 0?2:1/0,$t=[];for(const zt of Lt){if($t.length>=Rt)break;const _t=Math.floor(wt/zt.ms);_t!==0&&(wt-=_t*zt.ms,$t.push(Qe==="long"?ce(_t,zt,Ve.locale):`${_t}${zt.key}`))}return Pt+$t.join(" ")}function pe(Ae){if(typeof Ae!="string")return!1;const Ke=Ae.trim();return Ke===""||J.test(Ke)||!/[a-z]/i.test(Ke)?!1:oe(Ke)!==null}const he=Date.UTC(1899,11,30),ke=new Map;function Oe(Ae,Ke){const Ve=Ae||"";let Qe=ke.get(Ve);Qe||(Qe=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ke.set(Ve,Qe));const lt=typeof Ke=="number"?Ke:Date.now();for(const wt of Qe.formatToParts(new Date(lt)))if(wt.type==="timeZoneName")return wt.value;return""}function De(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function _e(Ae,Ke){const Ve=De(Ae),Qe=Oe(Ae,Ke);return Qe?`${Ve} (${Qe})`:Ve}function Se(Ae,Ke){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ve=Ke&&Ke.grid;return(Ve&&z(Ve.get)?Ve.get("timeZone"):void 0)||void 0}function xe(Ae,Ke){const Ve=Ke||k,Qe=x(Ae);if(Qe==null)return Ve.nullDisplay??"";const lt=I(Ve)(Qe);if(!Ve.showOrigin)return lt;const wt=Ve.originZone;return wt?wt===(Ve.timeZone||De(Ve.timeZone))?lt:`${lt} (${_e(wt,Qe)})`:`${lt} (no origin recorded)`}function $e(Ae,Ke,Ve,Qe){if(Ke==="instant"||!Ke)return Ae;const lt=O(Ae,Ve);if(Ke==="month")return A({year:lt.year,month:lt.month,day:1},Ve);if(Ke==="week"){const wt=Qe>=1&&Qe<=7?Qe:1,Lt=((new Date(Date.UTC(lt.year,lt.month-1,lt.day)).getUTCDay()+6)%7+1-wt+7)%7,Rt=new Date(Date.UTC(lt.year,lt.month-1,lt.day-Lt));return A({year:Rt.getUTCFullYear(),month:Rt.getUTCMonth()+1,day:Rt.getUTCDate()},Ve)}return A({year:lt.year,month:lt.month,day:lt.day},Ve)}function qe(Ae,Ke){const Ve=Ae&&Ae.group,Qe=Ve&&Ve.granularity||"day";if(Qe==="instant")return null;const lt=Ve&&Ve.weekStart;return wt=>typeof wt=="number"?$e(wt,Qe,Ke,lt):wt}const Ue={time:{base:"number",storage:"float64",matches:b,format:Ae=>m(g(Ae.value),n(Ae,"time")),parse:Ae=>h(Ae.text),compare:(Ae,Ke)=>s(g(Ae),g(Ke)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ke=g(Ae);return Ke===null?null:Ke/L},toStorage:Ae=>g(Ae),toClipboard:v,fromClipboard:h},datetime:{base:"dateString",storage:"dictionary",matches:j,format:Ae=>D(Ae.value,n(Ae,"datetime")),parse:Ae=>B(P(Ae.text,n(Ae,"datetime"))??Ae.text),compare:H,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,Ke)=>B(Ae,Ke&&Ke.timeZone),toClipboard:Ae=>N(Ae)?"":String(Ae),fromClipboard:Ae=>B(Ae)},duration:{base:"number",storage:"float64",matches:pe,format:Ae=>ae(ie(Ae.value),n(Ae,"duration")),parse:Ae=>oe(Ae.text,n(Ae,"duration")),compare:(Ae,Ke)=>s(ie(Ae),ie(Ke)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ke=ie(Ae);return Ke===null?null:Ke/L},toStorage:Ae=>ie(Ae),toClipboard:Ae=>ae(ie(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>oe(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const Ke=n(Ae,"timestamp");return xe(Ae.value,{...Ke,timeZone:Se(Ke,Ae)})},parse:Ae=>{const Ke=n(Ae,"timestamp"),Ve=P(Ae.text,{timeZone:Se(Ke,Ae)});return Ve?Ve.getTime():null},compare:(Ae,Ke)=>s(x(Ae),x(Ke)),groupProjector:(Ae,Ke)=>qe(Ae,Ke),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,Ke)=>{const Ve=x(Ae);if(Ve==null)return null;const Qe=O(Ve,Ke&&Ke.timeZone||void 0);return(Date.UTC(Qe.year,Qe.month-1,Qe.day,Qe.hour,Qe.minute,Qe.second)-he)/L},toStorage:Ae=>x(Ae),toClipboard:Ae=>{const Ke=x(Ae);return Ke==null?"":new Date(Ke).toISOString()},fromClipboard:Ae=>x(Ae)}},Je=["datetime","time","duration"],at=Ue}),ve("packages/core/src/columns/types/network.js",function(e,V){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.Lru,F=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function _(x){if(N(x))return null;if(typeof x=="string")return U(x);const K=Number(x);return Number.isFinite(K)?K<0?K<-2147483648?null:K>>>0:K>F?null:Math.trunc(K)>>>0:null}function U(x){if(N(x))return null;const K=String(x).trim();if(K==="")return null;const I=W.exec(K);if(!I)return null;let D=0;for(let j=1;j<=4;j++){const E=I[j];if(E.length>1&&E.charCodeAt(0)===48)return null;const $=Number(E);if($>255)return null;D=D*256+$}return D}function B(x){const K=_(x);return K===null?"":`${K>>>24&255}.${K>>>16&255}.${K>>>8&255}.${K&255}`}function H(x){return typeof x=="string"&&U(x)!==null}function L(x,K){const I=_(x),D=_(K);return I===null?D===null?0:1:D===null||I<D?-1:I>D?1:0}const k=64,S=F*k+32,y=/^(?:0|[1-9]\d?)$/;function u(x,K){return x*k+K}function o(x){if(N(x))return null;if(typeof x=="string"){const D=r(x);return D===null?null:o(D)}if(typeof x=="object"){const D=_(x.address),j=Number(x.prefix);return D===null||!Number.isInteger(j)||j<0||j>32?null:{address:D,prefix:j}}const K=Number(x);if(!Number.isInteger(K)||K<0||K>S)return null;const I=K%k;return I>32?null:{address:(K-I)/k,prefix:I}}function r(x){if(N(x))return null;const K=String(x).trim();if(K==="")return null;const I=K.indexOf("/");if(I<0)return null;const D=U(K.slice(0,I));if(D===null)return null;const j=K.slice(I+1).trim();if(!y.test(j))return null;const E=Number(j);return E>32?null:u(D,E)}function t(x){const K=o(x);return K?`${B(K.address)}/${K.prefix}`:""}function n(x){return typeof x=="string"&&r(x)!==null}function i(x,K){const I=o(x),D=o(K);return I?D?I.address!==D.address?I.address<D.address?-1:1:I.prefix-D.prefix:-1:D?1:0}function s(x){return x===0?0:4294967295<<32-x>>>0}function c(x){const K=o(x);return K?(K.address&s(K.prefix))>>>0:null}function d(x){const K=o(x);return K?(K.address&s(K.prefix)|~s(K.prefix)>>>0)>>>0:null}function f(x){const K=o(x);return K?2**(32-K.prefix):null}function h(x){const K=o(x);return K?K.prefix===32?1:K.prefix===31?2:2**(32-K.prefix)-2:null}function g(x,K){const I=o(x);if(!I)return!1;const D=_(K);if(D===null)return!1;const j=s(I.prefix);return(D&j)>>>0===(I.address&j)>>>0}function w(x,K){const I=c(x),D=c(K);return I===null||D===null?!1:I<=d(K)&&D<=d(x)}const p=/^[0-9a-fA-F]{1,4}$/,m=new z(512);function b(x){if(N(x))return null;let K=String(x).trim();if(K==="")return null;const I=K.indexOf("%");if(I>=0&&(K=K.slice(0,I)),K==="")return null;if(K.indexOf(".")>=0){const X=K.lastIndexOf(":");if(X<0)return null;const Q=U(K.slice(X+1));if(Q===null)return null;K=`${K.slice(0,X+1)}${(Q>>>16&65535).toString(16)}:${(Q&65535).toString(16)}`}const D=K.split("::");if(D.length>2)return null;const j=v(D[0]);if(j===null)return null;if(D.length===1)return j.length===8?j:null;const E=v(D[1]);if(E===null)return null;const $=8-j.length-E.length;if($<1)return null;const q=j.slice();for(let X=0;X<$;X++)q.push(0);for(const X of E)q.push(X);return q}function v(x){if(x==="")return[];const K=[];for(const I of x.split(":")){if(!p.test(I))return null;K.push(parseInt(I,16))}return K}function l(x){if(typeof x!="string")return b(x);if(m.has(x))return m.get(x);const K=b(x);return m.set(x,K),K}function a(x){if(x[0]===0&&x[1]===0&&x[2]===0&&x[3]===0&&x[4]===0&&x[5]===65535)return`::ffff:${B((x[6]<<16|x[7])>>>0)}`;let K=-1,I=0,D=-1,j=0;for(let q=0;q<8;q++)x[q]===0?(D<0?(D=q,j=1):j++,j>I&&(I=j,K=D)):(D=-1,j=0);if(I<2)return x.map(q=>q.toString(16)).join(":");const E=x.slice(0,K).map(q=>q.toString(16)).join(":"),$=x.slice(K+I).map(q=>q.toString(16)).join(":");return`${E}::${$}`}function O(x){const K=b(x);return K===null?null:a(K)}function T(x){return O(x)??""}function A(x){return typeof x=="string"&&x.indexOf(":")>=0&&b(x)!==null}function M(x,K){const I=l(x),D=l(K);if(!I)return D?1:0;if(!D)return-1;for(let j=0;j<8;j++)if(I[j]!==D[j])return I[j]<D[j]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:H,parse:x=>U(x.text),compare:L,format:x=>B(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:x=>_(x),toClipboard:x=>B(x),fromClipboard:x=>U(x)},cidr:{base:"number",storage:"float64",matches:n,parse:x=>r(x.text),compare:i,format:x=>t(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:x=>{const K=o(x);return K===null?null:u(K.address,K.prefix)},toClipboard:x=>t(x),fromClipboard:x=>r(x)},ipv6:{base:"text",storage:"dictionary",matches:A,parse:x=>O(x.text),compare:M,format:x=>T(x.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:x=>O(x),toClipboard:x=>T(x),fromClipboard:x=>O(x)}}),P=C}),ve("packages/core/src/i18n/catalogue.js",function(e,V){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return N}});const Z=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","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.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"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.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.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","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","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","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.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.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.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","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.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":"Next / previous cell, wrapping across rows","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.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.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…","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","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.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.dataTable":"Chart data","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.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.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","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"}),N=Object.freeze(Object.keys(Z))}),ve("packages/core/src/i18n/format.js",function(e,V){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,z=/\{(\w+)\}/g,F=new Map,W=new Map;function _(y){const u=y||"";if(F.has(u))return F.get(u);let o=null;try{o=new Intl.PluralRules(y||void 0)}catch{o=null}return F.set(u,o),o}function U(y,u,o="conjunction"){const r=Array.isArray(y)?y.filter(i=>i!=null&&i!==""):[];if(r.length===0)return"";if(r.length===1)return String(r[0]);const t=`${u||""}|${o}`;let n=W.get(t);if(n===void 0){try{n=new Intl.ListFormat(u||void 0,{style:"long",type:o})}catch{n=null}W.set(t,n)}return n?n.format(r.map(String)):r.map(String).join(", ")}function B(y,u){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(y)}function H(y,u,o){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const r=u&&typeof u.count=="number"?u.count:null;if(r===null)return y.other??"";const t=_(o),n=t?t.select(r):r===1?"one":"other";return y[n]??y.other??""}function L(y,u={},o){const r=H(y,u,o);return r?r.replace(z,(t,n)=>Object.prototype.hasOwnProperty.call(u,n)?B(u[n],o):t):""}function k(y,u,o="en-GB"){return typeof y=="string"&&y?y:typeof u=="string"&&u?u:o}function S(y,u){const o=y?y[u]:void 0;return o==null||N(o)?u:o}}),ve("packages/core/src/i18n/index.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return r}});const Z=V("packages/core/src/i18n/catalogue.js"),N=Z.EN_GB,z=Z.MESSAGE_KEYS,F=V("packages/core/src/i18n/format.js"),W=F.formatMessage,_=F.formatList,U=F.lookup,B=F.resolveLocale,H=V("packages/core/src/internal/util.js"),L=H.isFunction,k=H.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Z.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Z.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return F.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return F.resolveLocale}});const S="en-GB";class y{#e=S;#t=N;constructor(n={}){this.configure(n)}configure(n={}){this.#e=B(n.locale,n.declared,S);const i=n.messages;if(!i||typeof i!="object"){this.#t=N;return}const s=Object.keys(i).filter(c=>!(c in N));s.length&&k(`i18n:unknown:${s[0]}`,`message keys not in the catalogue and so ignored: ${s.slice(0,5).join(", ")}${s.length>5?`, and ${s.length-5} more`:""}`),this.#t={...N,...i}}get locale(){return this.#e}t(n,i){return W(U(this.#t,n),i||{},this.#e)}list(n,i){return _(n,this.#e,i)}number(n,i){const s=Number(n);return Number.isFinite(s)?s.toLocaleString(this.#e,i||{maximumFractionDigits:20}):""}}const u=new y;function o(t){return t instanceof y?t:new y(t||{})}function r(t){const n=t&&typeof t=="object"?t:{},i=z.filter(c=>{const d=n[c];return d==null||d===""||L(d)}),s=Object.keys(n).filter(c=>!(c in N));return{missing:i,unknown:s}}}),ve("packages/core/src/columns/types/structured.js",function(e,V){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.isObject,W=V("packages/core/src/i18n/index.js").defaultMessages,_=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function U(t,n){const i=n||{},s=i.emptyDisplay??_.emptyDisplay;if(N(t)||t==="")return s;const d=[...typeof i.char=="string"&&i.char!==""?i.char:_.char][0]||_.char,f=i.fixedLength??_.fixedLength,h=Number.isFinite(i.length)&&Number(i.length)>0?Math.floor(Number(i.length)):_.length,g=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let w=0;if(g!==null){const p=Number.isFinite(i.lastVisible)?Math.floor(Number(i.lastVisible)):_.lastVisible,m=[...g];if(w=p>0&&p<m.length?p:0,w>0){const b=m.slice(m.length-w).join(""),v=Math.max(1,(f?h:m.length)-w);return d.repeat(v)+b}return d.repeat(f?h:Math.max(1,m.length))}return d.repeat(h)}const B=48;function H(t){try{const n=JSON.stringify(t);return n===void 0?null:n}catch{return null}}function L(t,n){if(N(t))return"";const i=Number.isFinite(n&&n.inlineLimit)?Number(n.inlineLimit):B;if(typeof t=="string")return t.length>i?`${t.slice(0,i-1)}…`:t;if(typeof t!="object")return String(t);const s=H(t);if(s!==null&&s.length<=i)return s;if(Array.isArray(t)){const d=t.length;return`[${W.t("count.items",{count:d})}]`}const c=Object.keys(t).length;return`{${W.t("count.keys",{count:c})}}`}function k(t,n){if(t==null)return"null";const i=typeof t;if(i==="number"||i==="boolean"||i==="bigint")return String(t);if(i==="string")return JSON.stringify(t);if(i!=="object")return JSON.stringify(String(t));const s=n||new WeakSet;return s.has(t)?'"[circular]"':(s.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(f=>k(f,s)).join(",")}]`:`{${Object.keys(t).sort().map(f=>`${JSON.stringify(f)}:${k(t[f],s)}`).join(",")}}`)}function S(t,n){if(N(t))return N(n)?0:1;if(N(n))return-1;const i=k(t),s=k(n);return i<s?-1:i>s?1:0}function y(t){if(N(t))return null;const n=String(t);if(n.trim()==="")return null;try{return JSON.parse(n)}catch{return n}}function u(t){const n=t&&t.cell&&t.cell.props;return z(n)?n:{}}const o=Object.freeze({json:{base:"object",storage:"object",format:t=>L(t&&t.value,u(t&&t.column)),parse:t=>y(t&&t.text),compare:S,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(N(t))return"";if(typeof t=="string")return t;try{const n=JSON.stringify(t,null,2);return n===void 0?String(t):n}catch{return String(t)}},fromClipboard:t=>y(t)},secret:{base:"text",storage:"object",format:t=>U(t&&t.value,u(t&&t.column)),parse:t=>{const n=t&&t.text;return N(n)||String(n)===""?null:String(n)},compare:(t,n)=>{const i=N(t)||t==="",s=N(n)||n==="";return i===s?0:i?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>U(t),fromClipboard:t=>N(t)||String(t)===""?null:String(t)}}),r=o}),ve("packages/core/src/columns/types/unit.js",function(e,V){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.warnOnce;function F(j,E,$,q){return Object.freeze({symbol:j,factor:E,aliases:Object.freeze($||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(j,E,$,q){return F(j,E,$,q)}const _=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),U=Symbol("ambiguous"),B=new Map,H=new Map;function L(j,E){const $=String(j||"").trim();if(!$)throw new Error("[lattice] a unit system needs a name");if(_[$]||H.has($))throw new Error(`[lattice] unit system "${$}" already exists`);const q=[...E||[]];if(!q.length)throw new Error(`[lattice] unit system "${$}" has no units`);if(!q.some(Q=>Q.factor===1))throw new Error(`[lattice] unit system "${$}" has no base unit (none with factor 1)`);const X=new Set;for(const Q of q){if(X.has(Q.symbol))throw new Error(`[lattice] unit system "${$}" declares "${Q.symbol}" twice`);X.add(Q.symbol)}return H.set($,Object.freeze(q)),B.delete($),$}function k(){return[...Object.keys(_),...H.keys()]}function S(j){const E=y(j);return E?E.units:[]}function y(j){const E=String(j||""),$=B.get(E);if($!==void 0)return $;const q=_[E]||H.get(E);if(!q)return B.set(E,null),null;const X=Object.freeze([...q].sort((oe,ie)=>oe.factor-ie.factor)),Q=new Map,J=new Map,ne=(oe,ie)=>{const te=Q.get(oe);te===void 0?Q.set(oe,ie):te!==ie&&Q.set(oe,U)};for(const oe of X){ne(oe.symbol.toLowerCase(),oe);for(const ie of oe.aliases)ne(ie.toLowerCase(),oe);if(oe.prefix){const ie=J.get(oe.prefix)||[];ie.push(oe),J.set(oe.prefix,ie)}}const re={units:X,byToken:Q,byPrefix:J,decimal:X.filter(oe=>!oe.binary&&oe.auto),binary:X.some(oe=>oe.binary)?X.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return B.set(E,re),re}function u(j,E){return E&&j.binary||j.decimal}function o(j,E){const $=y(j);if(!$||N(E))return null;const q=$.units.find(Q=>Q.symbol===String(E));if(q)return q;const X=$.byToken.get(String(E).trim().toLowerCase());return X&&X!==U?X:null}const r=new WeakMap;function t(j){const E=j||{};if(typeof E=="object"&&E!==null){const Q=r.get(E);if(Q!==void 0)return Q}const $=E.system||"data",q=y($);let X=null;if(!q)z(`unit:system:${$}`,`unknown unit system "${$}"; known systems are ${k().join(", ")}`);else{let Q=E.unit?o($,E.unit):null;Q||(E.unit&&z(`unit:unit:${$}:${E.unit}`,`unknown unit "${E.unit}" in system "${$}"; falling back to ${q.units[0].symbol}`),Q=q.units.find(J=>J.factor===1)||q.units[0]),X={index:q,base:Q,binary:E.binary===!0}}return typeof E=="object"&&E!==null&&r.set(E,X),X}const n=new WeakMap;function i(j,E){if(!j||!E||!Array.isArray(j.compound)||j.compound.length===0)return null;const $=n.get(j);if($!==void 0)return $;const q=new Set,X=[];for(const J of j.compound){const ne=o(j.system||"data",J);if(!ne){z(`unit:compound:${j.system}:${J}`,`unknown compound unit "${J}" in system "${j.system||"data"}"; ignoring it`);continue}q.has(ne.symbol)||(q.add(ne.symbol),X.push(ne))}X.sort((J,ne)=>ne.factor-J.factor);const Q=X.length>=2?X:null;return n.set(j,Q),Q}function s(j,E,$){return E===$||E.factor===$.factor?j:j*E.factor/$.factor}const c=new Map;function d(j){const E=j||"",$=c.get(E);if($)return $;const q={group:",",decimal:"."};try{for(const X of new Intl.NumberFormat(j||void 0).formatToParts(12345.6))X.type==="group"?q.group=X.value:X.type==="decimal"&&(q.decimal=X.value)}catch{}return c.set(E,q),q}const f=/[\s ]/g,h=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,g=/^[^\d+\-(.,\s]+\s*/,w=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function p(j,E){const{group:$,decimal:q}=d(E);let X=String(j).replace(f,"");if(X==="")return null;const Q=q?X.indexOf(q):-1;if($&&$!==q){if(Q>=0&&X.indexOf($,Q+q.length)>=0)return null;X=X.split($).join("")}if(q&&q!=="."&&(X=X.split(q).join(".")),!w.test(X))return null;const J=Number(X);return Number.isFinite(J)?J:null}function m(j,E,$){const q=String(j).trim().replace(/\.$/,"");if(q==="")return null;const X=E.units.find(ie=>ie.symbol===q);if(X)return X;const Q=q.toLowerCase(),J=E.byToken.get(Q);if(J===U)return null;if(J)return J;const ne=E.byPrefix.get(Q);if(!ne||!ne.length)return null;const re=u(E,$),oe=ne.filter(ie=>re.includes(ie));return oe.length===1?oe[0]:null}function b(j,E,$,q){let X=j,Q=0,J=!1,ne=!1;for(;X!=="";){const re=h.exec(X)[0];if(re==="")return null;const oe=p(re,q&&q.locale);if(oe===null)return null;X=X.slice(re.length).trim();const ie=X.search(/[+-]?[\d]/),te=(ie>=0?X.slice(0,ie):X).trim();if(X=ie>=0?X.slice(ie).trim():"",te===""){if(J)return null;ne=!0,Q+=s(oe,$[0],E.base)}else{const ce=m(te,E.index,E.binary);if(!ce)return null;Q+=s(oe,ce,E.base)}if(J=!0,ne&&X!=="")return null}return J?Q:null}function v(j,E){if(N(j))return null;if(typeof j=="number")return Number.isFinite(j)?j:null;const $=t(E);if(!$)return null;let q=String(j).trim();if(q==="")return null;let X=!1;q.startsWith("(")&&q.endsWith(")")&&(X=!0,q=q.slice(1,-1).trim());const Q=i(E,$);if(Q){q.startsWith("-")&&(X=!0,q=q.slice(1).trim());const ue=b(q,$,Q,E);return ue===null?null:X?-ue:ue}let J=null;const ne=g.exec(q);if(ne&&ne[0]){const ue=m(ne[0].trim(),$.index,$.binary);ue&&(J=ue,q=q.slice(ne[0].length).trim())}const re=h.exec(q)[0],oe=p(re,E&&E.locale);if(oe===null)return null;const ie=q.slice(re.length).trim();if(J&&ie!=="")return null;const te=J||(ie===""?$.base:m(ie,$.index,$.binary));if(!te)return null;const ce=s(oe,te,$.base);return X?-ce:ce}const l=new Map;function a(j,E,$,q){const X=`${j||""}|${E}|${$}|${q?1:0}`;let Q=l.get(X);return Q||(Q=new Intl.NumberFormat(j||void 0,{minimumFractionDigits:E,maximumFractionDigits:$,useGrouping:q}),l.set(X,Q)),Q}function O(j,E){if(!Number.isFinite(j)||j===0)return Math.max(0,E-1);const $=Math.floor(Math.log10(Math.abs(j)));return Math.min(20,Math.max(0,E-1-$))}function T(j,E){if(!Number.isFinite(j)||j===0)return j;const $=Math.ceil(Math.log10(Math.abs(j))),q=10**(E-$);return Math.round(j*q)/q}function A(j,E,$){if(!$||$===E.base.symbol)return E.base;if($!=="auto")return M(E,$);if(j===0||!Number.isFinite(j))return E.base;const q=Math.abs(j)*E.base.factor,X=u(E.index,E.binary);let Q=X[0];for(const re of X)q>=re.factor&&(Q=re);if(q>=Q.factor)return Q;let J=Q;for(const re of E.index.units)re.binary!==E.binary&&re.factor!==1||re.factor<=q&&re.factor>(J===Q?0:J.factor)&&(J=re);if(J!==Q)return J;let ne=Q;for(const re of E.index.units)re.binary!==E.binary&&re.factor!==1||re.factor<ne.factor&&(ne=re);return ne.factor<E.base.factor?ne:E.base}function M(j,E){const $=j.index.units.find(X=>X.symbol===E);if($)return $;const q=j.index.byToken.get(String(E).toLowerCase());return q&&q!==U?q:(z(`unit:display:${E}`,`unknown display unit "${E}"; rendering in ${j.base.symbol}`),j.base)}function C(j,E,$,q){const X=j<0;let Q=Math.abs(j)*E.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,ne=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),re=q.space??" ",oe=[];for(let te=0;te<$.length;te++){const ce=$[te],ue=te===$.length-1;let ae=ue?Q/ce.factor:Math.floor(Q/ce.factor);if(Q-=ae*ce.factor,ue){const he=10**ne;ae=Math.round(ae*he)/he+0}const pe=ue?a(q.locale,J,ne,q.group!==!1):a(q.locale,0,0,q.group!==!1);oe.push(`${pe.format(ae)}${re}${ce.symbol}`)}const ie=oe.join(" ");return X?`-${ie}`:ie}function P(j,E){const $=E||{},q=$.nullDisplay??"";if(N(j)||j==="")return q;const X=typeof j=="number"?j:Number(j);if(!Number.isFinite(X))return q;const Q=t($);if(!Q)return String(X);const J=i($,Q);if(J)return C(X,Q,J,$);const ne=typeof $.significantFigures=="number"&&$.significantFigures>0?$.significantFigures:0,re=ne?T(X,ne):X,oe=A(re,Q,$.display),ie=s(re,Q.base,oe);let te=typeof $.decimals=="number"?$.decimals:$.minDecimals??0,ce=typeof $.decimals=="number"?$.decimals:$.maxDecimals??Math.max(te,2);ne&&(te=O(ie,ne),ce=te);const ue=a($.locale,te,ce,$.group!==!1).format(ie),ae=$.space??" ";return $.placement==="prefix"?`${oe.symbol}${$.space??""}${ue}`:`${ue}${ae}${oe.symbol}`}function x(j,E){const $=N(j)||Number.isNaN(j)?null:Number(j),q=N(E)||Number.isNaN(E)?null:Number(E);return $===null||Number.isNaN($)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||$<q?-1:$>q?1:0}function K(j){const E=typeof j.decimals=="number"&&j.decimals>0?`.${"0".repeat(j.decimals)}`:"";return`${typeof j.decimals=="number"?`#,##0${E}`:"#,##0.##"}" ${j.symbol}"`}function I(j){const E={system:"data",...j||{}},$=t(E),q=$?$.base.symbol:String(E.unit||""),X=Object.freeze({...E,unit:q}),Q=Object.freeze({...X,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[X.locale||"",X]]),ne=re=>{const oe=re||"";let ie=J.get(oe);return ie||(ie=Object.freeze({...X,locale:re||void 0}),J.set(oe,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:X,format:re=>P(re.value,re.locale?ne(re.locale):X),parse:re=>v(re.text,re.locale?ne(re.locale):X),compare:x,defaults:{filter:"number",editor:"unit",align:"end",total:E.total||"sum"},...E.totals?{totals:E.totals}:{},excel:E.excel||K({decimals:E.decimals,symbol:q}),toStorage:re=>typeof re=="number"?Number.isFinite(re)?re:null:typeof re=="string"?v(re,X):N(re)?null:v(String(re),X),toClipboard:re=>P(re,Q),fromClipboard:re=>v(re,X)}}const D=I}),ve("packages/core/src/columns/types/engineering.js",function(e,V){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isNil,F=V("packages/core/src/columns/types/unit.js").createUnitType;function W(B){const H=2*Math.PI/B;return L=>{let k=0,S=0,y=0;for(const o of L||[]){if(N(o))continue;const r=Number(o);Number.isFinite(r)&&(k+=Math.cos(r*H),S+=Math.sin(r*H),y+=1)}return!y||Math.hypot(k,S)/y<1e-12?null:(Math.atan2(S,k)/H%B+B)%B}}function _(B){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(B)}}}const U=Object.freeze({metres:F({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:F({system:"length",unit:"mm",maxDecimals:2}),kilometres:F({system:"length",unit:"km",maxDecimals:3}),grams:F({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:F({system:"mass",unit:"kg",maxDecimals:3}),tonnes:F({system:"mass",unit:"t",maxDecimals:3}),seconds:F({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:F({system:"duration",unit:"ms",maxDecimals:3}),hours:F({system:"duration",unit:"h",maxDecimals:2}),speed:F({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:F({system:"speed",unit:"km/h",maxDecimals:1}),mph:F({system:"speed",unit:"mph",maxDecimals:1}),knots:F({system:"speed",unit:"kn",maxDecimals:1}),acceleration:F({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:F({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:F({system:"area",unit:"ha",maxDecimals:4}),volume:F({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:F({system:"volume",unit:"m³",maxDecimals:3}),energy:F({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:F({system:"energy",unit:"kWh",maxDecimals:2}),power:F({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:F({system:"power",unit:"kW",maxDecimals:2}),force:F({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:F({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:F({system:"pressure",unit:"bar",maxDecimals:3}),psi:F({system:"pressure",unit:"psi",maxDecimals:1}),torque:F({system:"torque",unit:"N·m",maxDecimals:2}),density:F({system:"density",unit:"kg/m³",maxDecimals:2}),flow:F({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:F({system:"flow",unit:"L/min",maxDecimals:1}),radians:F({system:"angle",unit:"rad",maxDecimals:4,totals:_(2*Math.PI)}),degrees:F({system:"angle",unit:"°",maxDecimals:2,totals:_(360)}),rpm:F({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:F({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:F({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:F({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:F({system:"fraction",unit:"bp",maxDecimals:1}),molarity:F({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:F({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:F({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:F({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:F({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:F({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:F({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:F({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),ve("packages/core/src/columns/types/si.js",function(e,V){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/columns/types/unit.js"),N=Z.defineUnit,z=Z.registerUnitSystem,F=Z.createUnitType,W=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})]),_=Object.freeze(["p","n","µ","m","","k","M","G"]);function U(S){const y=String(S.base),u=new Set([...S.prefixes||_,""]),o=[];for(const r of W){if(!u.has(r.symbol))continue;const t=`${r.symbol}${y}`,n=[];if(S.name){n.push(`${r.name}${S.name}`,`${r.name}${S.name}s`);const i=r.name.slice(-1);if(i&&S.name.startsWith(i)){const s=`${r.name.slice(0,-1)}${S.name}`;n.push(s,`${s}s`)}}r.symbol==="µ"&&n.push(`u${y}`),r.factor===1&&S.aliases&&n.push(...S.aliases),o.push(N(t,r.factor,n))}for(const r of S.extra||[])o.push(r);return o}function B(S,y){const u=U(y);return z(S,u)}function H(S,y,u){return B(S,y),F({system:S,unit:y.base,display:"auto",maxDecimals:3,...u||{}})}const L=Object.freeze({voltage:H("voltage",{base:"V",name:"volt"}),current:H("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:H("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:H("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:H("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:H("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[N("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),N("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:H("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:H("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[N("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:H("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:H("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:H("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:H("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:H("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:H("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:H("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[N("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:H("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),k=H}),ve("packages/core/src/columns/types/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const N=V("packages/core/src/internal/util.js").isNil,z=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:o=>o+273.15,fromKelvin:o=>o-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:o=>(o+459.67)*(5/9),fromKelvin:o=>o*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:o=>o,fromKelvin:o=>o}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:o=>o*(5/9),fromKelvin:o=>o*(9/5)})});function F(o){if(N(o))return null;const r=String(o).trim();if(r==="")return null;for(const[n,i]of Object.entries(z))if(r===n||r===i.symbol)return{key:n,scale:i};const t=r.toLowerCase();for(const[n,i]of Object.entries(z))if(i.aliases.includes(t))return{key:n,scale:i};return null}function W(o,r,t){const n=F(r),i=F(t);return!n||!i||!Number.isFinite(Number(o))?null:n.key===i.key?Number(o):i.scale.fromKelvin(n.scale.toKelvin(Number(o)))}const _=new Map;function U(o,r,t){const n=`${o||""}|${r}|${t}`;let i=_.get(n);return i||(i=new Intl.NumberFormat(o||void 0,{minimumFractionDigits:r,maximumFractionDigits:t}),_.set(n,i)),i}function B(o,r){const t=r||{},n=t.nullDisplay??"";if(N(o)||o==="")return n;const i=Number(o);if(!Number.isFinite(i))return n;const s=F(t.scale||"C");if(!s)return String(i);const c=F(t.display||t.scale||"C")||s,d=c.key===s.key?i:c.scale.fromKelvin(s.scale.toKelvin(i)),f=typeof t.decimals=="number"?t.decimals:null,h=f??t.minDecimals??0,g=f??t.maxDecimals??1;return`${U(t.locale,h,g).format(d)}${t.space??" "}${c.scale.symbol}`}const H=/^[+-]?[\d\s., ]*\d/;function L(o,r){const t=String(o).trim();if(t==="")return null;const n=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(d=>d.type==="decimal")?.value||".",i=n===","?".":",",s=t.split(i).join("").split(/[\s ]/).join("").replace(n,"."),c=Number(s);return Number.isFinite(c)?c:null}function k(o,r){if(N(o))return null;const t=r||{},n=F(t.scale||"C");if(!n)return null;if(typeof o=="number")return Number.isFinite(o)?o:null;let i=String(o).trim();if(i==="")return null;let s=!1;i.startsWith("(")&&i.endsWith(")")&&(s=!0,i=i.slice(1,-1).trim());const c=H.exec(i);if(!c)return null;const d=L(c[0],t.locale);if(d===null)return null;const f=i.slice(c[0].length).trim();if(f==="")return s?-d:d;const h=F(f);if(!h)return null;const g=h.key===n.key?d:n.scale.fromKelvin(h.scale.toKelvin(d));return s?-g:g}function S(o){const r=Object.freeze({scale:"C",...o||{}}),n=(F(r.scale)||F("C")).scale.symbol,i=Object.freeze({...r,display:r.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[r.locale||"",r]]),c=d=>{const f=d||"";let h=s.get(f);return h||(h=Object.freeze({...r,locale:d||void 0}),s.set(f,h)),h};return{base:"number",extends:"number",storage:"float64",temperatureConfig:r,format:d=>B(d.value,d.locale?c(d.locale):r),parse:d=>k(d.text,d.locale?c(d.locale):r),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:r.excel||`#,##0${typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".#"}" ${n}"`,toStorage:d=>typeof d=="number"?Number.isFinite(d)?d:null:typeof d=="string"?k(d,r):N(d)?null:k(String(d),r),toClipboard:d=>B(d,i),fromClipboard:d=>k(d,r)}}const y=Object.freeze({celsius:S({scale:"C"}),fahrenheit:S({scale:"F"}),kelvin:S({scale:"K"})}),u=S}),ve("packages/core/src/columns/types/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Z=V("packages/core/src/internal/util.js"),N=Z.isNil,z=Z.warnOnce,F=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}),W=Object.freeze({2:1,8:3,16:4}),_=Object.freeze({2:"0b",8:"0o",16:"0x"}),U=Object.freeze({2:4,8:3,16:2}),B=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),H=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),L=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,S=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),u=new WeakSet,o=new WeakMap,r=new Map,t=new WeakMap,n=new WeakMap,i=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 s(P){if(P==null)return 16;const x=typeof P=="string"?P.toLowerCase():P,K=F[x];return K||(z(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function c(P,x){return Math.ceil(P/W[x])}function d(P,x){if(!P)return x?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!x)return{min:0,max:2**P-1};const K=2**(P-1);return{min:-K,max:K-1}}function f(P){return H[P]||"hexadecimal"}function h(P){if(typeof P=="string"){const x=i[P];return x||z(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(i).join(", ")}`),{...x||{}}}if(P&&typeof P.preset=="string"){const x=i[P.preset];return x||z(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(i).join(", ")}`),{...x||{},...P}}return P||{}}function g(P){const x=h(P),K=s(x.radix),I=W[K];let D=null;if(x.bitWidth!==void 0&&x.bitWidth!==null&&x.bitWidth!==!1){const re=Number(x.bitWidth);y.includes(re)?D=re:z(`radix:width:${String(x.bitWidth)}`,`unsupported bitWidth ${String(x.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let j=x.signed!==!1;!j&&D===null&&(z("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),D=32);const E=x.prefix===void 0||x.prefix===!0?_[K]:x.prefix===!1?"":String(x.prefix);let $=0;x.pad===!0?$=D?c(D,K):0:typeof x.pad=="number"&&x.pad>0&&($=Math.floor(x.pad));let q=0;x.group===!0?q=U[K]:typeof x.group=="number"&&x.group>0&&(q=Math.floor(x.group));const X=d(D,j),Q=typeof x.min=="number"?Math.max(X.min,x.min):X.min,J=typeof x.max=="number"?Math.min(X.max,x.max):X.max,ne=Object.freeze({radix:K,bits:I,prefix:E,uppercase:x.uppercase!==!1,pad:$,group:q,groupSeparator:typeof x.groupSeparator=="string"?x.groupSeparator:" ",bitWidth:D,signed:j,min:Q,max:J<Q?Q:J,nullDisplay:typeof x.nullDisplay=="string"?x.nullDisplay:"",name:f(K)});return u.add(ne),ne}function w(P){if(P&&u.has(P))return P;if(typeof P=="string"){let x=r.get(P);return x||(x=g(P),r.set(P,x)),x}if(P&&typeof P=="object"){let x=o.get(P);return x||(x=g(P),o.set(P,x)),x}return w("hex")}function p(P){return P<0?-Math.round(-P):Math.round(P)}function m(P,x,K){if(x<=0||P.length<=x)return P;const I=P.length%x||x,D=[P.slice(0,I)];for(let j=I;j<P.length;j+=x)D.push(P.slice(j,j+x));return D.join(K)}function b(P){const x=w(P),{radix:K,prefix:I,uppercase:D,pad:j,group:E,groupSeparator:$,signed:q,bitWidth:X,nullDisplay:Q}=x,J=X?2**X:0,ne=re=>{if(N(re)||re==="")return Q;const oe=typeof re=="number"?re:Number(re);if(!Number.isFinite(oe))return Q;const ie=p(oe);let te="",ce=ie;ie<0&&(q?(te="-",ce=-ie):ce=(ie%J+J)%J);let ue=ce.toString(K);return ue=D?ue.toUpperCase():ue.toLowerCase(),j>0&&ue.length<j&&(ue=ue.padStart(j,"0")),E>0&&(ue=m(ue,E,$)),te+I+ue};return ne.options=x,ne}function v(P,x){const K=w(x);let I=t.get(K);return I||(I=b(K),t.set(K,I)),I(P)}function l(P){const x=w(P),{radix:K,groupSeparator:I,signed:D,min:j,max:E}=x,$=B[K],q=X=>{if(N(X))return{ok:!0,value:null,reason:"blank"};let Q=String(X);if(I&&I!==""&&(Q=Q.split(I).join("")),Q=Q.replace(k,""),Q==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Q[0]==="-"||Q[0]==="+")&&(J=Q[0]==="-",Q=Q.slice(1)),Q==="")return{ok:!1,value:null,reason:"digits"};let ne=null;for(const[oe,ie]of L){const te=oe.exec(Q);if(!te)continue;const ce=Q.slice(te[0].length);if(ce==="")break;if(!B[ie].test(ce))return{ok:!1,value:null,reason:"digits"};ne=parseInt(ce,ie);break}if(ne===null)if($.test(Q))ne=parseInt(Q,K);else if(S.test(Q))ne=Number(Q);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ne))return{ok:!1,value:null,reason:"digits"};const re=p(J?-ne:ne);return!D&&re<0?{ok:!1,value:re,reason:"negative"}:re<j||re>E?{ok:!1,value:re,reason:"range"}:{ok:!0,value:re,reason:"ok"}};return q.options=x,q}function a(P,x){const K=w(x);let I=n.get(K);return I||(I=l(K),n.set(K,I)),I(P)}function O(P,x){const K=a(P,x);return K.ok?K.value:null}function T(P,x){const K=N(P)||Number.isNaN(P)?null:Number(P),I=N(x)||Number.isNaN(x)?null:Number(x);return K===null?I===null?0:1:I===null||K<I?-1:K>I?1:0}function A(P){const x=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&x?"int32":"float64"}function M(P){const x=g(P),K=b(x),I=l(x);return{base:"number",extends:"number",storage:A(x),matches:null,format:D=>K(D.value),parse:D=>{const j=I(D.text);return j.ok?j.value:null},compare:T,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:D=>K(D),fromClipboard:D=>{const j=I(D);return j.ok?j.value:null},radix:x,formatValue:K,parseText:I}}const C=M}),ve("packages/core/src/columns/types/aggregable.js",function(e,V){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isNil;function z(L){const k=[];for(const S of L||[]){if(N(S))continue;const y=Number(S);Number.isFinite(y)&&k.push(y)}return k}function F(L){return k=>{const S=z(k);if(!S.length)return null;let y=0;for(const u of S)y+=10**(u/L);return L*Math.log10(y)}}function W(L){return k=>{const S=z(k);if(!S.length)return null;let y=0;for(const u of S)y+=10**(u/L);return L*Math.log10(y/S.length)}}function _(L,k){const S=k&&k.column,u=(S&&S.typeOptions||{}).weight,o=k&&k.valueAt;if(!u||typeof o!="function")return null;let r=0,t=0;for(let n=0;n<L.length;n++){if(N(L[n]))continue;const i=Number(L[n]);if(!Number.isFinite(i))continue;const s=o(u,n);if(N(s))continue;const c=Number(s);!Number.isFinite(c)||c<=0||(r+=i*c,t+=c)}return t===0?null:r/t}function U(L={}){const k=L.factor===20?20:10,S=typeof L.suffix=="string"?L.suffix:"",y=Number.isInteger(L.decimals)?L.decimals:1;return{base:"number",storage:"float64",name:L.name||"logarithmic",format:u=>{const o=u&&u.value;return N(o)||!Number.isFinite(Number(o))?"":`${Number(o).toFixed(y)}${S}`},parse:u=>{const o=String((u&&u.text)??"").replace(S,"").trim();if(!o)return null;const r=Number(o);return Number.isFinite(r)?r:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:F(k),avg:W(k)}}}}function B(L={}){const k=Number.isInteger(L.decimals)?L.decimals:1,S=L.percent===!0;return{base:"number",storage:"float64",name:L.name||"ratio",format:y=>{const u=y&&y.value;return N(u)||!Number.isFinite(Number(u))?"":S?`${Number(u).toFixed(k)}%`:Number(u).toFixed(k)},parse:y=>{const u=String((y&&y.text)??"").replace("%","").trim();if(!u)return null;const o=Number(u);return Number.isFinite(o)?o:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:_}}}}const H=Object.freeze({decibel:U({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:U({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:B({name:"ratio"}),percentRate:B({name:"percentRate",percent:!0})})}),ve("packages/core/src/columns/types/currency.js",function(e,V){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=V("packages/core/src/internal/util.js").isNil,z="⚠ no rate";function F(d){if(N(d))return null;const f=String(d).trim().toUpperCase();return f===""?null:f}function W(d){if(N(d))return null;if(typeof d=="object"&&!Array.isArray(d)){const f=Number(d.amount),h=F(d.code);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}if(Array.isArray(d)&&d.length===2){const f=Number(d[0]),h=F(d[1]);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}return null}const _=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),U=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),B=/[+-]?[\d\s., ]*\d/;function H(d,f){const h=String(d).trim();if(h==="")return null;const g=new Intl.NumberFormat(f||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",w=g===","?".":",",p=h.split(w).join("").split(/[\s ]/).join("").replace(g,"."),m=Number(p);return Number.isFinite(m)?m:null}function L(d,f){const h=f||{},g=F(h.code);if(N(d))return null;const w=W(d);if(w)return w;if(typeof d=="number")return Number.isFinite(d)&&g?{amount:d,code:g}:null;let p=String(d).trim();if(p==="")return null;let m=!1;p.startsWith("(")&&p.endsWith(")")&&(m=!0,p=p.slice(1,-1).trim());let b=null;for(const[A,M]of Object.entries(_)){if(p.startsWith(A)){b=M,p=p.slice(A.length).trim();break}if(p.endsWith(A)){b=M,p=p.slice(0,-A.length).trim();break}}const v=B.exec(p);if(!v)return null;const l=H(v[0],h.locale);if(l===null)return null;const a=(p.slice(0,v.index)+" "+p.slice(v.index+v[0].length)).trim();!b&&a!==""&&(b=F(a));const O=b||g;return O?{amount:m?-l:l,code:O}:null}function k(d,f){if(typeof d=="function")return(h,g)=>{if(h===g)return 1;const w=d(h,g);return typeof w=="number"&&Number.isFinite(w)&&w>0?w:null};if(d&&typeof d=="object"){const h=d;return(g,w)=>{if(g===w)return 1;const p=Number(h[g]),m=Number(h[w]);return!Number.isFinite(p)||!Number.isFinite(m)||p<=0||m<=0?null:m/p}}return(h,g)=>h===g?1:null}function S(d,f,h){if(!d)return null;if(d.code===f)return d.amount;const g=h(d.code,f);return g===null?null:d.amount*g}const y=new Map;function u(d,f,h){const g=`${d||""}|${f}|${h??""}`;let w=y.get(g);if(!w){const p={style:"currency",currency:f};typeof h=="number"&&(p.minimumFractionDigits=h,p.maximumFractionDigits=h);try{w={fmt:new Intl.NumberFormat(d||void 0,p),currency:!0}}catch{w={fmt:new Intl.NumberFormat(d||void 0,typeof h=="number"?{minimumFractionDigits:h,maximumFractionDigits:h}:{}),currency:!1}}y.set(g,w)}return w}function o(d,f){const h=f||{},g=h.nullDisplay??"",w=W(d);if(!w)return g;const p=F(h.display)||w.code;let m=w.amount,b=w.code;if(p!==w.code){const a=h.rateFn||k(h.rates,h.rateBase),O=S(w,p,a);if(O===null)return`${h.missingRate??z} ${w.code}→${p}`;m=O,b=p}const{fmt:v,currency:l}=u(h.locale,b,h.decimals);return l?v.format(m):`${v.format(m)} ${b}`}function r(d){const f=W(d);return f?`${f.amount} ${f.code}`:""}function t(d){const f=d||{},h=F(f.display),g=f.rateFn||k(f.rates,f.rateBase);return(w,p)=>{const m=W(w),b=W(p);if(!m&&!b)return 0;if(!m)return 1;if(!b)return-1;if(h){const v=S(m,h,g),l=S(b,h,g);if(v!==null&&l!==null)return v===l?0:v<l?-1:1}return m.code===b.code?m.amount===b.amount?0:m.amount<b.amount?-1:1:m.code<b.code?-1:1}}function n(d){const f=d||{},h=(w,p)=>{const m=[];for(const O of w||[]){const T=W(O);T&&m.push(T)}if(!m.length)return null;if(new Set(m.map(O=>O.code)).size===1){const O=m[0].code;return{amount:p(m.map(T=>T.amount)),code:O}}const v=F(f.display);if(!v)return`${f.missingRate??z}: mixed currencies, no display currency set`;const l=f.rateFn||k(f.rates,f.rateBase),a=[];for(const O of m){const T=S(O,v,l);if(T===null)return`${f.missingRate??z}: ${O.code}→${v}`;a.push(T)}return{amount:p(a),code:v}},g=w=>w.reduce((p,m)=>p+m,0);return{sum:w=>h(w,g),avg:w=>h(w,p=>g(p)/p.length),min:w=>h(w,p=>Math.min(...p)),max:w=>h(w,p=>Math.max(...p))}}function i(d){const f=Object.freeze({code:"USD",...d||{}}),h=k(f.rates,f.rateBase),g=Object.freeze({...f,rateFn:h}),w=n(g),p=t(g),m=new Map([[f.locale||"",g]]),b=a=>{const O=a||"";let T=m.get(O);return T||(T=Object.freeze({...g,locale:a||void 0}),m.set(O,T)),T},v=U[F(f.display||f.code)]||"",l=typeof f.decimals=="number"&&f.decimals>0?`.${"0".repeat(f.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:g,format:a=>o(a.value,a.locale?b(a.locale):g),parse:a=>L(a.text,a.locale?b(a.locale):g),compare:p,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:w},excel:f.excel||(v?`"${v}"#,##0${l}`:`#,##0${l}`),toStorage:a=>{const O=W(a);return O||(typeof a=="string"||typeof a=="number"?L(a,g):null)},toClipboard:a=>r(a),fromClipboard:a=>L(a,g)}}const s=Object.freeze({currency:i({code:"USD"}),usd:i({code:"USD"}),eur:i({code:"EUR"}),gbp:i({code:"GBP"}),jpy:i({code:"JPY",decimals:0})}),c=i}),ve("packages/core/src/columns/types/index.js",function(e,V){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return A}});const Z=V("packages/core/src/columns/types/temporal.js"),N=Z.TEMPORAL_TYPES,z=V("packages/core/src/columns/types/network.js"),F=z.NETWORK_TYPES,W=V("packages/core/src/columns/types/structured.js"),_=W.STRUCTURED_TYPES,U=V("packages/core/src/columns/types/unit.js"),B=U.createUnitType,H=U.UNIT_SYSTEMS,L=U.parseUnit,k=U.formatUnit,S=U.registerUnitSystem,y=U.unitSystemNames,u=U.unitsOf,o=U.defineUnit,r=V("packages/core/src/columns/types/engineering.js"),t=r.ENGINEERING_TYPES,n=V("packages/core/src/columns/types/si.js"),i=n.SI_TYPES,s=n.createSiType,c=n.createSiSystem,d=n.siUnits,f=n.SI_PREFIXES,h=V("packages/core/src/columns/types/temperature.js"),g=h.TEMPERATURE_TYPES,w=h.createTemperatureType,p=h.convertTemperature,m=h.formatTemperature,b=h.parseTemperature,v=h.TEMPERATURE_SCALES,l=V("packages/core/src/columns/types/radix.js"),a=l.createRadixType,O=l.RADIX_PRESETS,T=l.parseRadix,A=l.formatRadix,M=V("packages/core/src/columns/types/aggregable.js"),C=M.AGGREGABLE_TYPES,P=V("packages/core/src/columns/types/currency.js"),x=P.CURRENCY_TYPES,K=P.createCurrencyType,I=P.parseMoney,D=P.formatMoney,j=P.convertMoney,E=P.toMoney,$=P.rateFunction,q=P.moneyComparator,X=P.normaliseCode,Q=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return U.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return r.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return r.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return h.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return h.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return h.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return h.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return h.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return h.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return h.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return P.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return P.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return P.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return P.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return P.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return P.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return P.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return P.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return P.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Z.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return z.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return W.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return M.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return M.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return M.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Z.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Z.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Z.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Z.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Z.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Z.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return z.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return z.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return z.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return z.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return z.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return z.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return z.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return z.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return z.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return z.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return z.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return W.summariseJson}});const J=Object.freeze({...N,...F,..._,...C,hex:a(O.hex),hex8:a(O.hex8),hex16:a(O.hex16),hex32:a(O.hex32),binary:a(O.binary),binary8:a(O.binary8),octal:a(O.octal),bytes:B({system:"data",unit:"B",display:"auto"}),megabytes:B({system:"data",unit:"MB"}),gigabytes:B({system:"data",unit:"GB"}),bitrate:B({system:"bitrate",unit:"Mbps"}),gigabits:B({system:"bitrate",unit:"Gbps"}),...t,...i,...g,...x});{const ne=new Set;for(const re of[N,F,_,C,t,i,g,x])for(const oe of Object.keys(re)){if(ne.has(oe))throw new Error(`[lattice] data type "${oe}" is declared twice`);ne.add(oe)}}}),ve("packages/core/src/columns/datatypes.js",function(e,V){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return C}});const Z=V("packages/core/src/internal/util.js"),N=Z.collator,z=Z.defaultCompare,F=Z.isNil,W=Z.isObject,_=Z.isFunction,U=Z.fail,B=Z.titleCase,H=V("packages/core/src/format/date.js"),L=H.toDate,k=H.toIsoDate,S=H.compareIso,u=V("packages/core/src/format/boolean.js").toTriState,r=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=V("packages/core/src/formula/index.js"),n=t.evaluateFormula,i=t.looksLikeFormula,s=/^\d{4}-\d{2}-\d{2}$/;function c(P){return P.getHours()===0&&P.getMinutes()===0&&P.getSeconds()===0&&P.getMilliseconds()===0}const d=new Map;function f(P){const x=P||"",K=d.get(x);if(K)return K;const I={group:",",decimal:"."};try{for(const D of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))D.type==="group"?I.group=D.value:D.type==="decimal"&&(I.decimal=D.value)}catch{}return d.set(x,I),I}const h=/\d\s*[*/^]\s*[\d.(]/;function g(P,x){if(F(P))return null;let K=String(P).trim();if(K===""||K.startsWith("=")||h.test(K))return null;let I=1;K.startsWith("(")&&K.endsWith(")")&&(I=-1,K=K.slice(1,-1));const D=K.endsWith("%"),{group:j,decimal:E}=f(x);if(K=K.replace(/[\s\u00a0\u202f\u2009']/g,""),j&&j!=="."&&j!==","&&(K=K.split(j).join("")),K=K.replace(/[^0-9eE+\-.,]/g,""),E===","?K=K.split(".").join("").replace(",","."):K=K.split(",").join(""),K===""||K==="-"||K==="+")return null;const $=Number(K);return Number.isNaN($)?null:I*(D?$/100:$)}function w(P,x){const K=F(P)||Number.isNaN(P)?null:Number(P),I=F(x)||Number.isNaN(x)?null:Number(x);return K===null?I===null?0:1:I===null||K<I?-1:K>I?1:0}function p(P,x){const K=u(P),I=u(x);return K===null?I===null?0:1:I===null?-1:K===I?0:K?1:-1}function m(P,x){const K=L(P),I=L(x);if(!K)return I?1:0;if(!I)return-1;const D=K.getTime(),j=I.getTime();return D<j?-1:D>j?1:0}const b=new Map;function v(P){const x=L(P.value);if(!x)return"";const K=P.locale||"";let I=b.get(K);return I||(I=new Intl.DateTimeFormat(P.locale||void 0,{dateStyle:"medium"}),b.set(K,I)),I.format(x)}const l={boolean:{base:"boolean",storage:"bitset",matches:P=>typeof P=="boolean",parse:P=>u(P.text),compare:p,format:P=>u(P.value)===null?"":u(P.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:P=>u(P)===null?"":String(u(P)),fromClipboard:P=>u(P)},number:{base:"number",storage:"float64",matches:P=>typeof P=="number"&&!Number.isNaN(P),parse:P=>{if(i(P.text)){const x=n(P.text,P);if(!x.ok)return null;const K=Number(x.value);return Number.isFinite(K)?K:null}return g(P.text,P.locale)},compare:w,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:P=>F(P)?"":String(P),fromClipboard:(P,x)=>g(P,x&&x.locale)},date:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&s.test(P)&&!Number.isNaN(Date.parse(P))||P instanceof Date&&!Number.isNaN(P.getTime())&&c(P),parse:P=>k(P.text),compare:S,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>F(P)?"":String(P),fromClipboard:P=>k(P)},dateString:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&s.test(P)&&!Number.isNaN(Date.parse(P)),parse:P=>k(P.text),compare:S,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>F(P)?"":String(P),fromClipboard:P=>k(P)},text:{base:"text",storage:"dictionary",matches:P=>typeof P=="string",parse:P=>P.text===""?null:String(P.text),compare:(P,x)=>F(P)?F(x)?0:1:F(x)?-1:N().compare(String(P),String(x)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:P=>F(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,x)=>F(P)?F(x)?0:1:F(x)?-1:N().compare(String(P),String(x)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:P=>F(P)?"":String(P),fromClipboard:P=>P},lookup:{base:"text",storage:"dictionary",parse:P=>{if(P.text===""||P.text==null)return null;const x=P.column&&P.column.lookup,K=x&&_(x.options)?x.options():null;if(!K)return P.text;const I=String(P.text),D=K.find($=>String($.id)===I);if(D)return D.id;const j=I.trim().toLowerCase(),E=K.find($=>String($.label).toLowerCase()===j);return E?E.id:P.text},compare:z,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:P=>F(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,x)=>z(P,x),format:P=>{const x=P.value;if(F(x))return"";if(typeof x=="string")return x;try{return JSON.stringify(x)}catch{return String(x)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:P=>F(P)?"":typeof P=="string"?P:JSON.stringify(P),fromClipboard:P=>P}},a=["boolean","number","date","dateString","datetime","text","object"];function O(P,x,K,I){const D=K.get(P);if(D)return D;I.includes(P)&&U(`circular data type extends chain: ${[...I,P].join(" → ")}`);const j=x[P];j||U(`unknown data type "${P}"`);let E=null;j.extends&&(E=O(j.extends,x,K,[...I,P]));const $={...E||{},...j,name:P,defaults:{...E&&E.defaults||{},...j.defaults||{}}};return $.base||($.base=E&&E.base||"text"),$.storage||($.storage=E&&E.storage||"object"),K.set(P,$),$}function T(P,x){const K={...l,...r};if(x&&typeof x.dataType=="function"&&Array.isArray(x.dataTypeNames))for(const D of x.dataTypeNames()){const j=x.dataType(D);j&&(K[D]=j)}if(W(P))for(const[D,j]of Object.entries(P))K[D]=j;const I=new Map;for(const D of a)O(D,K,I,[]);O("lookup",K,I,[]);for(const D of Object.keys(K))O(D,K,I,[]);return I}function A(P,x){if(P.base==="text"&&(!P.compare||P.compare===l.text.compare)){const K=N(x);return(I,D)=>F(I)?F(D)?0:1:F(D)?-1:K.compare(String(I),String(D))}return P.compare||z}function M(P,x){return x?P.multiStorage||"multi":P.storage||"object"}function C(P){return B(String(P).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),ve("packages/core/src/columns/infer.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return _}});const Z=V("packages/core/src/internal/util.js"),N=Z.infoOnce,z=Z.isNil,F=100;function W(U,B,H={}){const L=H.sampleSize??F,k=[];for(let S=0;S<U.length&&k.length<L;S++){const y=U[S];z(y)||typeof y=="number"&&Number.isNaN(y)||k.push(y)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[S,y]of B){if(typeof y.matches!="function")continue;let u=!0;for(let o=0;o<k.length;o++)if(!y.matches(k[o])){u=!1;break}if(u)return{type:S,unanimous:!0,sampled:k.length}}return H.quiet||N(`infer:${H.colId||"?"}`,`column "${H.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:k.length}}function _(U,B,H,L,k={}){const S=k.sampleSize??F,y=[];for(let u=0;u<B.length&&y.length<S;u++){const o=H(B[u]);z(o)||typeof o=="number"&&Number.isNaN(o)||y.push(o)}return W(y,L,{...k,colId:U}).type}}),ve("packages/core/src/columns/graph.js",function(e,V){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return L}});const Z=V("packages/core/src/internal/util.js"),N=Z.DEV,z=Z.fail,F=Z.isFunction,W=Z.warnOnce,_="*";function U(k){const S=k.value||{};if(!F(S.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const u=S.pure!==!1;return S.deps===_?{computed:!0,wholeRow:!0,deps:[],pure:u}:Array.isArray(S.deps)?{computed:!0,wholeRow:!1,deps:S.deps.slice(),pure:u}:(W(`deps:missing:${k.id}`,`computed column "${k.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:u})}function B(k){const S=new Map;for(const h of k)S.set(h.id,h);const y=new Map,u=new Map,o=new Set,r=new Set,t=new Set,n=new Set;for(const h of k){const g=U(h);if(!g.computed){y.set(h.id,[]);continue}r.add(h.id),(g.pure?t:n).add(h.id),g.wholeRow&&o.add(h.id);const w=[],p=[];for(const m of g.deps)(S.has(m)?w:p).push(m);y.set(h.id,w),p.length&&u.set(h.id,p)}for(const h of t)for(const g of y.get(h))n.has(g)&&z(`pure computed column "${h}" depends on impure column "${g}". Mark it \`value.pure: false\` or make the dependency pure.`);const i=[],s=new Map,c=[],d=h=>{const g=s.get(h);if(g!=="done"){if(g==="open"){const w=c.indexOf(h);z(`circular column dependency: ${[...c.slice(w),h].join(" → ")}`)}s.set(h,"open"),c.push(h);for(const w of y.get(h)||[])S.has(w)&&d(w);c.pop(),s.set(h,"done"),i.push(h)}};for(const h of k)d(h.id);const f=new Map;for(const h of k)f.set(h.id,[]);for(const h of k)for(const g of y.get(h.id)||[]){const w=f.get(g);w&&!w.includes(h.id)&&w.push(h.id)}if(o.size)for(const h of k){if(r.has(h.id))continue;const g=f.get(h.id);for(const w of o)g.includes(w)||g.push(w)}return{order:i,dependents:f,pure:t,impure:n,computed:r,deps:y,wholeRow:o,external:u,index:S}}function H(k,S){const y=Array.isArray(S)?S:[S],u=new Set,o=[...y];for(;o.length;){const r=o.shift();for(const t of k.dependents.get(r)||[])u.has(t)||(u.add(t),o.push(t))}for(const r of y)u.delete(r);return k.order.filter(r=>u.has(r))}function L(k,S,y){if(!N)return k;const u=S instanceof Set?S:new Set(S);return new Proxy(k,{get(o,r){return typeof r=="string"&&!u.has(r)&&!Object.hasOwn(o,r)&&W(`undeclared:${y}:${r}`,`computed column "${y}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),o[r]}})}}),ve("packages/core/src/columns/lookup.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),N=Z.collator,z=Z.defaultCompare,F=Z.isFunction,W=Z.isNil,_=Z.warnOnce,U=", ",B="";function H(u,o,r,t){if(u===null||typeof u!="object")return{id:u,label:u==null?"":String(u)};const n=u[o],i=u[r],s={id:n,label:i==null?String(n??""):String(i)};u.disabled&&(s.disabled=!0),u.variant&&(s.variant=u.variant),u.icon&&(s.icon=u.icon);const c=t?u[t]:u.group;return c!==void 0&&(s.group=c),s}function L(u,o,r=0,t=[],n=[]){for(const i of u||[]){const s=i&&typeof i=="object"?i[o]:null;if(n.push({raw:i,depth:r,path:t}),Array.isArray(s)&&s.length){const c=String(i&&typeof i=="object"?i.label??i.name??i.id??"":i);L(s,o,r+1,[...t,c],n)}}return n}class k{#e;#t;#n;#r;#o=[];#i=new Map;#a=new Map;#s=0;#l="idle";#u=null;#c;constructor(o,r={}){this.#e=o||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=N(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#l="ready")}get colId(){return this.#t}get version(){return this.#s}get state(){return this.#l}get ready(){return this.#l==="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(o){this.#n=o,this.#c=N(o)}#d(o){const r=this.#e,t=r.valueKey||"id",n=r.labelKey||"label",i=r.childrenKey||"children";this.#o=L(o,i).map(s=>{const c=H(s.raw,t,n,r.groupKey);return s.depth&&(c.depth=s.depth,c.path=s.path),c}),this.#i=new Map,this.#a=new Map,this.#o.forEach((s,c)=>{this.#i.set(s.id,s),this.#a.set(s.id,c)}),this.#l="ready",this.#s+=1}load(){if(this.#u)return this.#u;const o=this.#e.options;if(Array.isArray(o)||o===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(!F(o))return _(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#l="ready",this.#u=Promise.resolve([]),this.#u;this.#l="loading";let r;try{r=o()}catch(t){return this.#l="error",_(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!r||!F(r.then)?(this.#d(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#l="error",_(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#d(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}search(o,r){const t=this.#e;if(!F(t.search)){const s=String(o||"").toLowerCase();return Promise.resolve(s===""?this.#o:this.#o.filter(c=>c.label.toLowerCase().includes(s)))}const n=t.valueKey||"id",i=t.labelKey||"label";return Promise.resolve(t.search(o,r)).then(s=>(s||[]).map(c=>H(c,n,i,t.groupKey)))}option(o){return this.#i.get(o)}has(o){return this.#i.has(o)}label(o){if(W(o)||o==="")return"";const r=this.#i.get(o);if(r)return r.label;if(this.#l==="loading"||this.#l==="idle")return"";this.allowCustom||_(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(o)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const t=this.#e.unknownLabel;return F(t)?String(t(o)??""):typeof t=="string"?t:String(o)}text(o){if(this.multiple){const r=S(o);return r.length===0?"":r.map(t=>this.label(t)).join(this.separator)}return this.label(o)}dictionary(){return this.#o.map(o=>o.id)}sorted(){const o=this.sortBy;if(o==="optionOrder"||o==="count")return this.#o.slice();if(o==="value")return this.#o.slice().sort((t,n)=>z(t.id,n.id));const r=this.#c;return this.#o.slice().sort((t,n)=>r.compare(t.label,n.label))}comparator(){const o=this.sortBy,r=this.multiple,t=this.#c,n=this.#a;if(r&&o==="count")return(s,c)=>S(s).length-S(c).length;const i=r?s=>S(s)[0]:s=>s;return o==="value"?(s,c)=>z(i(s),i(c)):o==="optionOrder"?(s,c)=>{const d=n.has(i(s))?n.get(i(s)):Number.MAX_SAFE_INTEGER,f=n.has(i(c))?n.get(i(c)):Number.MAX_SAFE_INTEGER;return d-f}:(s,c)=>{const d=i(s),f=i(c);return W(d)?W(f)?0:1:W(f)?-1:t.compare(this.label(d),this.label(f))}}groupKey(o){return this.multiple?S(o).map(t=>String(t)).sort().join(B):W(o)?"":String(o)}countValues(o){return this.multiple?S(o).length:W(o)?0:1}contains(o,r,t){const n=this.multiple?S(o):W(o)?[]:[o],i=Array.isArray(r)?r:[r];switch(t){case"containsAll":return i.every(s=>n.includes(s));case"containsNone":return!i.some(s=>n.includes(s));default:return i.some(s=>n.includes(s))}}exportText(o,r="label"){return r==="value"?this.multiple?S(o).join(this.separator):W(o)?"":String(o):this.text(o)}exportColumns(){const o=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:t=>o?S(t).includes(r.id):t===r.id}))}}function S(u){return Array.isArray(u)?u:W(u)||u===""?[]:[u]}function y(u,o={}){const r=u.lookup;if(!r)return null;const t=new k(r,{colId:u.id,locale:o.locale,onChange:o.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&t.load(),t}}),ve("packages/core/src/columns/value.js",function(e,V){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),N=Z.getPath,z=Z.isFunction,F=Z.isNil,W=Z.Lru,_=Z.warnOnce,B=V("packages/core/src/columns/graph.js").depsProxy,H="\0";function L(t,n={}){const i=n.locale,s=n.grid??null,c=n.context,d=t.value&&t.value.format,f=t.formatter||null,h=t.dataType&&t.dataType.format,g=t.lookup||null,w=(p,m,b)=>({value:p,data:b,row:m,column:t,colId:t.id,grid:s,context:c,locale:i});if(z(d))return(p,m,b)=>{const v=d(w(p,m,b));return v==null?"":String(v)};if(f){if(g){const p=f.kind==="text";return(m,b,v)=>f(p?g.text(m):m,w(m,b,v))}return(p,m,b)=>f(p,w(p,m,b))}return z(h)?(p,m,b)=>{const v=h(w(p,m,b));return v==null?"":String(v)}:g?p=>g.text(p):p=>F(p)?"":typeof p=="string"?p:String(p)}function k(t,n){!t||!t.value||t.value.pure!==!1||_(`impure:${n}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class S{#e;#t;#n;#r;#o;#i;#a=new W(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(i=>[i.id,i])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#o=n.rowKey||y}get graph(){return this.#t}setGraph(n){this.#t=n,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(n){if(this.#a.size===0)return;const i=n&&n.rows?new Set([...n.rows].map(String)):null,s=n&&n.columns?[...n.columns]:null;if(!i&&!s){this.#a.clear();return}const c=s?this.#s(s):null;for(const d of[...this.#a.keys()]){const f=String(d).split(H);f.length===3&&(i&&!i.has(f[0])||c&&!c.has(f[2])||this.#a.delete(d))}}#s(n){const i=new Set,s=this.#t,c=[...n];for(;c.length;){const d=c.pop();if(!i.has(d)){i.add(d);for(const f of s?s.dependents.get(d)||[]:[])c.push(f)}}return i}value(n,i,s){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return;if(!c.computed)return this.#u(c,i,s);if(c.value.pure!==!1&&this.#i&&s&&s.physical!=null&&this.#i.has(c.id))return this.#i.get(c.id,s.physical);if(c.volatile)return this.compute(c,i,s);if(c.value.pure===!1)return this.compute(c,i,s);const d=`${this.#l(i,s)}${H}${c.id}`;if(this.#a.has(d))return this.#a.get(d);const f=this.compute(c,i,s);return this.#a.set(d,f),f}#l(n,i){return`${this.#o(n,i)}${H}${u(n)}`}#u(n,i,s){if(this.#i&&s&&s.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,s.physical);if(n.field)return n.read?n.read(i):N(i,n.field)}compute(n,i,s){const c=this.#t,d=c&&c.wholeRow.has(n.id);let f;if(d)f=i??{};else{f={};const g=c&&c.deps.get(n.id)||[];for(const p of g)f[p]=this.value(p,i,s);const w=c&&c.external.get(n.id)||[];for(const p of w)f[p]=N(i,p);f=B(f,[...g,...w],n.id)}const h={data:i,row:s,column:n,grid:this.#n,context:this.#r};return n.value.compute(f,h)}values(n,i){const s={},c=this.#t?this.#t.order:[...this.#e.keys()];for(const d of c)s[d]=this.value(d,n,i);return s}text(n,i,s){const c=typeof n=="string"?this.#e.get(n):n;return c?c.formatValue(this.value(c,i,s),s,i):""}key(n,i,s){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return"";const d=this.value(c,i,s);return z(c.value.key)?String(c.value.key(this.#c(c,d,i,s))):c.lookup?c.lookup.groupKey(d):F(d)?"":String(d)}quickFilterText(n,i,s){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return"";if(z(c.value.quickFilterText)){const d=this.value(c,i,s);return String(c.value.quickFilterText(this.#c(c,d,i,s))??"")}return this.text(c,i,s)}#c(n,i,s,c){return{value:i,data:s,row:c,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,i,s,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return i;const f={text:i,value:this.value(d,s,c),data:s,row:c,column:d,grid:this.#n,context:this.#r,locale:this.#n&&z(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&z(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return z(d.value.parse)?d.value.parse(f):d.dataType&&z(d.dataType.parse)?d.dataType.parse(f):i}validate(n,i,s,c,d){const f=typeof n=="string"?this.#e.get(n):n;if(!f||!z(f.edit.validate))return!0;const h=f.edit.validate({value:i,oldValue:s,data:c,row:d,column:f,grid:this.#n,context:this.#r});return h===!0||h===void 0?!0:String(h)}apply(n,i,s,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return!1;const f=this.value(d,s,c);if(z(d.value.apply)){const h=d.value.apply({value:i,oldValue:f,data:s,row:c,column:d,grid:this.#n,context:this.#r});return this.#d(d,s,c),h!==!1}return d.field?f===i?!1:(d.write(s,i),this.#d(d,s,c),!0):(_(`apply:${d.id}`,`column "${d.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,i,s,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const f=this.value(d,s,c),h=this.parse(d,i,s,c),g=this.validate(d,h,f,s,c);if(g!==!0)return{ok:!1,value:h,oldValue:f,changed:!1,error:g};const w=this.apply(d,h,s,c);return{ok:!0,value:h,oldValue:f,changed:w}}#d(n,i,s){if(this.#a.size===0)return;const c=this.#l(i,s);this.#a.delete(`${c}${H}${n.id}`);for(const d of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#a.delete(`${c}${H}${d}`)}}function y(t,n){return n&&n.key!=null?String(n.key):u(t)}function u(t){if(t&&typeof t=="object"){let n=o.get(t);return n===void 0&&(n=`#${r++}`,o.set(t,n)),n}return String(t)}const o=new WeakMap;let r=0}),ve("packages/core/src/model/shadow.js",function(e,V){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return f}});const N=V("packages/core/src/internal/util.js").warnOnce,z=2e5,F=20,W=1e3,_=50;function U(h){return Math.min(W,Math.max(_,Math.floor(h)))}const B=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),H=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),L=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),k=.6745,S=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),o=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function r(h,g){if(!g)return null;const w=Number.isFinite(Number(g.lower))?Number(g.lower):null,p=Number.isFinite(Number(g.upper))?Number(g.upper):null;if(w===null&&p===null||!Number.isFinite(h))return null;if(w!==null&&h<w||p!==null&&h>p)return y.FAIL;const m=Number.isFinite(Number(g.warnLower))?Number(g.warnLower):null,b=Number.isFinite(Number(g.warnUpper))?Number(g.warnUpper):null;return m!==null&&h<m||b!==null&&h>b?y.WARN:y.PASS}function t(h,g,w){if(!g||typeof g!="object")return null;if(g.kind!=="time")return g.kind!==void 0&&N(`shadow.history.window.kind:${h}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${g.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 p=g.minutes!=null?Number(g.minutes)*6e4:Number(g.span);if(!(p>0))return N(`shadow.history.window.span:${h}`,"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 m=Math.max(2,Math.floor(w)||F);return{span:p,bucketMs:Math.max(1,Math.floor(p/m))}}class n{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#a=new Map;#s=0;#l;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(g){this.#e=g.colId,this.#l=Math.max(2,g.depth||F),this.#u=Math.max(1,g.max||z),this.#c=g.now||(()=>Date.now()),this.#d=t(this.#e,g.historyWindow,this.#l),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#s}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(g,w){const p=d(w);if(p===null)return;if(!this.#n.has(g)){this.#m=null,this.#p=null,this.#g(),this.#t.set(g,p),this.#n.set(g,p),this.#r.set(g,0),this.#o.set(g,this.#c()),this.#i.set(g,[p]),this.#d&&this.#h.set(g,[p]),this.#a.set(g,0);return}const m=this.#n.get(g);if(m===p)return;this.#m=null,this.#p=null,this.#n.set(g,p),this.#r.set(g,(this.#r.get(g)||0)+1),this.#o.set(g,this.#c());const b=this.#i.get(g)||[];b.push(p),b.length>this.#l&&b.splice(0,b.length-this.#l),this.#i.set(g,b);const v=Math.sign(p-m),l=this.#a.get(g)||0;this.#a.set(g,Math.sign(l)===v?l+v:v)}#g(){if(this.#n.size<this.#u)return;const g=this.#n.keys().next().value;g!==void 0&&(this.#t.delete(g),this.#n.delete(g),this.#r.delete(g),this.#o.delete(g),this.#i.delete(g),this.#h.delete(g),this.#a.delete(g),this.#s++)}rebase(){for(const[g,w]of this.#n)this.#t.set(g,w);this.#m=null,this.#p=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#a.clear(),this.#s=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(g){const w=g instanceof Set?g:new Set(g);let p=0;for(const m of[...this.#n.keys()])w.has(m)||(this.#t.delete(m),this.#n.delete(m),this.#r.delete(m),this.#o.delete(m),this.#i.delete(m),this.#h.delete(m),this.#a.delete(m),p++);return p&&(this.#m=null,this.#p=null),p}advanceHistoryWindow(g=this.#c()){const w=this.#d;if(!w)return 0;const p=Math.floor(g/w.bucketMs),m=p-this.#f;if(!(m>0))return 0;const b=Math.min(m,this.#l);for(const[v,l]of this.#h){const a=this.#n.get(v);for(let O=0;O<b;O++)l.push(a);l.length>this.#l&&l.splice(0,l.length-this.#l)}return this.#f=p,m}read(g,w,p,m){switch(g){case"updates":return this.#r.has(w)?this.#r.get(w):0;case"updatedAt":{const b=this.#o.get(w);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(w);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(w)?this.#t.get(w):null;case"delta":return this.#n.has(w)?this.#n.get(w)-this.#t.get(w):null;case"deltaPercent":{if(!this.#n.has(w))return null;const b=this.#t.get(w);return b?(this.#n.get(w)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(w),v=this.#o.get(w);if(!b||b.length<2||v===void 0)return null;const l=this.#c()-v,a=b[b.length-1]-b[b.length-2];return l>0?a/l*1e3:a}case"history":return this.#d?this.#h.has(w)?[...this.#h.get(w)]:null:this.#i.has(w)?[...this.#i.get(w)]:null;case"streak":return this.#a.has(w)?this.#a.get(w):0;case"specStatus":return this.#n.has(w)?r(this.#n.get(w),m):null;default:return u.includes(g)?this.#y(g,w,p,m):null}}#v(g){if(g){if(this.#p&&this.#p.only===g)return this.#p.view;const w=this.#b(g);return this.#p={only:g,view:w},w}return this.#m?this.#m:(this.#m=this.#b(null),this.#m)}#b(g){const w=[];for(const[M,C]of this.#n)g&&!g.has(M)||w.push(C);const p=w.sort((M,C)=>M-C);let m=0,b=0,v=0,l=0;for(const M of p){l+=M,m++;const C=M-b;b+=C/m,v+=C*(M-b)}const a=[];for(const[M,C]of this.#t)g&&!g.has(M)||a.push(C);const O=m?i(p):0,T=p.map(M=>Math.abs(M-O)).sort((M,C)=>M-C),A=m?i(T):0;return{sorted:p,baseline:a.sort((M,C)=>M-C),sum:l,mean:m?b:0,sd:m>1?Math.sqrt(v/(m-1)):0,median:O,mad:A}}#y(g,w,p,m){if(!this.#n.has(w)||p&&!p.has(w))return null;const b=this.#n.get(w),v=this.#v(p),l=v.sorted.length;if(!l)return null;switch(g){case"rank":return l-c(v.sorted,b)+1;case"rankAsc":return s(v.sorted,b)+1;case"rankChange":{if(!this.#t.has(w)||!v.baseline.length)return null;const a=v.baseline.length-c(v.baseline,this.#t.get(w))+1,O=l-c(v.sorted,b)+1;return a-O}case"percentile":return c(v.sorted,b)/l*100;case"quartile":{const a=c(v.sorted,b)/l;return Math.min(4,Math.max(1,Math.ceil(a*4)))}case"zScore":return v.sd?(b-v.mean)/v.sd:null;case"anomalyScore":return v.mad?k*(b-v.median)/v.mad:null;case"anomalyFlag":{if(!v.mad)return null;const a=m&&Number.isFinite(Number(m.threshold))?Number(m.threshold):S;return Math.abs(k*(b-v.median)/v.mad)>a}case"shareOfTotal":return v.sum?b/v.sum*100:null;default:return null}}}function i(h){const g=h.length;if(!g)return 0;const w=(g-1)*.5,p=Math.floor(w),m=Math.ceil(w);return p===m?h[p]:h[p]+(w-p)*(h[m]-h[p])}function s(h,g){let w=0,p=h.length;for(;w<p;){const m=w+p>>1;h[m]<g?w=m+1:p=m}return w}function c(h,g){let w=0,p=h.length;for(;w<p;){const m=w+p>>1;h[m]<=g?w=m+1:p=m}return w}function d(h){if(h==null||h==="")return null;if(h instanceof Date){const w=h.getTime();return Number.isFinite(w)?w:null}const g=typeof h=="number"?h:Number(h);return Number.isFinite(g)?g:null}function f(h){const g=[];for(const w of h||[]){const p=w.shadow;if(!p)continue;const m=typeof p=="string"?{kind:p}:p,b=m.kind;B.includes(b)&&(H.includes(b)||L.includes(b)||g.push({colId:w.id||w.field,of:m.of||w.field||w.id,kind:b,depth:m.depth,historyWindow:b==="history"?m.window:void 0}))}return g}}),ve("packages/core/src/columns/model.js",function(e,V){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return re}});const Z=V("packages/core/src/internal/util.js"),N=Z.expand,z=Z.fail,F=Z.getPath,W=Z.humanise,_=Z.isFunction,U=Z.isObject,B=Z.merge,H=Z.pathGetter,L=Z.pathSetter,k=Z.toArray,S=Z.uid,y=Z.warnOnce,o=V("packages/core/src/format/index.js").compileFormat,r=V("packages/core/src/columns/datatypes.js"),t=r.comparatorFor,n=r.createTypeRegistry,i=r.storageKind,s=V("packages/core/src/columns/infer.js"),c=s.inferColumnType,d=s.DEFAULT_SAMPLE,f=V("packages/core/src/columns/graph.js"),h=f.buildGraph,g=f.affectedBy,p=V("packages/core/src/columns/lookup.js").createLookup,m=V("packages/core/src/columns/value.js"),b=m.compileDisplay,v=m.ValuePipeline,l=m.warnImpureUse,O=V("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,T={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},A={centre:"center"},M=new Set(["start","center","end","left","right"]);function C(ie){if(typeof ie!="string")return;const te=ie.toLowerCase();return A[te]?A[te]:M.has(te)?te:void 0}function P(ie){if(typeof ie!="string")return;const te=ie.toLowerCase();return te==="center"||te==="centre"?"middle":te==="top"||te==="middle"||te==="bottom"?te:void 0}const x=["cell","layout","header"];function K(ie){if(!U(ie))return{};const te={...ie},ce=(ue,ae)=>{if(ie[ue]===void 0)return;const pe=N(ie[ue],ae);pe&&x.includes(ue)&&!U(ie[ue])&&delete pe.enabled,te[ue]=pe};return ce("sort","direction"),ce("filter","type"),ce("cell","render"),ce("edit","editor"),ce("layout","width"),ce("group","index"),ce("pivot","index"),ce("header","render"),ce("facet","strategy"),te}function I(ie,te){const ce={...ie||{}},ue=U(te)&&U(te.layout)&&te.layout.width!==void 0;return ce.fit==="content"&&!ue&&delete ce.width,ce}const D=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","edit","export","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","validation","value","verticalAlign"]),j=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function E(ie,te,ce,ue){const ae=ce==="columnGroup"?"column group":"column";for(const pe of Object.keys(ie))te.has(pe)||y(`${ce}.unknown:${pe}`,`'${pe}' is not a configuration key this grid recognises, so it had no effect on ${ae} "${ue}". Check the spelling against the reference.`)}function $(ie){const te=ie.defaults||{},ce={};return te.align&&(ce.align=te.align,ce.cell={align:te.align},ce.header={align:te.align}),te.filter&&(ce.filter=te.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:te.filter}),te.editor&&(ce.edit=te.editor==="none"?{editor:null}:{editor:te.editor}),te.total&&(ce.total=te.total),te.render&&(ce.cell={...ce.cell||{},render:te.render}),ie.export&&(ce.export={...ie.export}),ce}function q(ie){if(typeof ie=="string")return ie.trim()?[ie.trim()]:[];if(!Array.isArray(ie))return[];const te=[];for(const ce of ie){if(typeof ce!="string")continue;const ue=ce.trim();ue&&!te.includes(ue)&&te.push(ue)}return te}class X{#e=new Map;#t=[];#n=[];#r;#o;#i;#a;#s;#l;#u(te,ce,ue){const ae=this.#c(te,ce,ue);if(typeof ae!="string"||!this.#d)return ae??null;const pe=ce&&ce.totals&&ce.totals.implement;if(pe&&_(pe[ae])){const ke=pe[ae];return ke.totalName=ae,ke}const he=this.#d.totalFn?.(ae);return _(he)?he:ae}#c(te,ce,ue){if(typeof te!="string")return te;const ae=ce&&ce.totals&&ce.totals.supported;if(!Array.isArray(ae)||ae.includes(te))return te;const pe=ae.length?ae.join(", "):"none";return z(`column "${ue}" is typed ${ce.name||"a type"}, for which the total "${te}" is not meaningful. Supported: ${pe}. Aggregating it anyway would produce a confident wrong number.`),te}#d;#h;#f;#m;#p;#g;#v=!1;#b;#y;constructor(te={}){this.#o=K(te.columnDefaults||{}),this.#i=te.columnPresets||{},this.#s=te.locale,this.#a=te.timeZone,this.#l=P(te.verticalAlign),this.#d=te.registry||null,this.#h=te.grid||null,this.#f=te.context,this.#b=te.sampleSize??d,this.#y=te.onChange||null,this.#g=_(te.rowKey)?te.rowKey:void 0,this.#r=n(te.dataTypes,this.#d);const{leaves:ce,groups:ue}=re(te.columns||[]);this.#n=ue;for(const ae of ce){const pe=this.#w(ae.def,null);if(pe.groupPath=ae.path,this.#e.has(pe.id)){y(`columns.duplicate:${pe.id}`,`two columns resolve to the id '${pe.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}ae.column=pe,this.#e.set(pe.id,pe),this.#t.push(pe.id)}this.#A(te.stored||null)}#w(te,ce){E(te,D,"column",te.id||te.field||"(unnamed)");const ue=K(te),ae=k(te.preset),pe=ae.map(Ue=>{const Je=this.#i[Ue];return Je?K(Je):(y(`preset:${Ue}`,`unknown column preset "${Ue}"; ignoring`),{})}),he=this.#j(ue,pe,ce),ke=this.#r.get(he)||this.#r.get("text");!this.#r.has(he)&&te.type&&y(`type:${he}`,`unknown data type "${he}"; falling back to "text"`);let Oe=T;Oe=B(Oe,this.#o),te.type!==!1&&(Oe=B(Oe,$(ke)));for(const Ue of pe)Oe=B(Oe,Ue);Oe=B(Oe,ue);const De=Oe.edit;De&&De.editor&&De.enabled!==!0&&!_(De.enabled)&&(te.edit||{}).editor&&y(`column.editor-not-enabled:${te.id||te.field}`,`column '${te.id||te.field}' names the editor '${De.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const _e=te.id||te.field||S("col");if(te.shadow&&!_(Oe.value&&Oe.value.compute)){const Ue=typeof te.shadow=="string"?{kind:te.shadow}:te.shadow,Je=Ue.of||te.field||_e,at=O.includes(Ue.kind),Ae=at?Ue.model||Ue:null,Ke=at&&Ae?[...Array.isArray(Ae.predictors)?Ae.predictors:[],Ae.response].filter(Boolean):null;Oe.value={...Oe.value||{},deps:Ke&&Ke.length?Ke:Ue.orderBy&&Ue.orderBy!==Je?[Je,Ue.orderBy]:[Je],pure:!1,compute:(Ve,Qe)=>{const lt=Qe.grid&&Qe.grid.statistics;if(!lt)return null;const wt=Qe.row&&Qe.row.key||lt.keyOf(Qe.data);if(!wt)return null;if(at){if(!_(lt.fitShadow))return null;const Pt=Ue.model?{...Ue.model,threshold:Ue.threshold}:Ue;return lt.fitShadow(Ue.kind,wt,Pt)}return lt.shadow(Je,Ue.kind,wt,Ue.scope,Ue)}}}if(te.running&&!_(Oe.value&&Oe.value.compute)){const Ue=typeof te.running=="string"?{kind:te.running}:te.running,Je=Ue.of||te.field||_e;Oe.value={...Oe.value||{},deps:[Je],pure:!1,compute:(at,Ae)=>{const Ke=Ae.grid&&Ae.grid.statistics;if(!Ke||!_(Ke.running))return null;const Ve=Ae.row&&Ae.row.key||Ke.keyOf(Ae.data);return Ve?Ke.running(Je,Ue.kind||"total",Ve):null}},te.sort===void 0&&(Oe.sort={...Oe.sort||{},enabled:!1})}const Se=te.field??(_(Oe.value&&Oe.value.compute)?null:te.id??null),xe=_(Oe.value&&Oe.value.compute),$e={id:_e,field:Se,shadow:te.shadow||null,running:te.running||null,spec:te.spec||null,validation:te.validation||null,volatile:!!(te.shadow||te.running),title:Oe.title??W(Se||_e),type:ke.name,dataType:ke,nullable:Oe.nullable!==!1,align:C(ue.cell&&ue.cell.align||ue.align||Oe.cell&&Oe.cell.align||Oe.align||ke.defaults&&ke.defaults.align)||"start",verticalAlign:P(ue.cell&&ue.cell.verticalAlign||ue.verticalAlign||Oe.cell&&Oe.cell.verticalAlign||Oe.verticalAlign)||this.#l,rowSpan:_(Oe.rowSpan)?Oe.rowSpan:null,colSpan:_(Oe.colSpan)?Oe.colSpan:null,value:{pure:!0,...Oe.value||{}},cell:{...Oe.cell||{}},edit:{...Oe.edit||{}},sort:{...Oe.sort||{}},filter:{...Oe.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Oe.group||{}},pivot:{enabled:!1,index:-1,...Oe.pivot||{}},total:this.#u(Oe.total,ke,te.id||te.field||"(unnamed)"),groupTotal:Oe.groupTotal===void 0?null:this.#u(Oe.groupTotal,ke,te.id||te.field||"(unnamed)"),grandTotal:Oe.grandTotal===void 0?null:this.#u(Oe.grandTotal,ke,te.id||te.field||"(unnamed)"),tags:q(Oe.tags),typeOptions:Oe.typeOptions??null,...U(Oe[he])?{[he]:Oe[he]}:{},layout:I(Oe.layout,ue),header:{...Oe.header||{}},contextMenu:Oe.contextMenu===void 0?null:Oe.contextMenu,facet:{...Oe.facet||{}},export:{...Oe.export||{}},allowGroup:Oe.allowGroup!==!1,allowPivot:Oe.allowPivot!==!1,allowTotal:Oe.allowTotal!==!1,quickFilter:Oe.quickFilter!==!1,def:te,format:Oe.format,presets:ae,inferred:ce!=null&&!te.type,computed:xe,read:Se?H(Se):null,write:Se?L(Se):null};$e.cell.align=C(ue.cell&&ue.cell.align)||$e.align,$e.header.align=C(ue.header&&ue.header.align)||$e.align;const qe=Oe.lookup||null;return $e.lookup=qe?p({id:_e,lookup:qe},{locale:this.#s,onChange:()=>{this.#y&&this.#y("lookup",{colId:_e})}}):null,$e.group.explode&&$e.lookup&&$e.lookup.multiple&&y(`explode:${_e}`,`column "${_e}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S($e),$e}#S(te){te.formatter=o(te.format,te.dataType,this.#s,this.#a,te.id),te.formatValue=b(te,{locale:this.#s,grid:this.#h,context:this.#f}),te.compare=_(te.value.compare)?te.value.compare:te.lookup?te.lookup.comparator():t(te.dataType,this.#s),te.excel=te.formatter&&te.formatter.ooxml||te.dataType&&te.dataType.excel||"General",te.storeKind=i(te.dataType,!!(te.lookup&&te.lookup.multiple))}#j(te,ce,ue){if(te.type===!1)return"text";if(te.type)return te.type;for(let ae=ce.length-1;ae>=0;ae--)if(ce[ae].type)return ce[ae].type;if(this.#o.type)return this.#o.type;if(te.shadow){const ae=typeof te.shadow=="string"?te.shadow:te.shadow.kind;if(ae==="fitInfluence")return"boolean";if(ae==="fitPredicted"||ae==="fitResidual"||ae==="fitStdResidual"||ae==="fitLeverage"||ae==="fitCooksD"||ae==="tsTrend"||ae==="tsSeasonal"||ae==="tsResidual"||ae==="tsCoverage"||ae==="tsSmoothed"||ae==="tsSmoothingAlpha"||ae==="tsSmoothingBeta")return"number"}return ue||(te.lookup?"lookup":"text")}#A(te){const ce=this.all();this.#m=h(ce),this.#p?this.#p.setGraph(this.#m):this.#p=new v({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:te||null,rowKey:this.#g});const ue=this.#p;for(const ae of ce)ae.getValue=(pe,he)=>ue.value(ae,pe,he)}all(){return this.#t.map(te=>this.#e.get(te))}visible(){return this.all().filter(te=>!te.layout.hidden)}get(te){return this.#e.get(te)}groups(){const te=ce=>{const ue=[];for(const ae of ce)Array.isArray(ae.columns)?ue.push({...ae,columns:te(ae.columns)}):ae.column&&ue.push(ae.column);return ue};return te(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(te){return g(this.#m,te)}value(te,ce,ue){return this.#p.value(te,ce,ue)}text(te,ce,ue){return this.#p.text(te,ce,ue)}checkImpure(te,ce){l(this.#e.get(te),ce)}setLocale(te){this.#s=te;for(const ce of this.all())ce.lookup&&ce.lookup.setLocale(te),this.#S(ce);this.#y&&this.#y("locale",{locale:te})}infer(te){const ce={};if(this.#v||!Array.isArray(te)||te.length===0)return ce;this.#v=!0;let ue=!1;for(const ae of this.all()){const pe=ae.def;if(pe.type!==void 0||!ae.field||ae.computed||ae.lookup||this.#O(ae))continue;const he=ae.read||(De=>F(De,ae.field)),ke=c(ae.id,te,he,this.#r,{sampleSize:this.#b});if(ke===ae.type)continue;ce[ae.id]=ke;const Oe=this.#w(pe,ke);Oe.groupPath=ae.groupPath,Oe.layout={...Oe.layout,...Q(ae.layout)},this.#e.set(ae.id,Oe),oe(this.#n,ae.id,Oe),ue=!0}return ue&&this.#A(null),ce}redecorate(te,ce,ue={}){const ae=this.#e.get(te);if(!ae){y(`redecorate:${te}`,`columns.decorate('${te}', …): no column with id '${te}'.`);return}const pe=ae.def||{},he={...U(pe.cell)?pe.cell:{}};he.decoration=ce??void 0,ue&&"variant"in ue&&(he.variant=ue.variant);const ke={...pe,cell:he},Oe=this.#w(ke,ae.type);return Oe.groupPath=ae.groupPath,Oe.layout={...Oe.layout,...Q(ae.layout)},this.#e.set(te,Oe),oe(this.#n,te,Oe),this.#A(null),this.#y&&this.#y("decorate",{colId:te}),Oe}#O(te){for(const ce of te.presets){const ue=this.#i[ce];if(ue&&ue.type)return!0}return!!this.#o.type}#C(te){return!te.computed&&_(te.dataType&&te.dataType.toStorage)}storeReader(te){if(te.computed)return ce=>this.#p.value(te,ce,null);if(this.#C(te)){const ce=te.dataType.toStorage,ue={timeZone:te.timeZone||this.#a};return ae=>ce(te.read(ae),ue)}return te.read}storeValue(te,ce){if(!(!te||te.computed)&&_(te.read))return this.storeReader(te)(ce)}storeSchema(){const te=[];for(const ce of this.all()){if(ce.computed&&ce.value.pure===!1||!ce.computed&&!ce.field)continue;const ue=this.storeReader(ce);let ae=null;!ce.computed&&!this.#C(ce)&&typeof ce.field=="string"&&!ce.lookup&&(ae=ce.field);const pe={id:ce.id,kind:ce.storeKind,nullable:ce.nullable,read:ue};ae!==null&&(pe.field=ae),ce.lookup&&(pe.dictionary=ce.lookup.dictionary()),te.push(pe)}return te}state(){return this.all().map(te=>({id:te.id,width:te.layout.width,flex:te.layout.flex||void 0,hidden:!!te.layout.hidden,pin:te.layout.pin??null,sort:te.sort.direction??null,sortIndex:te.sort.direction?te.sort.order??0:null,groupIndex:te.group.enabled?te.group.index??0:null,pivotIndex:te.pivot.enabled?te.pivot.index??0:null,total:typeof te.total=="string"?te.total:null,groupTotal:typeof te.groupTotal=="string"?te.groupTotal:void 0,grandTotal:typeof te.grandTotal=="string"?te.grandTotal:void 0,decoration:te.cell&&te.cell.decoration!=null?J(te.cell.decoration):void 0,variant:te.cell&&te.cell.variant!=null?J(te.cell.variant):void 0}))}applyState(te){const ce={applied:[],skipped:[]},ue=Array.isArray(te)?te:te&&te.columns||[],ae=!Array.isArray(te)&&te&&te.columnOrder||null;for(const he of ue){if(!he||!he.id){ce.skipped.push({key:"?",reason:"no id"});continue}let ke=this.#e.get(he.id);if(!ke){ce.skipped.push({key:he.id,reason:"unknown column"});continue}if(Object.hasOwn(he,"decoration")||Object.hasOwn(he,"variant")){const Oe=ke.cell?ke.cell.decoration:void 0,De=he.decoration??null,_e=Object.hasOwn(he,"variant"),Se=_e&&!ne(ke.cell?ke.cell.variant:void 0,he.variant);(!ne(Oe,De)||Se)&&(this.redecorate(he.id,De,_e?{variant:he.variant??void 0}:{}),ke=this.#e.get(he.id)||ke)}he.width!=null&&(ke.layout.width=he.width),he.flex!=null&&(ke.layout.flex=he.flex),he.hidden!=null&&(ke.layout.hidden=!!he.hidden),he.pin!==void 0&&(ke.layout.pin=he.pin),he.sort!==void 0&&(ke.sort.direction=he.sort),he.sortIndex!=null&&(ke.sort.order=he.sortIndex),he.groupIndex!=null&&(ke.group.enabled=!0,ke.group.index=he.groupIndex),he.pivotIndex!=null&&(ke.pivot.enabled=!0,ke.pivot.index=he.pivotIndex),he.total!==void 0&&(ke.total=he.total),he.groupTotal!==void 0&&(ke.groupTotal=he.groupTotal),he.grandTotal!==void 0&&(ke.grandTotal=he.grandTotal),ce.applied.push(he.id)}const pe=ae||ue.map(he=>he&&he.id).filter(Boolean);if(pe.length){const he=pe.filter(Oe=>this.#e.has(Oe)),ke=this.#t.filter(Oe=>!he.includes(Oe));this.#t=[...he,...ke]}return this.#y&&this.#y("state",ce),ce}move(te,ce){const ue=this.#t.indexOf(te);if(ue===-1)return;const ae=this.#e.get(te);if(ae.layout.movable===!1||ae.layout.lockPosition){y(`move:${te}`,`column "${te}" is not movable; the move was ignored`);return}const pe=this.#E(te,ce);if(pe){y(`move.married:${pe}`,`band "${pe}" declares marryChildren, so its columns stay together; the move was ignored`);return}this.#t.splice(ue,1),this.#t.splice(Math.max(0,Math.min(ce,this.#t.length)),0,te),this.#T(),this.#y&&this.#y("move",{id:te,to:ce})}#E(te,ce){if(!this.#n||!this.#n.length)return null;const ue=this.#t.filter(ke=>ke!==te),ae=Math.max(0,Math.min(ce,ue.length)),pe=(ke,Oe)=>{if(Array.isArray(ke.columns)){for(const _e of ke.columns)pe(_e,Oe);return Oe}const De=ke.column?ke.column.id:ke.id;return De&&Oe.push(De),Oe},he=ke=>{for(const Oe of ke){if(!Array.isArray(Oe.columns))continue;if(Oe.marryChildren===!0){const _e=pe(Oe,[]),Se=_e.includes(te),xe=_e.map($e=>ue.indexOf($e)).filter($e=>$e>=0);if(xe.length){const $e=Math.min(...xe),qe=Math.max(...xe);if(Se?ae<$e||ae>qe+1:ae>$e&&ae<=qe)return Oe.id}}const De=he(Oe.columns);if(De)return De}return null};return he(this.#n)}#T(){const te=new Map(this.#t.map((ae,pe)=>[ae,pe])),ce=ae=>{if(!Array.isArray(ae.columns)){const he=ae.column?ae.column.id:ae.id;return te.has(he)?te.get(he):1/0}let pe=1/0;for(const he of ae.columns)pe=Math.min(pe,ce(he));return pe},ue=ae=>{ae.sort((pe,he)=>ce(pe)-ce(he));for(const pe of ae)Array.isArray(pe.columns)&&ue(pe.columns)};ue(this.#n)}#x(te){const ce=ue=>{for(let ae=0;ae<ue.length;ae++){const pe=ue[ae];if(Array.isArray(pe.columns)){const he=ce(pe.columns);if(he)return he}else if(pe.column&&pe.column.id===te)return ue.splice(ae,1)[0]}return null};return ce(this.#n)}#R(te){const ce=[];for(let ue=te.length-1;ue>=0;ue--){const ae=te[ue];Array.isArray(ae.columns)&&(ce.push(...this.#R(ae.columns)),ae.columns.length===0&&(ce.push(ae.id),te.splice(ue,1)))}return ce}#N(){const te=(ce,ue)=>{for(const ae of ce)Array.isArray(ae.columns)?te(ae.columns,[...ue,ae.id]):ae.column&&(ae.column.groupPath=ue)};te(this.#n,[])}#M(te){const ce=new Set(te),ue=this.#t.filter(ke=>ce.has(ke));if(!ue.length)return;const ae=Math.min(...ue.map(ke=>this.#t.indexOf(ke))),pe=this.#t.slice(0,ae).filter(ke=>!ce.has(ke)),he=this.#t.slice(ae).filter(ke=>!ce.has(ke));this.#t=[...pe,...ue,...he]}#_(te){const ce=[],ue=ae=>{if(Array.isArray(ae.columns))for(const pe of ae.columns)ue(pe);else ae.column&&ce.push(ae.column.id)};return ue(te),ce}#U(te){const ce=ue=>{for(const ae of ue){if(!Array.isArray(ae.columns))continue;if(ae.id===te)return{node:ae,parent:ue};const pe=ce(ae.columns);if(pe)return pe}return null};return ce(this.#n)}groupColumns(te,ce={}){const ue=k(te).filter(Oe=>this.#e.has(Oe));if(!ue.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Oe of ue)if(this.#e.get(Oe).layout.lockPosition)return y(`columns.group.locked:${Oe}`,`column "${Oe}" is position-locked and cannot be grouped.`),null;const ae=ce.groupId?this.#U(ce.groupId):null;if(ce.groupId&&!ae)return y(`columns.group.unknown:${ce.groupId}`,`no band "${ce.groupId}" to add to; nothing was grouped.`),null;let pe=null;if(!ae&&ce.id!=null&&(pe=String(ce.id),this.#U(pe)||this.#e.has(pe)))return y(`columns.group.idtaken:${pe}`,`band id "${pe}" is already in use; nothing was grouped.`),null;const he=ue.map(Oe=>this.#x(Oe)).filter(Boolean);if(!he.length)return null;let ke;if(ae)ae.node.columns.push(...he),ke=ae.node.id;else{const Oe={id:pe||S("grp"),title:ce.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:he},De=Number.isInteger(ce.at)?Math.max(0,Math.min(ce.at,this.#n.length)):this.#n.length;this.#n.splice(De,0,Oe),ke=Oe.id}return this.#R(this.#n),this.#M(ue),this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"formed",groupId:ke,ids:ue}),ke}ungroupColumn(te){const ce=this.#e.get(te);if(!ce){y(`columns.ungroup.unknown:${te}`,`no column "${te}" to ungroup.`);return}const ue=ce.groupPath||[];if(!ue.length)return;const ae=ue[ue.length-1],pe=this.#U(ae);if(!pe)return;const he=this.#x(te);if(!he)return;const ke=pe.parent.indexOf(pe.node);pe.parent.splice(ke+1,0,he);const Oe=this.#R(this.#n),De=this.#_(pe.node);if(De.length){this.#M(De);const _e=Math.max(...De.map(xe=>this.#t.indexOf(xe))),Se=this.#t.filter(xe=>xe!==te);Se.splice(_e+1,0,te),this.#t=Se}this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"removed",id:te,dissolved:Oe})}renameGroup(te,ce){const ue=this.#U(te);if(!ue){y(`columns.group.rename:${te}`,`no band "${te}" to rename.`);return}ue.node.title=String(ce??""),this.#y&&this.#y("columngroup",{action:"renamed",groupId:te,title:ue.node.title})}dissolveGroup(te){const ce=this.#U(te);if(!ce){y(`columns.group.dissolve:${te}`,`no band "${te}" to dissolve.`);return}const ue=ce.parent.indexOf(ce.node);ce.parent.splice(ue,1,...ce.node.columns),this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"dissolved",groupId:te})}moveGroup(te,ce){const ue=this.#U(te);if(!ue){y(`columns.group.move:${te}`,`no band "${te}" to move.`);return}const ae=ue.parent,pe=ae.indexOf(ue.node);pe!==-1&&(ae.splice(pe,1),ae.splice(Math.max(0,Math.min(ce,ae.length)),0,ue.node),this.#L(),this.#N(),this.#y&&this.#y("columngroup",{action:"moved",groupId:te,to:ce}))}#L(){const te=[],ce=ae=>{for(const pe of ae)Array.isArray(pe.columns)?ce(pe.columns):pe.column&&te.push(pe.column.id)};ce(this.#n);const ue=new Set(te);this.#t=[...te,...this.#t.filter(ae=>!ue.has(ae))]}groupTree(){const te=ue=>ue.map(ae=>Array.isArray(ae.columns)?{id:ae.id,title:ae.title||"",collapsible:!!ae.collapsible,openByDefault:ae.openByDefault!==!1,columns:te(ae.columns)}:ae.column?ae.column.id:null).filter(ae=>ae!==null),ce=te(this.#n);return ce.some(ue=>ue&&typeof ue=="object")?ce:[]}applyGroupTree(te){if(!Array.isArray(te))return;const ce=new Set,ue=pe=>{const he=[];for(const ke of pe)if(ke&&typeof ke=="object"&&Array.isArray(ke.columns)){const Oe=ue(ke.columns);if(!Oe.length)continue;he.push({id:ke.id||S("grp"),title:ke.title||"",collapsible:ke.collapsible===!0,openByDefault:ke.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Oe})}else if(typeof ke=="string"){const Oe=this.#e.get(ke);Oe&&!ce.has(ke)&&(ce.add(ke),he.push({column:Oe,path:[]}))}return he},ae=ue(te);for(const pe of this.#t){if(ce.has(pe))continue;const he=this.#e.get(pe);he&&ae.push({column:he,path:[]})}this.#n=ae,this.#N(),this.#T(),this.#y&&this.#y("columngroup",{action:"applied"})}show(te){this.#Y(te,!1)}hide(te){this.#Y(te,!0)}#Y(te,ce){const ue=[];for(const ae of k(te)){const pe=this.#e.get(ae);if(pe){if(ce&&pe.layout.lockVisible){y(`lockVisible:${ae}`,`column "${ae}" is \`layout.lockVisible\` and cannot be hidden`);continue}pe.layout.hidden!==ce&&(pe.layout.hidden=ce,ue.push(ae))}}ue.length&&this.#y&&this.#y("visible",{ids:ue,hidden:ce})}pin(te,ce){const ue=this.#e.get(te);ue&&(ue.layout.pin=ce??null,this.#y&&this.#y("pin",{id:te,side:ue.layout.pin}))}resize(te,ce){const ue=this.#e.get(te);if(!ue)return;if(ue.layout.resizable===!1){y(`resize:${te}`,`column "${te}" is not resizable; the resize was ignored`);return}const ae=ue.layout.min??0,pe=ue.layout.max;let he=Math.max(ae,ce);pe!=null&&(he=Math.min(pe,he)),ue.layout.width=he,ue.layout.flex=0,this.#y&&this.#y("resize",{id:te,width:he})}}function Q(ie){const te={};return ie.width!=null&&(te.width=ie.width),ie.hidden!=null&&(te.hidden=ie.hidden),ie.pin!==void 0&&(te.pin=ie.pin),te}function J(ie){if(ie===null||typeof ie!="object")return ie;try{return structuredClone(ie)}catch{}try{return JSON.parse(JSON.stringify(ie))}catch{return ie}}function ne(ie,te){const ce=ie??null,ue=te??null;if(ce===ue)return!0;if(ce===null||ue===null)return!1;if(typeof ce!="object"||typeof ue!="object")return ce===ue;try{return JSON.stringify(ce)===JSON.stringify(ue)}catch{return!1}}function re(ie){const te=[],ce=(ae,pe)=>{const he=[];for(const ke of ae){if(!U(ke)){z("a column definition must be an object");continue}if(Array.isArray(ke.columns)){E(ke,j,"columnGroup",ke.title||ke.id||"(unnamed)");const Oe={id:ke.id||S("grp"),title:ke.title||"",collapsible:ke.collapsible===!0,openByDefault:ke.openByDefault!==!1,showWhen:ke.showWhen||"always",marryChildren:ke.marryChildren===!0,header:ke.header||{},def:ke,columns:[]};Oe.columns=ce(ke.columns,[...pe,Oe.id]),he.push(Oe)}else{const Oe={def:ke,path:pe};te.push(Oe),he.push(Oe)}}return he},ue=ce(ie,[]);return{leaves:te,groups:ue}}function oe(ie,te,ce){for(const ue of ie){if(ue.columns){if(oe(ue.columns,te,ce))return!0;continue}if(ue.column&&ue.column.id===te)return ue.column=ce,!0}return!1}}),ve("packages/core/src/columns/autogroup.js",function(e,V){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return U}});const N=V("packages/core/src/internal/util.js").warnOnce,z="__lattice_group",F=240,W=.5;function _(B){const{columns:H,groupBy:L}=B,k=L.map(u=>H.get(u)).filter(Boolean),S=k.length?k.map(u=>u.title||u.id).join(" > "):"Group",y=B.config&&B.config.autoGroupColumnWidth||F;return{id:z,field:null,title:S,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:L.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:y,min:120,pin:B.config&&B.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(u,o){return o&&o.group?o.groupValue:null},formatValue(u,o){if(!o||!o.group)return"";if(o.grandTotal)return B.config&&B.config.grandTotalLabel||"Total";const r=k[Math.min(o.level||0,k.length-1)];return r&&typeof r.formatValue=="function"?r.formatValue(u,o):u==null?"":String(u)}}}function U(B,H,L){!B.length||L<100||H<L*W||N(`grouping.cardinality:${B.join(",")}`,`grouping by ${B.join(", ")} produced ${H} groups for ${L} 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.`)}}),ve("packages/core/src/columns/selectcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Z="__lattice_select",N=44;function z(W){const _=W.selection||{},U=W.config&&W.config.selectionColumnWidth||N;return{id:Z,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:U,min:U,max:U,pin:W.config&&W.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:_.headerCheckbox===!0,def:{},getValue(B,H){return H?H.selected:!1},formatValue(){return""}}}const F=z}),ve("packages/core/src/columns/rownumbercolumn.js",function(e,V){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").isFunction,z="__lattice_rownumber",F=40,W=9,_=22;function U(L){const k=String(Math.max(1,Math.trunc(Math.abs(L))||1)).length;return Math.max(F,k*W+_)}function B(L){const k=L.rowNumbers,S=k&&typeof k=="object"?k:{},y=Number.isFinite(S.start)?S.start:1,u=Number.isFinite(S.width)?S.width:U((L.maxNumber||0)+y),o=N(L.rank)?L.rank:()=>null;return{id:z,field:null,title:typeof S.title=="string"?S.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:S.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(r,t){const n=o(t);return n==null?null:n-1+y},formatValue(r){return r==null?"":String(r)}}}const H=B}),ve("packages/core/src/model/detail.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F=240,W=10;function _(H){if(!H)return null;const L=H===!0?{}:H;return L.enabled===!1?null:!N(L.rows)&&!L.render?(z("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:L.render||null,config:L.config||null,rows:N(L.rows)?L.rows:null,height:L.height??F,cacheLimit:Number.isFinite(L.cacheLimit)?Math.max(0,L.cacheLimit):W,isMaster:N(L.isMaster)?L.isMaster:null,target:L.target||null,onCreate:N(L.onCreate)?L.onCreate:null,path:typeof L.path=="string"?L.path:null}}class U{#e;#t=new Set;#n;#r=0;constructor(L){this.#e=L.config,this.#n=N(L.onChange)?L.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(L){if(!L||L.group||L.detail)return!1;const k=this.#e.isMaster;return k?!!k(L.data,L):!0}isOpen(L){return this.#t.has(L)}keys(){return[...this.#t]}activeKey(){for(const L of this.#t)return L;return null}heightOf(L){const k=this.#e.height;return N(k)?Number(k(L))||F:k==="auto"?F:Number(k)||F}open(L){return this.#t.has(L)?!1:(this.inline||this.#t.clear(),this.#t.add(L),this.#o(),!0)}close(L){return this.#t.delete(L)?(this.#o(),!0):!1}toggle(L){return this.#t.has(L)?(this.close(L),!1):(this.open(L),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(L){if(!this.#t.size||!N(L))return;let k=!1;for(const S of[...this.#t])L(S)||(this.#t.delete(S),k=!0);k&&this.#o()}signature(){return`${this.#r}`}set(L){this.#t.clear();const k=Array.isArray(L)?L:[];for(const S of this.inline?k:k.slice(0,1))this.#t.add(S);this.#o()}#o(){this.#r++,this.#n()}}const B=U}),ve("packages/core/src/compute/handle.js",function(e,V){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return n}});const Z=V("packages/core/src/internal/util.js"),N=Z.collator,z=Z.defaultCompare,F=Z.warnOnce;function W(i){const s=new Uint32Array(i);for(let c=0;c<i;c++)s[c]=c;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const c=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):c?i.kind==="bitset"?typeof c.size=="number"?c.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(F(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${c.length*8}`),c.length*8):c.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const U=new WeakMap;function B(i){const s=i.constructor;if(!s)return"unknown";const c=U.get(s);if(c)return c;let d="unknown";try{let f=null;typeof s.from=="function"?f=s.from([!1,!0]):(f=new s(8),f.set(1));const h=f&&f.words;h&&h.length&&(h[0]===2?d="lsb":h[0]===64&&(d="msb"))}catch{d="unknown"}return U.set(s,d),d}function H(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const c=i instanceof Uint8Array?"lsb":B(i);if(c==="lsb")return d=>s[d>>>3]>>>(d&7)&1;if(c==="msb")return d=>s[d>>>3]>>>7-(d&7)&1}return typeof i.get=="function"?c=>i.get(c)?1:0:()=>0}function L(i){return!i||!i.presence?null:H(i.presence)}function k(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function S(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function y(i,s){const c=i.offsets,d=i.values;if(!c||!d)return[];const f=c[s],h=c[s+1];if(!(h>f))return[];const g=i.dict,w=new Array(h-f);for(let p=f;p<h;p++)w[p-f]=g?S(g,d[p]):d[p];return w}function u(i){if(!i)return()=>{};const s=i.values,c=L(i),d=i.kind;if(d==="dictionary"){const f=i.dict;return c?h=>c(h)?S(f,s[h]):null:h=>S(f,s[h])}if(d==="bitset"){const f=H(s);return c?h=>c(h)?f(h)===1:null:h=>f(h)===1}if(d==="multi")return c?f=>c(f)?y(i,f):null:f=>y(i,f);if(!s&&typeof i.get=="function"){const f=i.get.bind(i);return h=>{const g=f(h);return g===void 0?null:g}}return c?f=>{if(!c(f))return null;const h=s[f];return h===void 0?null:h}:f=>{const h=s[f];return h===void 0?null:h}}function o(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const f=Object.is(i,-0),h=Object.is(s,-0);return f===h?0:f?-1:1}const c=Number.isNaN(i),d=Number.isNaN(s);return c&&d?0:c?1:-1}function r(i){const s=N(i);return(c,d)=>{if(c===d)return 0;const f=typeof c,h=typeof d;if(f==="string"&&h==="string")return s.compare(c,d);if(f==="number"&&h==="number")return o(c,d);if(f==="boolean"&&h==="boolean")return c===d?0:c?1:-1;if(c instanceof Date||d instanceof Date){const g=c instanceof Date?c.getTime():Number(c),w=d instanceof Date?d.getTime():Number(d);return o(g,w)}return z(c,d)}}function t(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const c=i&&typeof i.values=="function"?i.values():[],d=c.length,f=r(s),h=new Array(d);for(let w=0;w<d;w++)h[w]=w;h.sort((w,p)=>f(c[w],c[p])||w-p);const g=new Uint32Array(d);for(let w=0;w<d;w++)g[h[w]]=w;return g}function n(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),ve("packages/core/src/compute/special.js",function(e,V){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return r}});const Z=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),N=3e-12,z=1e-300;function F(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-F(1-t);const n=t-1;let i=.9999999999998099;const s=n+7.5;for(let c=0;c<Z.length;c++)i+=Z[c]/(n+c+1);return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(s)-s+Math.log(i)}function W(t,n,i){const s=t+n,c=t+1,d=t-1;let f=1,h=1-s*i/c;Math.abs(h)<z&&(h=z),h=1/h;let g=h;for(let w=1;w<=300;w++){const p=2*w;let m=w*(n-w)*i/((d+p)*(t+p));h=1+m*h,Math.abs(h)<z&&(h=z),f=1+m/f,Math.abs(f)<z&&(f=z),h=1/h,g*=h*f,m=-(t+w)*(s+w)*i/((t+p)*(c+p)),h=1+m*h,Math.abs(h)<z&&(h=z),f=1+m/f,Math.abs(f)<z&&(f=z),h=1/h;const b=h*f;if(g*=b,Math.abs(b-1)<N)break}return g}function _(t,n,i){if(!(t>0)||!(n>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(F(t+n)-F(t)-F(n)+t*Math.log(i)+n*Math.log(1-i));return i<(t+1)/(t+n+2)?s*W(t,n,i)/t:1-s*W(n,t,1-i)/n}function U(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const n=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],c=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],d=.02425;let f,h,g;t<d?(f=Math.sqrt(-2*Math.log(t)),g=(((((s[0]*f+s[1])*f+s[2])*f+s[3])*f+s[4])*f+s[5])/((((c[0]*f+c[1])*f+c[2])*f+c[3])*f+1)):t<=1-d?(f=t-.5,h=f*f,g=(((((n[0]*h+n[1])*h+n[2])*h+n[3])*h+n[4])*h+n[5])*f/(((((i[0]*h+i[1])*h+i[2])*h+i[3])*h+i[4])*h+1)):(f=Math.sqrt(-2*Math.log(1-t)),g=-(((((s[0]*f+s[1])*f+s[2])*f+s[3])*f+s[4])*f+s[5])/((((c[0]*f+c[1])*f+c[2])*f+c[3])*f+1));const p=(.5*B(-g/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(g*g/2);return g-p/(1+g*p/2)}function B(t){const n=Math.abs(t),i=2/(2+n),s=4*i-2,c=[-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 d=0,f=0,h;for(let w=c.length-1;w>0;w--)h=f,f=s*f-d+c[w],d=h;const g=i*Math.exp(-n*n+.5*(c[0]+s*f)-d);return t>=0?g:2-g}function H(t){return .5*B(-t/Math.SQRT2)}function L(t,n){if(!(n>0)||!Number.isFinite(t))return Number.NaN;const i=.5*_(n/2,.5,n/(n+t*t));return t>0?1-i:i}function k(t,n){if(!(t>0)||!(t<1)||!(n>0))return Number.NaN;if(n>1e7)return U(t);let i=-1e4,s=1e4,c=U(t);const d=F(n/2)+F(.5)-F((n+1)/2);for(let f=0;f<60;f++){const h=L(c,n);h<t?i=c:s=c;const g=Math.exp(-((n+1)/2)*Math.log(1+c*c/n)-d)/Math.sqrt(n),w=g>0?(h-t)/g:0;if(Math.abs(w)<1e-12)break;const p=c-w;if(c=p>i&&p<s&&Number.isFinite(p)?p:(i+s)/2,s-i<1e-12)break}return c}function S(t,n){let i=t,s=1/t,c=s;for(let d=0;d<300&&(i+=1,c*=n/i,s+=c,!(Math.abs(c)<Math.abs(s)*N));d++);return s*Math.exp(-n+t*Math.log(n)-F(t))}function y(t,n){let i=n+1-t,s=1/z,c=1/i,d=c;for(let f=1;f<=300;f++){const h=-f*(f-t);i+=2,c=h*c+i,Math.abs(c)<z&&(c=z),s=i+h/s,Math.abs(s)<z&&(s=z),c=1/c;const g=c*s;if(d*=g,Math.abs(g-1)<N)break}return Math.exp(-n+t*Math.log(n)-F(t))*d}function u(t,n){return!(t>0)||!(n>=0)||!Number.isFinite(n)?Number.NaN:n===0?0:n<t+1?S(t,n):1-y(t,n)}function o(t,n){return n>0?u(n/2,t/2):Number.NaN}function r(t,n){const i=o(t,n);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),ve("packages/core/src/compute/linalg.js",function(e,V){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return _}});function Z(U){const B=U.length,H=Array.from({length:B},()=>new Array(B).fill(0));for(let L=0;L<B;L++)for(let k=0;k<=L;k++){let S=U[L][k];for(let y=0;y<k;y++)S-=H[L][y]*H[k][y];if(L===k){if(!(S>0))return null;H[L][k]=Math.sqrt(S)}else H[L][k]=S/H[k][k]}return H}function N(U,B){const H=U.length,L=new Array(H).fill(0);for(let S=0;S<H;S++){let y=B[S];for(let u=0;u<S;u++)y-=U[S][u]*L[u];L[S]=y/U[S][S]}const k=new Array(H).fill(0);for(let S=H-1;S>=0;S--){let y=L[S];for(let u=S+1;u<H;u++)y-=U[u][S]*k[u];k[S]=y/U[S][S]}return k}function z(U){const B=U.length,H=Array.from({length:B},()=>new Array(B).fill(0));for(let L=0;L<B;L++){const k=new Array(B).fill(0);k[L]=1;const S=N(U,k);for(let y=0;y<B;y++)H[y][L]=S[y]}return H}function F(U,B,H){const L=U.length,k=L?U[0].length:0,S=Array.from({length:k},()=>new Array(k).fill(0)),y=new Array(k).fill(0);for(let u=0;u<L;u++){const o=H?H[u]:1,r=U[u];for(let t=0;t<k;t++){const n=o*r[t];y[t]+=n*B[u];for(let i=t;i<k;i++)S[t][i]+=n*r[i]}}for(let u=0;u<k;u++)for(let o=0;o<u;o++)S[u][o]=S[o][u];return{xtwx:S,xtwy:y}}function W(U,B){return U.map(H=>H.reduce((L,k,S)=>L+k*B[S],0))}function _(U,B){let H=0;for(let L=0;L<U.length;L++){let k=0;for(let S=0;S<U.length;S++)k+=B[L][S]*U[S];H+=U[L]*k}return H}}),ve("packages/core/src/compute/sketch.js",function(e,V){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});class Z{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const o=u-this.#t;this.#t+=o/this.#e,this.#n+=o*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const o=this.#e+u.#e,r=u.#t-this.#t;this.#t+=r*(u.#e/o),this.#n+=u.#n+r*r*(this.#e*u.#e/o),this.#e=o}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class N{#e=[];#t=0;#n;#r;constructor(u,o=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=o}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const o=Math.floor(this.#r()*this.#t);o<this.#n&&(this.#e[o]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const o of this.#e)u+=o;return u/this.#e.length}quantile(u){const o=this.#e.length;if(!o)return null;const r=this.#e.slice().sort((s,c)=>s-c);if(o===1)return r[0];const t=(o-1)*Math.min(1,Math.max(0,u)),n=Math.floor(t),i=Math.ceil(t);return n===i?r[n]:r[n]+(t-n)*(r[i]-r[n])}}function z(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function F(y){if(typeof y=="number"){const r=new DataView(new ArrayBuffer(8));return r.setFloat64(0,y===0?0:y),z(r.getUint32(0)^r.getUint32(4))}const u=typeof y=="string"?y:String(y);let o=2166136261;for(let r=0;r<u.length;r++)o^=u.charCodeAt(r),o=Math.imul(o,16777619);return z(o)}class W{#e;#t;#n;constructor(u=14){const o=Math.floor(u);if(o<4||o>16)throw new RangeError("HLL precision must be 4..16");this.#e=o,this.#t=1<<o,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const o=1<<Math.floor(u),r=1.04/Math.sqrt(o);return Object.freeze({kind:"probabilistic",metric:"relative",value:r,statement:`distinct count within ~${(r*100).toFixed(2)}% relative standard error (m=${o} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(u){const o=F(u),r=o&this.#t-1,t=o>>>this.#e|1<<32-this.#e;let n=1,i=t;for(;(i&1)===0;)n++,i>>>=1;n>this.#n[r]&&(this.#n[r]=n)}count(){const u=this.#t,o=32-this.#e,r=new Float64Array(o+2);for(let i=0;i<u;i++)r[this.#n[i]]++;let t=u*B(1-r[o+1]/u);for(let i=o;i>=1;i--)t=.5*(t+r[i]);t+=u*U(r[0]/u);const n=_*u*u/t;return Math.round(n)}}const _=.5/Math.log(2);function U(y){if(y===1)return 1/0;let u=1,o=y,r;do y*=y,r=o,o+=y*u,u+=u;while(o!==r);return o}function B(y){if(y===0||y===1)return 0;let u=1,o=1-y,r;do y=Math.sqrt(y),r=o,u*=.5,o-=(1-y)**2*u;while(o!==r);return o/3}class H{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const o=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:o,statement:`each count overestimates the truth by at most N/m = ${o.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const o=this.#e.get(u);if(o){o.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let r,t=1/0;for(const[n,i]of this.#e)i.count<t&&(t=i.count,r=n);this.#e.delete(r),this.#e.set(u,{count:t+1,error:t})}top(u=this.#t){return[...this.#e.entries()].map(([r,t])=>({item:r,count:t.count,error:t.error})).sort((r,t)=>t.count-r.count).slice(0,Math.max(0,Math.floor(u)))}}class L{#e;#t=[[]];#n=0;#r;#o;constructor(u=200,o=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=o,this.#o=2/3}static errorBoundFor(u=200){const o=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:o,statement:`queried quantile's true rank within ~${(o*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return L.errorBoundFor(this.#e)}get count(){return this.#n}#i(u){const r=this.#t.length-1-u,t=Math.ceil(this.#e*this.#o**r);return Math.max(2,t)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#i(0)&&this.#a(0))}#a(u){const o=this.#t[u];o.sort((n,i)=>n-i),u+1>=this.#t.length&&this.#t.push([]);const r=this.#t[u+1],t=this.#r()<.5?0:1;for(let n=t;n<o.length;n+=2)r.push(o[n]);this.#t[u]=[];for(let n=0;n<this.#t.length;n++)if(this.#t[n].length>=this.#i(n)){this.#a(n);return}}#s(){const u=[];for(let o=0;o<this.#t.length;o++){const r=1<<o;for(const t of this.#t[o])u.push({v:t,w:r})}return u}quantile(u){const o=this.#s();if(!o.length)return null;o.sort((i,s)=>i.v-s.v);let r=0;for(const i of o)r+=i.w;const t=Math.min(1,Math.max(0,u))*r;let n=0;for(const i of o)if(n+=i.w,n>=t)return i.v;return o[o.length-1].v}rank(u){let o=0;for(let r=0;r<this.#t.length;r++){const t=1<<r;for(const n of this.#t[r])n<=u&&(o+=t)}return o}}const k=Object.freeze({distinct:W.errorBoundFor(14),median:L.errorBoundFor(200),p25:L.errorBoundFor(200),p75:L.errorBoundFor(200),p90:L.errorBoundFor(200),p95:L.errorBoundFor(200),p99:L.errorBoundFor(200),iqr:L.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"})}),S={Welford:Z,Reservoir:N,HyperLogLog:W,SpaceSaving:H,KLL:L,hash32:F,SKETCH_BOUNDS:k}}),ve("packages/core/src/compute/statistics.js",function(e,V){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return dt}});const Z=V("packages/core/src/compute/handle.js"),N=Z.presenceReader,z=Z.valueReader,F=V("packages/core/src/compute/special.js"),W=F.studentTQuantile,_=F.studentT,U=F.normalQuantile,B=F.normalCdf,H=F.chiSquareUpperTail,L=V("packages/core/src/compute/linalg.js"),k=L.cholesky,S=L.choleskySolve,y=L.choleskyInverse,u=L.normalEquations,o=L.quadForm,t=V("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,n=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"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function c(fe){const we=fe==="sum"||fe==="avg"||fe==="countValues"||fe==="min"||fe==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,fe)?i[fe]:null,be=Object.prototype.hasOwnProperty.call(s,fe)?s[fe]:null;return{stat:fe,exact:we,approximate:be}}function d(fe,we){const be=we.length,je=new Float64Array(be);let Pe=0;if(fe&&(fe.kind==="float64"||fe.kind==="int32")){const Fe=fe.values,Le=N(fe);for(let Ze=0;Ze<be;Ze++){const Ye=we[Ze];if(Le&&Le(Ye)!==1)continue;const mt=Fe[Ye];Number.isNaN(mt)||(je[Pe++]=mt)}return je.subarray(0,Pe)}const Re=z(fe);for(let Fe=0;Fe<be;Fe++){const Le=Re(we[Fe]);if(Le==null||Le==="")continue;const Ze=typeof Le=="number"?Le:Number(Le);Number.isFinite(Ze)&&(je[Pe++]=Ze)}return je.subarray(0,Pe)}function f(fe,we){const be=new Map,je=z(fe);let Pe=0;for(let Re=0;Re<we.length;Re++){const Fe=je(we[Re]);if(Fe==null||Fe===""||typeof Fe=="number"&&Number.isNaN(Fe))continue;const Le=typeof Fe=="object"?String(Fe):Fe;be.set(Le,(be.get(Le)||0)+1),Pe++}const Ne=[...be.values()].sort((Re,Fe)=>Fe-Re);return{counts:Ne,total:Pe,distinct:Ne.length}}function h(fe){return fe.total>0?fe.counts.map(we=>we/fe.total):[]}function g(fe,we){const be=f(fe,we);if(!be.total)return null;let je=0;for(const Pe of h(be))je+=Pe*Pe;return je}function w(fe,we){const be=f(fe,we);if(!be.total)return null;let je=0;for(const Pe of h(be))Pe>0&&(je-=Pe*Math.log2(Pe));return je}function p(fe,we){const be=f(fe,we);if(!be.total||be.distinct<2)return be.total?1:null;let je=0;for(const Pe of h(be))Pe>0&&(je-=Pe*Math.log2(Pe));return je/Math.log2(be.distinct)}function m(fe,we,be=3){const je=f(fe,we);if(!je.total)return null;const Pe=Math.max(1,Math.floor(be));let Ne=0;for(let Re=0;Re<Math.min(Pe,je.counts.length);Re++)Ne+=je.counts[Re];return Ne/je.total}function b(fe,we){const be=d(fe,we),je=be.length;if(!je)return null;const Pe=be.slice().sort();if(Pe[0]<0)return null;let Ne=0,Re=0;for(let Fe=0;Fe<je;Fe++)Ne+=Pe[Fe],Re+=(Fe+1)*Pe[Fe];return Ne===0?0:2*Re/(je*Ne)-(je+1)/je}function v(fe){let we=0,be=0,je=0;for(let Pe=0;Pe<fe.length;Pe++){const Ne=fe[Pe];we++;const Re=Ne-be;be+=Re/we,je+=Re*(Ne-be)}return{n:we,mean:be,m2:je}}function l(fe,we){const be=fe.length;if(!be)return NaN;if(be===1)return fe[0];const je=(be-1)*Math.min(1,Math.max(0,we)),Pe=Math.floor(je),Ne=Math.ceil(je);return Pe===Ne?fe[Pe]:fe[Pe]+(je-Pe)*(fe[Ne]-fe[Pe])}function a(fe,we){if(!fe.length)return NaN;const be=fe.slice().sort();return l(be,we)}function O(fe,we){const be=z(fe);let je=0,Pe=0,Ne=0;for(let Re=0;Re<we.length;Re++){const Fe=be(we[Re]);if(Fe==null||Fe==="")continue;const Le=String(Fe).toUpperCase();Le==="PASS"?je++:Le==="FAIL"?Pe++:Le==="WARN"&&Ne++}return{pass:je+Ne,fail:Pe,warn:Ne,judged:je+Ne+Pe}}const T=Object.freeze({hhi:(fe,we)=>g(fe,we),entropy:(fe,we)=>w(fe,we),evenness:(fe,we)=>p(fe,we),top3Share:(fe,we)=>m(fe,we,3),top10Share:(fe,we)=>m(fe,we,10),gini:(fe,we)=>b(fe,we),trimmedMean:(fe,we)=>x(d(fe,we),.1),winsorizedMean:(fe,we)=>K(d(fe,we),.1),robustOutliers:(fe,we)=>I(d(fe,we),3.5),jarqueBera:(fe,we)=>D(d(fe,we)),variance:(fe,we)=>{const{n:be,m2:je}=v(d(fe,we));return be>1?je/(be-1):null},varianceP:(fe,we)=>{const{n:be,m2:je}=v(d(fe,we));return be>0?je/be:null},stddev:(fe,we)=>{const{n:be,m2:je}=v(d(fe,we));return be>1?Math.sqrt(je/(be-1)):null},stddevP:(fe,we)=>{const{n:be,m2:je}=v(d(fe,we));return be>0?Math.sqrt(je/be):null},median:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.5):null},p25:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.25):null},p75:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.75):null},p90:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.9):null},p95:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.95):null},p99:(fe,we)=>{const be=d(fe,we);return be.length?a(be,.99):null},iqr:(fe,we)=>{const be=d(fe,we);if(!be.length)return null;const je=be.slice().sort();return l(je,.75)-l(je,.25)},mad:(fe,we)=>{const be=d(fe,we);if(!be.length)return null;const je=a(be,.5),Pe=new Float64Array(be.length);for(let Ne=0;Ne<be.length;Ne++)Pe[Ne]=Math.abs(be[Ne]-je);return a(Pe,.5)},range:(fe,we)=>{const be=d(fe,we);if(!be.length)return null;let je=1/0,Pe=-1/0;for(let Ne=0;Ne<be.length;Ne++)be[Ne]<je&&(je=be[Ne]),be[Ne]>Pe&&(Pe=be[Ne]);return Pe-je},distinct:(fe,we)=>{const be=z(fe),je=new Set;for(let Pe=0;Pe<we.length;Pe++){const Ne=be(we[Pe]);Ne==null||Ne===""||je.add(Ne instanceof Date?Ne.getTime():Ne)}return je.size},mode:(fe,we)=>{const be=z(fe),je=new Map;for(let Re=0;Re<we.length;Re++){const Fe=be(we[Re]);if(Fe==null||Fe==="")continue;const Le=Fe instanceof Date?Fe.getTime():Fe;je.set(Le,(je.get(Le)||0)+1)}let Pe=null,Ne=1;for(const[Re,Fe]of je)Fe>Ne&&(Ne=Fe,Pe=Re);return Pe},skewness:(fe,we)=>{const be=d(fe,we),{n:je,mean:Pe,m2:Ne}=v(be);if(je<3||Ne<=0)return null;const Re=Math.sqrt(Ne/(je-1));let Fe=0;for(let Le=0;Le<be.length;Le++)Fe+=((be[Le]-Pe)/Re)**3;return je/((je-1)*(je-2))*Fe},kurtosis:(fe,we)=>{const be=d(fe,we),{n:je,mean:Pe,m2:Ne}=v(be);if(je<4||Ne<=0)return null;const Re=Math.sqrt(Ne/(je-1));let Fe=0;for(let Ye=0;Ye<be.length;Ye++)Fe+=((be[Ye]-Pe)/Re)**4;const Le=je*(je+1)/((je-1)*(je-2)*(je-3)),Ze=3*(je-1)**2/((je-2)*(je-3));return Le*Fe-Ze},geomean:(fe,we)=>{const be=d(fe,we);if(!be.length)return null;let je=0;for(let Pe=0;Pe<be.length;Pe++){if(be[Pe]<=0)return null;je+=Math.log(be[Pe])}return Math.exp(je/be.length)},harmean:(fe,we)=>{const be=d(fe,we);if(!be.length)return null;let je=0;for(let Pe=0;Pe<be.length;Pe++){if(be[Pe]===0)return null;je+=1/be[Pe]}return be.length/je},sumSquares:(fe,we)=>{const be=d(fe,we);let je=0;for(let Pe=0;Pe<be.length;Pe++)je+=be[Pe]*be[Pe];return je},passRate:(fe,we)=>{const{pass:be,judged:je}=O(fe,we);return je?be/je:null},failureCount:(fe,we)=>O(fe,we).fail}),A=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 M(fe,we,be){const je=z(fe),Pe=z(we);let Ne=0,Re=0;for(let Fe=0;Fe<be.length;Fe++){const Le=be[Fe],Ze=Number(je(Le)),Ye=Number(Pe(Le));!Number.isFinite(Ze)||!Number.isFinite(Ye)||(Ne+=Ze*Ye,Re+=Ye)}return Re===0?null:Ne/Re}function C(fe,we,be){const je=z(fe);let Pe=null,Ne=be?-1/0:1/0;for(let Re=0;Re<we.length;Re++){const Fe=we[Re],Le=Number(je(Fe));Number.isFinite(Le)&&(be?Le>Ne:Le<Ne)&&(Ne=Le,Pe=Fe)}return Pe}function P(fe,we,be){const je=z(fe),Pe=z(we);let Ne=0,Re=0,Fe=0,Le=0,Ze=0,Ye=0;for(let ft=0;ft<be.length;ft++){const kt=be[ft],St=Number(je(kt)),Ee=Number(Pe(kt));!Number.isFinite(St)||!Number.isFinite(Ee)||(Ne++,Re+=St,Fe+=Ee,Le+=St*St,Ze+=Ee*Ee,Ye+=St*Ee)}if(Ne<2)return null;const mt=Ne*Ye-Re*Fe,pt=Math.sqrt((Ne*Le-Re*Re)*(Ne*Ze-Fe*Fe));if(pt===0)return null;const yt=mt/pt;return Math.max(-1,Math.min(1,yt))}function x(fe,we=.1){const be=fe.length;if(!be)return null;const je=Array.from(fe).sort((Fe,Le)=>Fe-Le),Pe=Math.floor(be*Math.min(.49,Math.max(0,we))),Ne=je.slice(Pe,be-Pe);if(!Ne.length)return l(je,.5);let Re=0;for(const Fe of Ne)Re+=Fe;return Re/Ne.length}function K(fe,we=.1){const be=fe.length;if(!be)return null;const je=Array.from(fe).sort((Le,Ze)=>Le-Ze),Pe=Math.floor(be*Math.min(.49,Math.max(0,we))),Ne=je[Pe],Re=je[be-1-Pe];let Fe=0;for(const Le of je)Fe+=Math.min(Re,Math.max(Ne,Le));return Fe/be}function I(fe,we=3.5){if(!fe.length)return null;const je=Array.from(fe).sort((Le,Ze)=>Le-Ze),Pe=l(je,.5),Ne=je.map(Le=>Math.abs(Le-Pe)).sort((Le,Ze)=>Le-Ze),Re=l(Ne,.5);if(Re===0)return null;let Fe=0;for(const Le of je)Math.abs(.6745*(Le-Pe)/Re)>we&&Fe++;return Fe}function D(fe){const we=fe.length;if(we<8)return null;let be=0;for(const Le of fe)be+=Le;be/=we;let je=0,Pe=0,Ne=0;for(const Le of fe){const Ze=Le-be;je+=Ze*Ze,Pe+=Ze*Ze*Ze,Ne+=Ze*Ze*Ze*Ze}if(je/=we,Pe/=we,Ne/=we,je===0)return null;const Re=Pe/je**1.5,Fe=Ne/(je*je)-3;return we/6*(Re*Re+Fe*Fe/4)}function j(fe,we,be){const je=[];let Pe=0;for(let Le=0;Le<fe.length;Le++){const Ze=Number(fe[Le]),Ye=Number(we[Le]);!Number.isFinite(Ze)||!Number.isFinite(Ye)||Ye<=0||(je.push([Ze,Ye]),Pe+=Ye)}if(!je.length||Pe<=0)return null;if(je.sort((Le,Ze)=>Le[0]-Ze[0]),je.length===1)return je[0][0];const Ne=[];let Re=0;for(const[,Le]of je)Ne.push((Re+Le/2)/Pe),Re+=Le;const Fe=Math.max(0,Math.min(1,be));if(Fe<=Ne[0])return je[0][0];if(Fe>=Ne[Ne.length-1])return je[je.length-1][0];for(let Le=1;Le<Ne.length;Le++){if(Fe>Ne[Le])continue;const Ze=Ne[Le]-Ne[Le-1],Ye=Ze>0?(Fe-Ne[Le-1])/Ze:0;return je[Le-1][0]+(je[Le][0]-je[Le-1][0])*Ye}return je[je.length-1][0]}function E(fe,we,be){const je=z(fe),Pe=z(we),Ne=new Float64Array(be.length),Re=new Float64Array(be.length);let Fe=0;for(let Le=0;Le<be.length;Le++){const Ze=be[Le],Ye=Number(je(Ze)),mt=Number(Pe(Ze));!Number.isFinite(Ye)||!Number.isFinite(mt)||(Ne[Fe]=Ye,Re[Fe]=mt,Fe++)}return{xs:Ne.subarray(0,Fe),ys:Re.subarray(0,Fe),n:Fe}}function $(fe,we,be,je=!1){const{xs:Pe,ys:Ne,n:Re}=E(fe,we,be);if(Re<2)return null;let Fe=0,Le=0;for(let Ye=0;Ye<Re;Ye++)Fe+=Pe[Ye],Le+=Ne[Ye];Fe/=Re,Le/=Re;let Ze=0;for(let Ye=0;Ye<Re;Ye++)Ze+=(Pe[Ye]-Fe)*(Ne[Ye]-Le);return Ze/(je?Re:Re-1)}function q(fe,we,be){const{xs:je,ys:Pe,n:Ne}=E(fe,we,be);if(Ne<2)return null;let Re=0,Fe=0;for(let St=0;St<Ne;St++)Re+=je[St],Fe+=Pe[St];Re/=Ne,Fe/=Ne;let Le=0,Ze=0,Ye=0;for(let St=0;St<Ne;St++){const Ee=je[St]-Re,tt=Pe[St]-Fe;Le+=Ee*Ee,Ze+=Ee*tt,Ye+=tt*tt}if(Le===0)return null;const mt=Ze/Le,pt=Fe-mt*Re,yt=Ye===0?1:Math.max(0,Math.min(1,Ze*Ze/(Le*Ye))),ft=Math.max(0,Ye-mt*Ze),kt=Ne>2?Math.sqrt(ft/(Ne-2)/Le):0;return{slope:mt,intercept:pt,r2:yt,stdError:kt,n:Ne}}const X=new Set(["ols","wls","robust"]),Q=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ne=1.345;function re(fe,we,be){const{xtwx:je,xtwy:Pe}=u(fe,we,be),Ne=k(je);if(!Ne)return null;const Re=S(Ne,Pe),Fe=y(Ne),Le=oe(fe,Re),Ze=we.map((Ye,mt)=>Ye-Le[mt]);return{beta:Re,cov:Fe,fitted:Le,residuals:Ze}}function oe(fe,we){return fe.map(be=>be.reduce((je,Pe,Ne)=>je+Pe*we[Ne],0))}function ie(fe,we){const be=fe.length,je=fe.map(Ze=>Ze[we]),Pe=fe.map(Ze=>[1,...Ze.filter((Ye,mt)=>mt!==we)]),Ne=re(Pe,je,null);if(!Ne)return 1;const Re=je.reduce((Ze,Ye)=>Ze+Ye,0)/be;let Fe=0,Le=0;for(let Ze=0;Ze<be;Ze++)Fe+=Ne.residuals[Ze]**2,Le+=(je[Ze]-Re)**2;return Le===0?1:Math.max(0,Math.min(1,1-Fe/Le))}function te(fe){const we=[...fe].sort((Pe,Ne)=>Pe-Ne),be=ce(we),je=fe.map(Pe=>Math.abs(Pe-be)).sort((Pe,Ne)=>Pe-Ne);return ce(je)/.6745}function ce(fe){const we=fe.length;if(!we)return 0;const be=Math.floor(we/2);return we%2?fe[be]:(fe[be-1]+fe[be])/2}function ue(fe,we,be={}){const je=be.method||"ols";if(J.has(je))throw new Error(`[lattice] regression method "${je}" is out of scope; use ols, wls or robust.`);if(Q.has(je))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!X.has(je))throw new Error(`[lattice] unknown regression method "${je}"; use ols, wls or robust.`);const Pe=Array.isArray(we)?we.length:0,Ne=Pe&&Array.isArray(fe[0])?fe[0].length:0,Re=Ne+1;if(!(Pe>Re))return null;for(let bt=0;bt<Pe;bt++){if(!Number.isFinite(we[bt])||!Array.isArray(fe[bt])||fe[bt].length!==Ne)return null;for(let Ct=0;Ct<Ne;Ct++)if(!Number.isFinite(fe[bt][Ct]))return null}let Fe=null;if(je==="wls"){if(Fe=be.weights,!Array.isArray(Fe)||Fe.length!==Pe)return null;for(let bt=0;bt<Pe;bt++)if(!(Fe[bt]>0)||!Number.isFinite(Fe[bt]))return null}const Le=fe.map(bt=>[1,...bt]);let Ze,Ye=null;if(je==="robust"){if(Ze=re(Le,we,null),!Ze)return null;for(let bt=0;bt<50;bt++){const Ct=te(Ze.residuals);if(!(Ct>0))break;const Tt=Ze.residuals.map(Kt=>{const qt=Math.abs(Kt/Ct);return qt<=ne?1:ne/qt}),Bt=re(Le,we,Tt);if(!Bt)return null;const Yt=Bt.beta.reduce((Kt,qt,Jt)=>Math.max(Kt,Math.abs(qt-Ze.beta[Jt])),0);if(Ze=Bt,Ye=Tt,Yt<1e-10)break}}else if(Ze=re(Le,we,Fe),!Ze)return null;const mt=je==="robust"?Ye:Fe,{beta:pt,cov:yt,fitted:ft,residuals:kt}=Ze;let St=0,Ee=0,tt=0;for(let bt=0;bt<Pe;bt++){const Ct=mt?mt[bt]:1;St+=Ct*kt[bt]**2,Ee+=Ct,tt+=Ct*we[bt]}const rt=tt/Ee;let ht=0;for(let bt=0;bt<Pe;bt++){const Ct=mt?mt[bt]:1;ht+=Ct*(we[bt]-rt)**2}const Dt=Pe-Re,Nt=St/Dt,ot=ht===0?1:Math.max(0,Math.min(1,1-St/ht)),vt=1-(1-ot)*(Pe-1)/Dt,Ht=Array.isArray(be.names)&&be.names.length===Ne?be.names:fe[0].map((bt,Ct)=>`x${Ct+1}`),Gt=Rt(be.confidence),on=Dt>0?W(1-(1-Gt)/2,Dt):1/0,sn=pt.map((bt,Ct)=>{const Tt=Math.sqrt(Math.max(0,Nt*yt[Ct][Ct])),Bt=Tt>0?bt/Tt:bt===0?0:1/0,Yt=Number.isFinite(Bt)?2*(1-_(Math.abs(Bt),Dt)):0,Kt=Number.isFinite(on)?on*Tt:null;return{name:Ct===0?"(intercept)":Ht[Ct-1],estimate:bt,stdError:Tt,t:Bt,p:Math.max(0,Math.min(1,Yt)),lower:Kt===null?null:bt-Kt,upper:Kt===null?null:bt+Kt}}),an=new Array(Pe),xt=new Array(Pe);for(let bt=0;bt<Pe;bt++){const Ct=mt?mt[bt]:1,Tt=Math.max(0,Math.min(1,Ct*o(Le[bt],yt)));an[bt]=Tt;const Bt=(1-Tt)**2;xt[bt]=Bt>0&&Nt>0?kt[bt]**2/(Re*Nt)*(Tt/Bt):null}const ln=fe[0].map((bt,Ct)=>{if(Ne<2)return 1;const Tt=ie(fe,Ct);return Tt>=1?1/0:1/(1-Tt)});let un=null;{const bt=kt.map(Tt=>Tt*Tt),Ct=re(Le,bt,null);if(Ct){const Tt=bt.reduce((Zt,cn)=>Zt+cn,0)/Pe;let Bt=0,Yt=0;for(let Zt=0;Zt<Pe;Zt++)Bt+=Ct.residuals[Zt]**2,Yt+=(bt[Zt]-Tt)**2;const Kt=Yt===0?0:Math.max(0,Math.min(1,1-Bt/Yt)),qt=Pe*Kt,Jt=H(qt,Ne);un={statistic:qt,df:Ne,p:Jt,heteroscedastic:Jt<.05}}}let nn=null;if(Ne===1){const bt=fe.map((Ct,Tt)=>Tt).sort((Ct,Tt)=>fe[Ct][0]-fe[Tt][0]);nn={confidence:Gt,points:bt.map(Ct=>{const Tt=Le[Ct],Bt=Math.sqrt(Math.max(0,Nt*o(Tt,yt)));return{x:fe[Ct][0],yhat:ft[Ct],lower:ft[Ct]-on*Bt,upper:ft[Ct]+on*Bt}})}}return{method:je,coefficients:sn,r2:ot,adjR2:vt,n:Pe,df:Dt,sigma2:Nt,fitted:ft,residuals:kt,leverage:an,cooksD:xt,vif:ln,heteroscedasticity:un,band:nn,weights:mt?[...mt]:null}}function ae(fe){const we=fe.length,be=Array.from({length:we},(Ne,Re)=>Re).sort((Ne,Re)=>fe[Ne]-fe[Re]),je=new Float64Array(we);let Pe=0;for(;Pe<we;){let Ne=Pe;for(;Ne+1<we&&fe[be[Ne+1]]===fe[be[Pe]];)Ne++;const Re=(Pe+Ne)/2+1;for(let Fe=Pe;Fe<=Ne;Fe++)je[be[Fe]]=Re;Pe=Ne+1}return je}const pe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function he(fe){const we=[.01,.05,.1],be=[pe["1%"],pe["5%"],pe["10%"]];if(fe<=be[0]){const Ne=(Math.log(we[1])-Math.log(we[0]))/(be[1]-be[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(we[0])+Ne*(fe-be[0]))))}if(fe>=be[2]){const Ne=(Math.log(we[2])-Math.log(we[1]))/(be[2]-be[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(we[2])+Ne*(fe-be[2]))))}const je=fe<be[1]?0:1,Pe=(fe-be[je])/(be[je+1]-be[je]);return Math.exp(Math.log(we[je])+Pe*(Math.log(we[je+1])-Math.log(we[je])))}function ke(fe,we,be,je){const Pe=be-je,Ne=je+3,Re=new Array(Pe),Fe=new Array(Pe);let Le=!0,Ze=je;for(let ft=0;ft<Pe;ft++){const kt=je+ft,St=new Float64Array(Ne);St[0]=1,St[1]=ft+1,St[2]=fe[kt];for(let Ee=1;Ee<=je;Ee++)St[2+Ee]=we[kt-Ee];for(let Ee=1;Ee<Ne;Ee++)Number.isFinite(St[Ee])||(Ze=Math.min(Ze,Ee-3));Re[ft]=St,Fe[ft]=we[kt],Number.isFinite(Fe[ft])||(Le=!1)}if(!Le)return 0;const{xtwx:Ye,xtwy:mt}=u(Re,Fe,null);let pt=0,yt=1/0;for(let ft=0;ft<=Ze;ft++){const kt=ft+3;if(!(Pe>kt))continue;const St=new Array(kt);for(let ot=0;ot<kt;ot++)St[ot]=Ye[ot].slice(0,kt);const Ee=k(St);if(!Ee)continue;const tt=S(Ee,mt.slice(0,kt));let rt=0;for(let ot=0;ot<Pe;ot++){const vt=Re[ot];let Ht=0;for(let Gt=0;Gt<kt;Gt++)Ht+=vt[Gt]*tt[Gt];rt+=(Fe[ot]-Ht)**2}const Dt=rt/(Pe-kt)*(Pe-kt);if(!(Dt>0))continue;const Nt=Pe*Math.log(Dt/Pe)+2*kt;Nt<yt&&(yt=Nt,pt=ft)}return pt}function Oe(fe,we={}){const be=[];for(let yt=0;yt<fe.length;yt++){const ft=Number(fe[yt]);Number.isFinite(ft)&&be.push(ft)}const je=be.length,Pe=je-1;if(je<8||Pe<6)return null;const Ne=new Array(Pe);for(let yt=0;yt<Pe;yt++)Ne[yt]=be[yt+1]-be[yt];let Re=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.ceil(12*(je/100)**.25);Re=Math.max(0,Math.min(Re,Math.floor((Pe-5)/2)));const Fe=(yt,ft)=>{const kt=[],St=[];for(let Ee=ft;Ee<Pe;Ee++){const tt=[Ee-ft+1,be[Ee]];for(let rt=1;rt<=yt;rt++)tt.push(Ne[Ee-rt]);kt.push(tt),St.push(Ne[Ee])}return ue(kt,St,{method:"ols"})},Le=ke(be,Ne,Pe,Re),Ze=Fe(Le,Le);if(!Ze||!Ze.coefficients[2])return null;const Ye=Ze.coefficients[2].t,mt=he(Ye),pt=Ye<pe["5%"];return{statistic:Ye,usedLag:Le,nobs:Pe-Le,criticalValues:{...pe},pValue:mt,pApproximate:!0,stationary:pt,verdict:pt?"stationary":"non-stationary",regression:"ct"}}function De(fe,we={}){const be=[];for(let pt=0;pt<fe.length;pt++){const yt=Number(fe[pt]);Number.isFinite(yt)&&be.push(yt)}const je=be.length;if(je<3)return null;let Pe=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.min(10,je-1);Pe=Math.max(1,Math.min(Pe,je-1));let Ne=0;for(const pt of be)Ne+=pt;Ne/=je;const Re=be.map(pt=>pt-Ne);let Fe=0;for(const pt of Re)Fe+=pt*pt;Fe/=je;const Le=new Array(Pe+1).fill(0);Le[0]=1;for(let pt=1;pt<=Pe;pt++){let yt=0;for(let ft=pt;ft<je;ft++)yt+=Re[ft]*Re[ft-pt];Le[pt]=Fe>0?yt/je/Fe:0}const Ze=new Array(Pe+1).fill(0);Ze[0]=1;let Ye=[];for(let pt=1;pt<=Pe;pt++){let yt=Le[pt];for(let Ee=1;Ee<pt;Ee++)yt-=Ye[Ee-1]*Le[pt-Ee];let ft=1;for(let Ee=1;Ee<pt;Ee++)ft-=Ye[Ee-1]*Le[Ee];const kt=ft!==0?yt/ft:0,St=new Array(pt);for(let Ee=1;Ee<pt;Ee++)St[Ee-1]=Ye[Ee-1]-kt*Ye[pt-1-Ee];St[pt-1]=kt,Ze[pt]=kt,Ye=St}const mt=1.96/Math.sqrt(je);return{acf:Le,pacf:Ze,bounds:{upper:mt,lower:-mt},n:je,nlags:Pe,approximate:!0}}function _e(fe,we,be){const{xs:je,ys:Pe,n:Ne}=E(fe,we,be);if(Ne<2)return null;const Re=ae(je),Fe=ae(Pe);let Le=0,Ze=0;for(let yt=0;yt<Ne;yt++)Le+=Re[yt],Ze+=Fe[yt];Le/=Ne,Ze/=Ne;let Ye=0,mt=0,pt=0;for(let yt=0;yt<Ne;yt++){const ft=Re[yt]-Le,kt=Fe[yt]-Ze;Ye+=ft*kt,mt+=ft*ft,pt+=kt*kt}return mt===0||pt===0?null:Math.max(-1,Math.min(1,Ye/Math.sqrt(mt*pt)))}function Se(fe,we,be){const{xs:je,ys:Pe,n:Ne}=E(fe,we,be);if(Ne<2||Ne>n)return null;let Re=0,Fe=0,Le=0,Ze=0;for(let pt=0;pt<Ne;pt++)for(let yt=pt+1;yt<Ne;yt++){const ft=Math.sign(je[pt]-je[yt]),kt=Math.sign(Pe[pt]-Pe[yt]),St=ft*kt;St>0?Re++:St<0?Fe++:ft===0&&kt===0||(ft===0?Le++:Ze++)}const Ye=Re+Fe+Ze,mt=Re+Fe+Le;return Ye===0||mt===0?null:(Re-Fe)/Math.sqrt(Ye*mt)}function xe(fe,we={}){const be=fe.length;if(be<2)return null;const je=fe[0],Pe=fe[be-1],Ne=[];for(let Ee=1;Ee<be;Ee++){const tt=fe[Ee-1];tt!==0&&Ne.push((fe[Ee]-tt)/Math.abs(tt))}let Re=null;if(Ne.length>1){let Ee=0;for(const rt of Ne)Ee+=rt;Ee/=Ne.length;let tt=0;for(const rt of Ne)tt+=(rt-Ee)**2;Re=Math.sqrt(tt/(Ne.length-1))}const Fe=Number(we.periodsPerYear)>0?Number(we.periodsPerYear):null;let Le=fe[0],Ze=0,Ye=0,mt=0,pt=0;for(let Ee=1;Ee<be;Ee++){if(fe[Ee]>Le){Le=fe[Ee],Ze=Ee;continue}if(Le<=0)continue;const tt=(Le-fe[Ee])/Le;tt>Ye&&(Ye=tt,mt=Ze,pt=Ee)}let yt=null;if(be>2){let Ee=0;for(let ht=0;ht<be;ht++)Ee+=fe[ht];Ee/=be;let tt=0,rt=0;for(let ht=0;ht<be;ht++){const Dt=fe[ht]-Ee;rt+=Dt*Dt,ht>0&&(tt+=Dt*(fe[ht-1]-Ee))}yt=rt>0?tt/rt:null}let ft=0,kt=0;for(const Ee of Ne)Ee>0?ft++:Ee<0&&kt++;let St=null;if(je>0&&Pe>0){const Ee=(Pe/je)**(1/(be-1))-1;St=Fe?(1+Ee)**Fe-1:Ee}return{n:be,first:je,last:Pe,change:Pe-je,changePercent:je===0?null:(Pe-je)/Math.abs(je)*100,volatility:Re,annualisedVolatility:Re!==null&&Fe?Re*Math.sqrt(Fe):null,growth:St,maxDrawdown:Ye,maxDrawdownFrom:mt,maxDrawdownTo:pt,autocorrelation:yt,upDays:ft,downDays:kt}}const $e=1.128,qe=3.267;function Ue(fe){const we=fe.length;if(we<2)return null;const be=[];for(let Pe=1;Pe<we;Pe++)be.push(Math.abs(fe[Pe]-fe[Pe-1]));const je=be.reduce((Pe,Ne)=>Pe+Ne,0)/be.length;return{ranges:be,centre:je,upper:qe*je,lower:0}}function Je(fe){const we=fe.length;if(we<2)return null;let be=0;for(let Pe=1;Pe<we;Pe++)be+=Math.abs(fe[Pe]-fe[Pe-1]);const je=be/(we-1);return{sigma:je/$e,meanRange:je}}function at(fe,we){const be=fe.length;if(be<2||!we)return null;const je=Number.isFinite(Number(we.lower))?Number(we.lower):null,Pe=Number.isFinite(Number(we.upper))?Number(we.upper):null;if(je===null&&Pe===null)return null;let Ne=0;for(let ft=0;ft<be;ft++)Ne+=fe[ft];Ne/=be;let Re=0;for(let ft=0;ft<be;ft++)Re+=(fe[ft]-Ne)**2;const Fe=Math.sqrt(Re/(be-1)),Le=Je(fe),Ze=Le?Le.sigma:null,Ye=ft=>{if(!ft||ft<=0)return{index:null,k:null};const St=je!==null&&Pe!==null?(Pe-je)/(6*ft):null,Ee=Pe!==null?(Pe-Ne)/(3*ft):1/0,tt=je!==null?(Ne-je)/(3*ft):1/0;return{index:St,k:Math.min(Ee,tt)}},mt=Ye(Ze),pt=Ye(Fe);let yt=0;for(let ft=0;ft<be;ft++){if(je!==null&&fe[ft]<je){yt++;continue}Pe!==null&&fe[ft]>Pe&&yt++}return{n:be,mean:Ne,lower:je,upper:Pe,target:Number.isFinite(Number(we.target))?Number(we.target):null,sigmaWithin:Ze,sigmaOverall:Fe,cp:mt.index,cpk:mt.k,pp:pt.index,ppk:pt.k,outOfSpec:yt,defectRate:be?yt/be:null}}function Ae(fe){const we=fe.length;if(we<2)return null;const be=Je(fe);if(!be||!(be.sigma>0))return null;let je=0;for(let Pe=0;Pe<we;Pe++)je+=fe[Pe];return je/=we,{centre:je,sigma:be.sigma,upper:je+3*be.sigma,lower:je-3*be.sigma}}function Ke(fe,we){if(!we||!(we.sigma>0))return[];const be=fe.length,{centre:je,sigma:Pe}=we,Ne=Fe=>(fe[Fe]-je)/Pe,Re=[];for(let Fe=0;Fe<be;Fe++){if(Math.abs(Ne(Fe))>3&&Re.push({index:Fe,rule:1,description:"beyond three sigma"}),Fe>=2)for(const Le of[1,-1]){let Ze=0;for(let Ye=Fe-2;Ye<=Fe;Ye++)Ne(Ye)*Le>2&&Ze++;if(Ze>=2){Re.push({index:Fe,rule:2,description:"two of three past two sigma"});break}}if(Fe>=4)for(const Le of[1,-1]){let Ze=0;for(let Ye=Fe-4;Ye<=Fe;Ye++)Ne(Ye)*Le>1&&Ze++;if(Ze>=4){Re.push({index:Fe,rule:3,description:"four of five past one sigma"});break}}if(Fe>=7)for(const Le of[1,-1]){let Ze=!0;for(let Ye=Fe-7;Ye<=Fe;Ye++)if(Ne(Ye)*Le<=0){Ze=!1;break}if(Ze){Re.push({index:Fe,rule:4,description:"eight in a row on one side"});break}}}return Re}function Ve(fe,we){if(!we||!(we.sigma>0))return[];const be=fe.length,{centre:je,sigma:Pe}=we,Ne=Le=>(fe[Le]-je)/Pe,Re=(Le,Ze,Ye,mt)=>{for(const pt of[1,-1]){let yt=0;for(let ft=Le;ft<=Ze;ft++)Ne(ft)*pt>Ye&&yt++;if(yt>=mt)return!0}return!1},Fe=[];for(let Le=0;Le<be;Le++){if(Math.abs(Ne(Le))>3&&Fe.push({index:Le,rule:1,description:"beyond three sigma"}),Le>=8)for(const Ze of[1,-1]){let Ye=!0;for(let mt=Le-8;mt<=Le;mt++)if(Ne(mt)*Ze<=0){Ye=!1;break}if(Ye){Fe.push({index:Le,rule:2,description:"nine in a row on one side"});break}}if(Le>=5)for(const Ze of[1,-1]){let Ye=!0;for(let mt=Le-4;mt<=Le;mt++)if((fe[mt]-fe[mt-1])*Ze<=0){Ye=!1;break}if(Ye){Fe.push({index:Le,rule:3,description:Ze>0?"six rising":"six falling"});break}}if(Le>=13){let Ze=!0;for(let Ye=Le-12;Ye<=Le;Ye++){const mt=fe[Ye]-fe[Ye-1],pt=fe[Ye+1<=Le?Ye+1:Ye]-fe[Ye];if(Ye+1>Le)break;if(mt===0||pt===0||mt>0==pt>0){Ze=!1;break}}Ze&&Fe.push({index:Le,rule:4,description:"fourteen alternating"})}if(Le>=2&&Re(Le-2,Le,2,2)&&Fe.push({index:Le,rule:5,description:"two of three past two sigma"}),Le>=4&&Re(Le-4,Le,1,4)&&Fe.push({index:Le,rule:6,description:"four of five past one sigma"}),Le>=14){let Ze=!0;for(let Ye=Le-14;Ye<=Le;Ye++)if(Math.abs(Ne(Ye))>=1){Ze=!1;break}Ze&&Fe.push({index:Le,rule:7,description:"fifteen within one sigma"})}if(Le>=7){let Ze=!0;for(let Ye=Le-7;Ye<=Le;Ye++)if(Math.abs(Ne(Ye))<=1){Ze=!1;break}Ze&&Fe.push({index:Le,rule:8,description:"eight beyond one sigma"})}}return Fe}const Qe=Object.freeze(["westernElectric","nelson"]);function lt(fe,we,be="westernElectric"){return String(be)==="nelson"?Ve(fe,we):Ke(fe,we)}function wt(fe,we,be){let je=0;for(let Pe=0;Pe<fe.length;Pe++)(fe[Pe]<we||fe[Pe]>be)&&je++;return je}function Pt(fe,we,be,je=20){const Pe=fe.length;if(!Pe)return[];const Ne=fe[0],Re=fe[Pe-1];if(Re===Ne)return[{from:Ne,to:Re,count:Pe}];const Fe=be-we,Le=1.5*Fe;let Ze=Fe>0?Math.max(Ne,we-Le):Ne,Ye=Fe>0?Math.min(Re,be+Le):Re;Ye>Ze||(Ze=Ne,Ye=Re);const mt=Fe>0?2*Fe/Math.cbrt(Pe):(Ye-Ze)/(Math.ceil(Math.log2(Pe))+1),pt=mt>0?Math.min(je,Math.max(1,Math.ceil((Ye-Ze)/mt))):1,yt=(Ye-Ze)/pt,ft=[];for(let kt=0;kt<pt;kt++)ft.push({from:Ze+kt*yt,to:Ze+(kt+1)*yt,count:0});for(let kt=0;kt<Pe;kt++){const St=Math.min(pt-1,Math.max(0,Math.floor((fe[kt]-Ze)/yt)));ft[St].count++}return ft[0].from=Ne,ft[pt-1].to=Re,ft}const Lt=.95;function Rt(fe){const we=Number(fe);return Number.isFinite(we)&&we>0&&we<1?we:Lt}function $t(fe,we=Lt){const be=fe.length;if(be<2)return null;let je=0;for(let Ye=0;Ye<be;Ye++)je+=fe[Ye];const Pe=je/be;let Ne=0;for(let Ye=0;Ye<be;Ye++){const mt=fe[Ye]-Pe;Ne+=mt*mt}const Re=Math.sqrt(Ne/(be-1)),Fe=Rt(we),Ze=W(1-(1-Fe)/2,be-1)*Re/Math.sqrt(be);return{mean:Pe,lower:Pe-Ze,upper:Pe+Ze,margin:Ze,n:be,confidence:Fe}}function zt(fe,we,be=Lt){const je=Number(fe),Pe=Number(we);if(!(Pe>0)||!(je>=0)||je>Pe)return null;const Ne=Rt(be),Re=U(1-(1-Ne)/2),Fe=je/Pe,Le=Re*Re,Ze=1+Le/Pe,Ye=(Fe+Le/(2*Pe))/Ze,mt=Re/Ze*Math.sqrt(Fe*(1-Fe)/Pe+Le/(4*Pe*Pe));return{proportion:Fe,lower:Math.max(0,Ye-mt),upper:Math.min(1,Ye+mt),n:Pe,confidence:Ne}}function _t(fe,we=Lt){if(!fe||!(fe.n>2)||!Number.isFinite(fe.stdError))return null;const be=Rt(we),Pe=W(1-(1-be)/2,fe.n-2)*fe.stdError;return{slope:fe.slope,lower:fe.slope-Pe,upper:fe.slope+Pe,margin:Pe,confidence:be}}function Qt(fe,we,be=Lt){const je=Number(fe),Pe=Number(we);if(!Number.isFinite(je)||!(Pe>1))return null;const Ne=Rt(be),Fe=U(1-(1-Ne)/2)*Math.sqrt(1/(9*Pe)+je*je/(2*(Pe-1)));return{index:je,lower:je-Fe,upper:je+Fe,margin:Fe,n:Pe,confidence:Ne}}function ct(fe,we){return!fe||!(fe.sd>0)||!Number.isFinite(we)||!Number.isFinite(fe.mean)?null:(we-fe.mean)/fe.sd}function de(fe){return Number.isFinite(fe)?Math.min(1,Math.max(0,2*B(Math.abs(fe)/2)-1)):0}function ge(fe,we){const be=new Map,je=z(fe);let Pe=0;for(let Ne=0;Ne<we.length;Ne++){const Re=je(we[Ne]);if(Re==null||Re===""||typeof Re=="number"&&Number.isNaN(Re))continue;const Fe=Re instanceof Date?Re.getTime():typeof Re=="object"?String(Re):Re;be.set(Fe,(be.get(Fe)||0)+1),Pe++}return{map:be,total:Pe}}function Te(fe,we,be,je){if(!(we>0)||!(je>0))return null;let Pe=0;const Ne=new Set(fe.keys());for(const Re of be.keys())Ne.add(Re);for(const Re of Ne){const Fe=(fe.get(Re)||0)/we,Le=(be.get(Re)||0)/je;Pe+=Math.abs(Fe-Le)}return Pe/2}const Be=10;function He(fe,we,be){if(be&&be.numeric){const Fe=d(fe,we),{n:Le,mean:Ze}=v(Fe),Ye=Le>0?ct({mean:be.mean,sd:be.sd},Ze):null;return{measure:"standardizedMeanDifference",magnitude:Ye,distance:Ye===null?0:de(Ye),direction:Ye===null?0:Math.sign(Ye),subsetN:Le,populationN:be.n||0,reliable:Le>=Be}}const{map:Pe,total:Ne}=ge(fe,we),Re=Te(Pe,Ne,be.map,be.total);return{measure:"categoricalTotalVariation",magnitude:Re,distance:Re===null?0:Re,direction:0,subsetN:Ne,populationN:be.total||0,reliable:Ne>=Be}}function it(fe,we){if(fe&&(fe.kind==="float64"||fe.kind==="int32"))return!0;const be=z(fe);let je=0,Pe=0;for(let Ne=0;Ne<we.length&&je<200;Ne++){const Re=be(we[Ne]);if(Re==null||Re==="")continue;if(Re instanceof Date)return!1;je++;const Fe=typeof Re=="number"?Re:Number(Re);Number.isFinite(Fe)&&Pe++}return je===0?!1:Pe/je>=.9}function dt(fe,we){if(it(fe,we)){const Pe=d(fe,we),{n:Ne,mean:Re,m2:Fe}=v(Pe);return{numeric:!0,mean:Re,sd:Ne>0?Math.sqrt(Fe/Ne):0,n:Ne}}const{map:be,total:je}=ge(fe,we);return{numeric:!1,map:be,total:je}}}),ve("packages/core/src/compute/total.js",function(e,V){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return b}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F=V("packages/core/src/compute/handle.js"),W=F.presenceReader,_=F.valueComparator,U=F.valueReader,B=V("packages/core/src/compute/statistics.js"),H=B.STAT_FNS,L=B.STAT_LABELS;function k(v){return!!v&&(v.kind==="float64"||v.kind==="int32")}function S(v,l){const a=l.length;let O=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<a;C++){const P=A[l[C]];Number.isNaN(P)||(O+=P)}return O}for(let C=0;C<a;C++){const P=l[C];if(M(P)===1){const x=A[P];Number.isNaN(x)||(O+=x)}}return O}const T=U(v);for(let A=0;A<a;A++){const M=c(T(l[A]));M!==null&&(O+=M)}return O}S.kernel=!0;function y(v,l){const a=l.length;let O=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<a;C++)Number.isNaN(A[l[C]])||O++;return O}for(let C=0;C<a;C++){const P=l[C];M(P)===1&&!Number.isNaN(A[P])&&O++}return O}const T=U(v);for(let A=0;A<a;A++){const M=T(l[A]);M!=null&&!(typeof M=="number"&&Number.isNaN(M))&&O++}return O}y.kernel=!0;function u(v,l){return l.length}u.kernel=!0;function o(v,l){const a=y(v,l);return a===0?null:S(v,l)/a}o.kernel=!0;function r(v,l,a,O){const T=l.length;if(k(v)){const P=v.values,x=W(v);let K=null;if(!x){for(let I=0;I<T;I++){const D=P[l[I]];Number.isNaN(D)||(K===null||(a<0?D<K:D>K))&&(K=D)}return K}for(let I=0;I<T;I++){const D=l[I];if(x(D)===0)continue;const j=P[D];Number.isNaN(j)||(K===null||(a<0?j<K:j>K))&&(K=j)}return K}const A=U(v),M=_(O);let C=null;for(let P=0;P<T;P++){const x=A(l[P]);x==null||typeof x=="number"&&Number.isNaN(x)||(C===null||(a<0?M(x,C)<0:M(x,C)>0))&&(C=x)}return C}function t(v,l,a){return r(v,l,-1,a&&a.locale)}t.kernel=!0;function n(v,l,a){return r(v,l,1,a&&a.locale)}n.kernel=!0;function i(v,l){return l.length===0?null:U(v)(l[0])}i.kernel=!0;function s(v,l){return l.length===0?null:U(v)(l[l.length-1])}s.kernel=!0;function c(v){if(typeof v=="number")return Number.isNaN(v)?null:v;if(v==null||v===""||typeof v=="boolean")return null;if(v instanceof Date)return v.getTime();const l=Number(v);return Number.isNaN(l)?null:l}const d={sum:S,min:t,max:n,avg:o,count:u,first:i,last:s,countValues:y,...H},f=Object.freeze({...L,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(v){return v?typeof v=="string"?f[v]||v:"Total":""}const g=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function w(v){const l=v&&v.dataType&&v.dataType.totals&&v.dataType.totals.supported;if(Array.isArray(l))return l.slice();const a=g.filter(O=>O in d);for(const O of Object.keys(d))a.includes(O)||a.push(O);return a}function p(v,l){return typeof l!="string"?!0:w(v).includes(l)}function m(v,l){const a=U(v),O=[];for(let T=0;T<l.length;T++){const A=a(l[T]);A!=null&&O.push(A)}return O}function b(v,l,a,O){const T=l||[];if(typeof a=="string"){const A=d[a];return A?A(v,T,O):(z(`total:${a}`,`unknown total function "${a}"; register it in config.totalFns`),null)}return N(a)?a.kernel===!0?a(v,T,O):a(m(v,T),O||{}):null}}),ve("packages/core/src/compute/windowed.js",function(e,V){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/compute/sketch.js").Welford;class z{#e;#t;#n=[];#r;#o;constructor(B,H=0,L=Date.now){if(B!=="count"&&B!=="time"&&B!=="session")throw new RangeError(`unknown window kind: ${B}`);if((B==="count"||B==="time")&&!(H>0))throw new RangeError(`a ${B} window needs a positive span`);this.#e=B,this.#t=Math.floor(H),this.#r=L,this.#o=L()}get size(){return this.#n.length}push(B,H=this.#r()){Number.isFinite(B)&&(this.#n.push({t:H,v:B}),this.#i(H))}#i(B){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const H=B-this.#t;for(;this.#n.length&&this.#n[0].t<H;)this.#n.shift()}}spec(){const B=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:B,size:this.#n.length}}values(){return this.#n.map(B=>B.v)}aggregate(){const B=this.spec();if(!this.#n.length)return{over:B,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const H=new N;let L=0,k=1/0,S=-1/0;for(const{v:y}of this.#n)L+=y,y<k&&(k=y),y>S&&(S=y),H.add(y);return{over:B,count:this.#n.length,sum:L,mean:H.mean(),min:k,max:S,variance:H.variance(),stddev:H.stddev()}}reduce(B){const H=this.aggregate(),L={sum:H.sum,avg:H.mean,mean:H.mean,min:H.min,max:H.max,count:H.count,variance:H.variance,stddev:H.stddev};if(!(B in L))throw new RangeError(`unknown windowed aggregate: ${B}`);return{value:L[B],over:H.over}}}const F=Object.freeze(["count","time","session"]);function W(U,B=Date.now){const H=U.kind==="time"&&U.minutes!=null?U.minutes*6e4:U.span??0;return new z(U.kind,H,B)}const _={Window:z,WINDOW_KINDS:F,openWindow:W}}),ve("packages/core/src/compute/rolling.js",function(e,V){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/compute/windowed.js").openWindow,F=V("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function _(f,h,g,w){if(f.kind==="count"){const p=Math.max(1,Math.floor(f.span||0));return{coverage:Math.min(1,h/p),partial:h<p}}if(f.kind==="time"){const p=f.minutes!=null?f.minutes*6e4:f.span||0;if(!(p>0))return{coverage:1,partial:!1};const m=g-w;return{coverage:Math.min(1,m/p),partial:m<p}}return{coverage:null,partial:!1}}function U(f,h){const g=N(h),w=new Map,p=f.length?f[0].at:0;for(let m=0;m<f.length;m++){const{key:b,at:v,value:l}=f[m];Number.isFinite(l)&&g.push(l,v);const a=g.aggregate(),O=_(h,a.count,v,p);b!=null&&w.set(String(b),{sum:a.sum,avg:a.mean,min:a.min,max:a.max,count:a.count,coverage:O.coverage,partial:O.partial})}return w}function B(f){const h=new Map;let g=0;for(const{key:w,value:p}of f)Number.isFinite(p)&&(g+=p),w!=null&&h.set(String(w),g);return h}function H(f,h=1){const g=new Map,w=Math.max(1,Math.floor(h));for(let p=0;p<f.length;p++){const{key:m,value:b}=f[p];if(m==null)continue;const v=p>=w?f[p-w].value:null,l=Number.isFinite(b)?b:null,a=Number.isFinite(v)?v:null;g.set(String(m),l!==null&&a!==null?l-a:null)}return g}const L=4096;function k(f){let h=f>>>0;return()=>{h+=1831565813;let g=h;return g=Math.imul(g^g>>>15,g|1),g^=g+Math.imul(g^g>>>7,g|61),((g^g>>>14)>>>0)/4294967296}}function S(f,h){const g=f.length;if(g===1)return f[0];const w=(g-1)*h,p=Math.floor(w),m=Math.ceil(w);return p===m?f[p]:f[p]+(w-p)*(f[m]-f[p])}function y(f,h,g={}){const w=Math.min(1,Math.max(0,g.q==null?.5:g.q)),p=Math.max(1,Math.floor(g.cap==null?L:g.cap)),m=k(g.seed==null?2654435769:g.seed),b=new Map,v=f.length?f[0].at:0;if(h.kind==="session"){const a=new F(200,m);let O=0;for(const{key:T,value:A}of f)Number.isFinite(A)&&(a.add(A),O++),T!=null&&b.set(String(T),{value:O?a.quantile(w):null,approx:O>0,count:O,coverage:null,partial:!1});return b}const l=N(h);for(const{key:a,at:O,value:T}of f){Number.isFinite(T)&&l.push(T,O);const A=l.values(),M=A.length;let C=null,P=!1;if(M)if(M<=p)C=S([...A].sort((K,I)=>K-I),w);else{const K=new F(200,m);for(const I of A)K.add(I);C=K.quantile(w),P=!0}const x=_(h,M,O,v);a!=null&&b.set(String(a),{value:C,approx:P,count:M,coverage:x.coverage,partial:x.partial})}return b}function u(f,h){const g=f.length,w=new Array(g).fill(null),p=Math.floor(h/2),m=h%2===0;for(let b=0;b<g;b++){if(b-p<0||b+p>=g)continue;let v=0,l=!0;if(m)for(let a=-p;a<=p;a++){const O=f[b+a];if(!Number.isFinite(O)){l=!1;break}v+=a===-p||a===p?O*.5:O}else for(let a=-p;a<=p;a++){const O=f[b+a];if(!Number.isFinite(O)){l=!1;break}v+=O}l&&(w[b]=v/h)}return w}function o(f,h){const g=new Map,w=Math.floor(Number(h&&h.period));if(!(w>=2))return g;const p=h&&h.model==="multiplicative",m=f.length,b=f.map(P=>Number.isFinite(P.value)?P.value:null),v=u(b,w),l=new Array(m).fill(null);for(let P=0;P<m;P++){const x=v[P],K=b[P];x===null||K===null||(p?x!==0&&(l[P]=K/x):l[P]=K-x)}const a=new Array(w).fill(0),O=new Array(w).fill(0);for(let P=0;P<m;P++){if(l[P]===null)continue;const x=P%w;a[x]+=l[P],O[x]+=1}const T=p?1:0,A=a.map((P,x)=>O[x]?P/O[x]:T),M=A.reduce((P,x)=>P+x,0)/w,C=p?A.map(P=>M!==0?P/M:1):A.map(P=>P-M);for(let P=0;P<m;P++){const{key:x}=f[P];if(x==null)continue;const K=v[P],I=C[P%w],D=b[P];let j=null;K!==null&&D!==null&&(j=p?K*I!==0?D/(K*I):null:D-K-I),g.set(String(x),{trend:K,seasonal:D===null?null:I,residual:j,coverage:K===null?0:1,partial:K===null})}return g}function r(f,h,g,w=80){const p=(Math.sqrt(5)-1)/2;let m=h,b=g,v=b-p*(b-m),l=m+p*(b-m),a=f(v),O=f(l);for(let T=0;T<w;T++)a<O?(b=l,l=v,O=a,v=b-p*(b-m),a=f(v)):(m=v,v=l,a=O,l=m+p*(b-m),O=f(l));return(m+b)/2}const t=1e-4,n=1-1e-4;function i(f,h){const g=f.length,w=new Array(g).fill(null),p=new Array(g).fill(null);let m=null,b=0;for(let v=0;v<g;v++){const l=f[v];if(!Number.isFinite(l)){m!==null&&(p[v]=m,w[v]=m);continue}if(m===null){m=l,p[v]=l,w[v]=l;continue}p[v]=m,b+=(l-m)**2,m=h*l+(1-h)*m,w[v]=m}return{smoothed:w,fitted:p,sse:b}}function s(f,h,g){const w=f.length,p=new Array(w).fill(null),m=new Array(w).fill(null);let b=null,v=null,l=0;for(let a=0;a<w;a++){const O=f[a];if(!Number.isFinite(O)){b!==null&&(b+=v,p[a]=b);continue}if(b===null){b=O,p[a]=O;continue}if(v===null){v=O-b;const M=b+v;m[a]=M,l+=(O-M)**2;const C=b;b=h*O+(1-h)*(C+v),v=g*(b-C)+(1-g)*v,p[a]=b;continue}const T=b+v;m[a]=T,l+=(O-T)**2;const A=b;b=h*O+(1-h)*(A+v),v=g*(b-A)+(1-g)*v,p[a]=b}return{smoothed:p,fitted:m,sse:l}}function c(f,h={}){const g=new Map,w=h.method==="holt",p=f.map(T=>Number.isFinite(T.value)?T.value:null),m=p.filter(T=>T!==null).length,b=T=>Math.min(n,Math.max(t,T)),v=()=>{for(const{key:T}of f)T!=null&&g.set(String(T),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return g};if(m<(w?2:1))return v();let l=Number.isFinite(h.alpha)?b(h.alpha):null,a=w&&Number.isFinite(h.beta)?b(h.beta):null;if(w){if(l===null||a===null){let T=l===null?.5:l,A=a===null?.5:a;for(let M=0;M<6;M++)l===null&&(T=r(C=>s(p,C,A).sse,t,n)),a===null&&(A=r(C=>s(p,T,C).sse,t,n));l=l===null?T:l,a=a===null?A:a}}else l===null&&(l=r(T=>i(p,T).sse,t,n));const O=w?s(p,l,a):i(p,l);for(let T=0;T<f.length;T++){const{key:A}=f[T];A!=null&&g.set(String(A),{smoothed:O.smoothed[T],fitted:O.fitted[T],alpha:l,beta:w?a:null,sse:O.sse})}return g}const d={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:L,rollingWindow:U,rollingQuantile:y,cumulativeToDate:B,periodOverPeriod:H,seasonalDecompose:o,exponentialSmoothing:c}}),ve("packages/core/src/compute/compare.js",function(e,V){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const Z=V("packages/core/src/compute/statistics.js"),N=Z.numbers,z=Z.moments,F=Z.frequencyMap,W=Z.categoricalDistance,_=Z.normalTotalVariation,U=Z.isNumericColumn,B=Z.SUBSET_RELIABILITY_FLOOR,H=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function L(o,r){if(!o||!r||!(o.n>0)||!(r.n>0)||!Number.isFinite(o.mean)||!Number.isFinite(r.mean))return null;const t=(o.n*o.sd*o.sd+r.n*r.sd*r.sd)/(o.n+r.n);return t>0?(o.mean-r.mean)/Math.sqrt(t):null}function k(o,r){const t=N(o,r),{n,mean:i,m2:s}=z(t),c=n>0?Math.sqrt(s/n):0;return{mean:i,sd:c,n}}function S(o,r,t,n){return U(o,r)&&U(t,n)}function y(o,r,t,n){if(S(o,r,t,n)){const d=k(o,r),f=k(t,n),h=L(d,f);return{measure:H.numeric,magnitude:h,distance:h===null?0:_(h),direction:h===null?0:Math.sign(h),nA:d.n,nB:f.n,reliable:d.n>=B&&f.n>=B}}const i=F(o,r),s=F(t,n),c=W(i.map,i.total,s.map,s.total);return{measure:H.categorical,magnitude:c,distance:c===null?0:c,direction:0,nA:i.total,nB:s.total,reliable:i.total>=B&&s.total>=B}}function u(o,r,t={}){const n=new Set(o.columns),i=new Set(r.columns),s=o.columns.filter(g=>i.has(g)),c=Array.isArray(t.columns)&&t.columns.length?s.filter(g=>t.columns.includes(g)):s,d=o.indices(),f=r.indices(),h=[];for(const g of c){const w=o.handle(g),p=r.handle(g);if(!w||!p)continue;const m=y(w,d,p,f);h.push({column:g,name:o.name&&o.name(g)||r.name&&r.name(g)||g,measure:m.measure,magnitude:m.magnitude,distance:m.distance,direction:m.direction,nA:m.nA,nB:m.nB,reliable:m.reliable})}return h.sort((g,w)=>w.distance-g.distance||Math.abs(w.magnitude||0)-Math.abs(g.magnitude||0)),{ranked:h,nA:d.length,nB:f.length,unmatched:{onlyA:o.columns.filter(g=>!i.has(g)),onlyB:r.columns.filter(g=>!n.has(g))},measures:H}}}),ve("packages/core/src/compute/anomaly.js",function(e,V){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/compute/statistics.js").quantileSorted,F=V("packages/core/src/compute/special.js").logGamma,W=.6745,_=3.5,U=1.5,B=.975,H=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function L(f){if(!f.length)return null;const g=Array.from(f,Number).sort((b,v)=>b-v),w=N(g,.5),p=g.map(b=>Math.abs(b-w)).sort((b,v)=>b-v),m=N(p,.5);return{median:w,mad:m}}function k(f,h={}){const g=Number.isFinite(h.threshold)?h.threshold:_,w=f.length,p=new Array(w).fill(null),m=new Array(w).fill(!1),b=[];for(let a=0;a<w;a++){const O=Number(f[a]);Number.isFinite(O)&&b.push(O)}if(!b.length)return{median:null,mad:null,threshold:g,scores:p,flags:m,flagged:0};const v=L(b);if(v.mad===0)return{median:v.median,mad:0,threshold:g,scores:p,flags:m,flagged:0};let l=0;for(let a=0;a<w;a++){const O=Number(f[a]);if(!Number.isFinite(O))continue;const T=W*(O-v.median)/v.mad;p[a]=T,Math.abs(T)>g&&(m[a]=!0,l++)}return{median:v.median,mad:v.mad,threshold:g,scores:p,flags:m,flagged:l}}function S(f,h={}){const g=Number.isFinite(h.k)?h.k:U,w=[];for(let l=0;l<f.length;l++){const a=Number(f[l]);Number.isFinite(a)&&w.push(a)}if(!w.length)return null;const p=w.sort((l,a)=>l-a),m=N(p,.25),b=N(p,.75),v=b-m;return{q1:m,q3:b,iqr:v,lower:m-g*v,upper:b+g*v,k:g}}function y(f,h){if(h<=0)return 0;const g=F(f);if(h<f+1){let a=f,O=1/f,T=O;for(let A=0;A<1e3&&(a+=1,T*=h/a,O+=T,!(Math.abs(T)<Math.abs(O)*1e-15));A++);return O*Math.exp(-h+f*Math.log(h)-g)}const w=1e-300;let p=h+1-f,m=1/w,b=1/p,v=b;for(let a=1;a<1e3;a++){const O=-a*(a-f);p+=2,b=O*b+p,Math.abs(b)<w&&(b=w),m=p+O/m,Math.abs(m)<w&&(m=w),b=1/b;const T=b*m;if(v*=T,Math.abs(T-1)<1e-15)break}return 1-Math.exp(-h+f*Math.log(h)-g)*v}function u(f,h){return f<=0?0:y(h/2,f/2)}function o(f,h=B){if(!(h>0)||!(h<1))return NaN;let g=0,w=Math.max(1,f);for(;u(w,f)<h;)w*=2;for(let p=0;p<200;p++){const m=(g+w)/2;if(u(m,f)<h?g=m:w=m,w-g<1e-10)break}return(g+w)/2}function r(f){const h=f.length,g=f.map((w,p)=>{const m=w.slice();for(let b=0;b<h;b++)m.push(p===b?1:0);return m});for(let w=0;w<h;w++){let p=w;for(let b=w+1;b<h;b++)Math.abs(g[b][w])>Math.abs(g[p][w])&&(p=b);if(Math.abs(g[p][w])<1e-12)return null;if(p!==w){const b=g[p];g[p]=g[w],g[w]=b}const m=g[w][w];for(let b=0;b<2*h;b++)g[w][b]/=m;for(let b=0;b<h;b++){if(b===w)continue;const v=g[b][w];if(v!==0)for(let l=0;l<2*h;l++)g[b][l]-=v*g[w][l]}}return g.map(w=>w.slice(h))}function t(f,h){const g=f.length,w=new Array(h).fill(0);for(const b of f)for(let v=0;v<h;v++)w[v]+=b[v];for(let b=0;b<h;b++)w[b]/=g;const p=Array.from({length:h},()=>new Array(h).fill(0));for(const b of f)for(let v=0;v<h;v++){const l=b[v]-w[v];for(let a=v;a<h;a++)p[v][a]+=l*(b[a]-w[a])}const m=g>1?g-1:1;for(let b=0;b<h;b++)for(let v=b;v<h;v++)p[b][v]/=m,p[v][b]=p[b][v];return{mean:w,cov:p}}function n(f,h={}){const g=Number.isFinite(h.p)?h.p:B,w=Number.isFinite(h.ridge)?h.ridge:1e-6,p=f.length;if(!p)return null;const m=f[0].length;if(!m)return null;const b=new Array(p).fill(null),v=new Array(p).fill(null),l=new Array(p).fill(!1),a=[],O=[];for(let I=0;I<p;I++){const D=f[I];let j=D.length===m;const E=new Array(m);for(let $=0;j&&$<m;$++){const q=Number(D[$]);Number.isFinite(q)?E[$]=q:j=!1}j&&(a.push(I),O.push(E))}const T=m,A=o(T,g);if(O.length<=m)return{center:[],df:T,cutoff:A,singular:!0,used:O.length,distances:b,squared:v,flags:l,flagged:0};const{mean:M,cov:C}=t(O,m);let P=r(C),x=!1;if(!P){x=!0;let I=0;for(let E=0;E<m;E++)I+=C[E][E];const D=I/m*w||w,j=C.map((E,$)=>E.map((q,X)=>$===X?q+D:q));if(P=r(j),!P)return{center:M,df:T,cutoff:A,singular:!0,used:O.length,distances:b,squared:v,flags:l,flagged:0}}let K=0;for(let I=0;I<O.length;I++){const D=O[I],j=new Array(m);for(let q=0;q<m;q++)j[q]=D[q]-M[q];let E=0;for(let q=0;q<m;q++){let X=0;for(let Q=0;Q<m;Q++)X+=P[q][Q]*j[Q];E+=j[q]*X}E<0&&(E=0);const $=a[I];v[$]=E,b[$]=Math.sqrt(E),E>A&&(l[$]=!0,K++)}return{center:M,df:T,cutoff:A,singular:x,used:O.length,distances:b,squared:v,flags:l,flagged:K}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function c(f,h={}){const g=h.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",w=Number.isFinite(h.windowLen)&&h.windowLen>=1?Math.floor(h.windowLen):i,p=Number.isFinite(h.threshold)?h.threshold:_,m=Number.isFinite(h.k)?h.k:U,b=Number.isFinite(h.minPeriods)&&h.minPeriods>=1?Math.floor(h.minPeriods):w,v=f.length,l=new Array(v).fill(null),a=new Array(v).fill(!1);let O=0;for(let T=0;T<v;T++){const A=Number(f[T]);if(!Number.isFinite(A))continue;const M=Math.max(0,T-w+1),C=[];for(let P=M;P<=T;P++){const x=Number(f[P]);Number.isFinite(x)&&C.push(x)}if(!(C.length<b))if(g==="rollingIqr"){const P=S(C,{k:m});if(!P)continue;(A<P.lower||A>P.upper)&&(a[T]=!0,O++)}else{const P=L(C);if(!P||P.mad===0)continue;const x=W*(A-P.median)/P.mad;l[T]=x,Math.abs(x)>p&&(a[T]=!0,O++)}}return{method:g,windowLen:w,minPeriods:b,threshold:p,k:m,scores:l,flags:a,flagged:O}}function d(f={}){const h=f||{},g=h.field;if(typeof g!="string"||!g)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const w=h.method||"modifiedZScore";if(!(H.includes(w)||s.includes(w))||w==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${w}'`);const m=typeof h.orderBy=="string"?h.orderBy:null,b=h.latest===!0,v=s.includes(w),l=a=>Number(a==null?NaN:a[g]);return a=>{const O=Array.isArray(a)?a.slice():[...a];m&&O.sort((P,x)=>{const K=P?.[m],I=x?.[m];return K===I?0:K==null?-1:I==null?1:K<I?-1:1});const T=O.map(l);let A,M;if(v)({flags:A,scores:M}=c(T,{method:w,windowLen:h.windowLen,threshold:h.threshold,k:h.k,minPeriods:h.minPeriods}));else if(w==="iqr"){const P=S(T,{k:h.k});A=T.map(x=>P?Number.isFinite(x)&&(x<P.lower||x>P.upper):!1),M=T.map(()=>null)}else({flags:A,scores:M}=k(T,{threshold:h.threshold}));if(b){const P=A.length-1;return P<0||!A[P]?!1:{method:w,field:g,flagged:[{row:O[P],score:M[P]}]}}const C=[];for(let P=0;P<A.length;P++)A[P]&&C.push({row:O[P],score:M[P]});return C.length?{method:w,field:g,flagged:C}:!1}}}),ve("packages/core/src/compute/forecast.js",function(e,V){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const Z=V("packages/core/src/compute/special.js"),N=Z.normalQuantile,z=Z.studentTQuantile,W=V("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),U=1e-4,B=1-1e-4;function H(h){const g=[];for(let w=0;w<h.length;w++){const p=h[w];if(p!==null&&typeof p=="object"){const m=Number.isFinite(p.at)?p.at:w,b=Number.isFinite(p.value)?p.value:null;g.push({at:m,value:b})}else g.push({at:w,value:Number.isFinite(p)?Number(p):null})}return g}function L(h){const g=h.filter(v=>v.value!==null),w=g[0],p=g[g.length-1],m=p.at-w.at,b=g.length>1&&m>0?m/(g.length-1):1;return{lastAt:p.at,step:b}}function k(h){return Math.min(B,Math.max(U,h))}function S(h,g=U,w=B,p=80){const m=(Math.sqrt(5)-1)/2;let b=g,v=w,l=v-m*(v-b),a=b+m*(v-b),O=h(l),T=h(a);for(let A=0;A<p;A++)O<T?(v=a,a=l,T=O,l=v-m*(v-b),O=h(l)):(b=l,l=a,O=T,a=b+m*(v-b),T=h(a));return(b+v)/2}function y(h,g){let w=null,p=0,m=0;for(let b=0;b<h.length;b++){const v=h[b];if(v!==null){if(w===null){w=v;continue}p+=(v-w)**2,m+=1,w=g*v+(1-g)*w}}return{level:w,sse:p,m}}function u(h,g,w){let p=null,m=null,b=0,v=0;for(let l=0;l<h.length;l++){const a=h[l];if(a===null){p!==null&&m!==null&&(p+=m);continue}if(p===null){p=a;continue}m===null&&(m=a-p);const O=p+m;b+=(a-O)**2,v+=1;const T=p;p=g*a+(1-g)*(T+m),m=w*(p-T)+(1-w)*m}return{level:p,trend:m,sse:b,m:v}}function o(h,g,w,p,m){const b=h.length;if(b<2*g)return null;const v=x=>{let K=0,I=0;for(let D=x;D<x+g&&D<b;D++)h[D]!==null&&(K+=h[D],I+=1);return I?K/I:null},l=v(0),a=v(g);if(l===null||a===null)return null;let O=l,T=(a-l)/g;const A=new Array(g).fill(0);for(let x=0;x<g;x++)A[x]=h[x]===null?0:h[x]-O;const M=A.reduce((x,K)=>x+K,0)/g;for(let x=0;x<g;x++)A[x]-=M;let C=0,P=0;for(let x=g;x<b;x++){const K=x%g,I=A[K],D=h[x];if(D===null){O+=T;continue}const j=O+T+I;C+=(D-j)**2,P+=1;const E=O;O=w*(D-I)+(1-w)*(O+T),T=p*(O-E)+(1-p)*T,A[K]=m*(D-O)+(1-m)*I}return{level:O,trend:T,season:A,phase:(b-1)%g,sse:C,count:P}}function r(h,g,w){let p=1;for(const b of g)p+=b*b;const m=Math.sqrt(h*p);return{se:m,margin:w*m}}function t(h,g={}){if(!h||typeof h.length!="number"||h.length===0)return null;const w=_.includes(g.method)?g.method:"linear",p=Math.max(1,Math.floor(Number(g.horizon)||1)),m=Number.isFinite(g.confidence)&&g.confidence>0&&g.confidence<1?g.confidence:.95,b=1-(1-m)/2,v=H(h),l=v.map(C=>C.value),a=l.filter(C=>C!==null),O=a.length,{lastAt:T,step:A}=O?L(v):{lastAt:0,step:1},M=C=>T+C*A;return w==="linear"?n(v,O,p,m,b,M):w==="movingAverage"?i(a,O,p,m,b,g,M):w==="ses"?s(l,O,p,m,b,g,M):w==="holt"?c(l,O,p,m,b,g,M):d(l,O,p,m,b,g,M)}function n(h,g,w,p,m,b){if(g<2)return null;let v=0,l=0;for(const D of h)D.value!==null&&(v+=D.at,l+=D.value);v/=g,l/=g;let a=0,O=0,T=0;for(const D of h){if(D.value===null)continue;const j=D.at-v,E=D.value-l;a+=j*j,O+=j*E,T+=E*E}if(a===0)return null;const A=O/a,M=l-A*v,C=T===0?1:Math.max(0,Math.min(1,O*O/(a*T))),P=Math.max(0,T-A*O),x=g>2?Math.sqrt(P/(g-2)):null,K=g>2?z(m,g-2):null,I=[];for(let D=1;D<=w;D++){const j=b(D),E=M+A*j;let $=null,q=null,X=null,Q=null,J=null;if(x!==null){const ne=1/g+(j-v)**2/a,re=x*Math.sqrt(1+ne),oe=x*Math.sqrt(ne);J=re,$=E-K*re,q=E+K*re,X=E-K*oe,Q=E+K*oe}I.push({step:D,at:j,mean:E,lower:$,upper:q,lowerMean:X,upperMean:Q,se:J})}return{method:"linear",horizon:w,confidence:p,n:g,sigma:x,r2:C,params:{slope:A,intercept:M},points:I}}function i(h,g,w,p,m,b,v){if(g<1)return null;const l=Math.max(1,Math.min(g,Math.floor(Number(b.windowLen)||g))),a=h.slice(g-l);let O=0;for(const x of a)O+=x;const T=O/l;let A=null,M=null;if(l>1){let x=0;for(const I of a)x+=(I-T)**2;A=Math.sqrt(x/(l-1))*Math.sqrt(1+1/l),M=z(m,l-1)}const C=A===null?null:M*A,P=[];for(let x=1;x<=w;x++)P.push({step:x,at:v(x),mean:T,lower:C===null?null:T-C,upper:C===null?null:T+C,se:A});return{method:"movingAverage",horizon:w,confidence:p,n:g,sigma:A===null?null:A,params:{windowLen:l},points:P}}function s(h,g,w,p,m,b,v){if(g<1)return null;let l=Number.isFinite(b.alpha)?k(b.alpha):null;l===null&&(l=S(M=>y(h,M).sse));const a=y(h,l),O=N(m),T=a.m>0?a.sse/a.m:null,A=[];for(let M=1;M<=w;M++){const C=a.level;let P=null,x=null,K=null;if(T!==null){const I=[];for(let j=1;j<M;j++)I.push(l);const D=r(T,I,O);K=D.se,P=C-D.margin,x=C+D.margin}A.push({step:M,at:v(M),mean:C,lower:P,upper:x,se:K})}return{method:"ses",horizon:w,confidence:p,n:g,sigma:T===null?null:Math.sqrt(T),params:{alpha:l},points:A}}function c(h,g,w,p,m,b,v){if(g<2)return null;let l=Number.isFinite(b.alpha)?k(b.alpha):null,a=Number.isFinite(b.beta)?k(b.beta):null;if(l===null||a===null){let P=l===null?.5:l,x=a===null?.5:a;for(let K=0;K<6;K++)l===null&&(P=S(I=>u(h,I,x).sse)),a===null&&(x=S(I=>u(h,P,I).sse));l=l===null?P:l,a=a===null?x:a}const O=u(h,l,a),T=N(m),A=O.m>0?O.sse/O.m:null,M=l*a,C=[];for(let P=1;P<=w;P++){const x=O.level+P*O.trend;let K=null,I=null,D=null;if(A!==null){const j=[];for(let $=1;$<P;$++)j.push(l+$*M);const E=r(A,j,T);D=E.se,K=x-E.margin,I=x+E.margin}C.push({step:P,at:v(P),mean:x,lower:K,upper:I,se:D})}return{method:"holt",horizon:w,confidence:p,n:g,sigma:A===null?null:Math.sqrt(A),params:{alpha:l,beta:a},points:C}}function d(h,g,w,p,m,b,v){const l=Math.floor(Number(b.period));if(!(l>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(g<2*l)return null;let a=Number.isFinite(b.alpha)?k(b.alpha):null,O=Number.isFinite(b.beta)?k(b.beta):null,T=Number.isFinite(b.gamma)?k(b.gamma):null;const A=(D,j,E)=>{const $=o(h,l,D,j,E);return $?$.sse:1/0};if(a===null||O===null||T===null){let D=a===null?.5:a,j=O===null?.5:O,E=T===null?.5:T;for(let $=0;$<8;$++)a===null&&(D=S(q=>A(q,j,E))),O===null&&(j=S(q=>A(D,q,E))),T===null&&(E=S(q=>A(D,j,q)));a=a===null?D:a,O=O===null?j:O,T=T===null?E:T}const M=o(h,l,a,O,T);if(!M)return null;const C=N(m),P=M.count>0?M.sse/M.count:null,x=a*O,K=T*(1-a),I=[];for(let D=1;D<=w;D++){const j=M.season[(M.phase+D)%l],E=M.level+D*M.trend+j;let $=null,q=null,X=null;if(P!==null){const Q=[];for(let ne=1;ne<D;ne++)Q.push(a+ne*x+(ne%l===0?K:0));const J=r(P,Q,C);X=J.se,$=E-J.margin,q=E+J.margin}I.push({step:D,at:v(D),mean:E,lower:$,upper:q,se:X})}return{method:"holtWinters",horizon:w,confidence:p,n:g,sigma:P===null?null:Math.sqrt(P),params:{alpha:a,beta:O,gamma:T,period:l},points:I}}const f={FORECAST_METHODS:_,forecast:t}}),ve("packages/core/src/compute/hypothesis.js",function(e,V){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const N=V("packages/core/src/internal/util.js").warnOnce,F=V("packages/core/src/compute/handle.js").valueReader,W=V("packages/core/src/compute/statistics.js"),_=W.numbers,U=W.moments,B=W.frequencyMap,H=W.categoricalDistance,L=W.isNumericColumn,k=W.jarqueBera,S=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,o=V("packages/core/src/compute/compare.js").pooledStandardMeanDifference,r=V("packages/core/src/compute/special.js"),t=r.studentT,n=r.studentTQuantile,i=r.normalCdf,s=r.normalQuantile,c=r.chiSquareUpperTail,d=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),f=.05,h=2e6;function g(P){const x=Number(P);return Number.isFinite(x)&&x>0&&x<1?x:.95}function w(P){const{n:x,mean:K,m2:I}=U(P);return{mean:K,sd:x>0?Math.sqrt(I/x):0,n:x}}function p(P,x){const K=P.length;if(K<2)return 0;let I=0;for(let D=0;D<K;D++){const j=P[D]-x;I+=j*j}return I/(K-1)}function m(P,x){return{name:"pooledStandardMeanDifference",value:o(w(P),w(x))}}function b(P,x,K){const I=P.length,D=x.length;if(I<2||D<2)return null;const j=g(K),{mean:E}=U(P),{mean:$}=U(x),q=p(P,E),X=p(x,$),Q=q/I+X/D;if(!(Q>0))return null;const J=Math.sqrt(Q),ne=(E-$)/J,re=q/I*(q/I)/(I-1),oe=X/D*(X/D)/(D-1),ie=Q*Q/(re+oe),te=Math.min(1,Math.max(0,2*(1-t(Math.abs(ne),ie)))),ce=E-$,ue=n(1-(1-j)/2,ie)*J;return{test:d.WELCH,statistic:ne,statisticName:"t",df:ie,pValue:te,interval:{estimate:ce,lower:ce-ue,upper:ce+ue,confidence:j,method:"welch-t (difference of means)"},effectSize:m(P,x),nA:I,nB:D,reliable:I>=y&&D>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function v(P){const x=P.length;if(x===0)return Number.NaN;const K=x>>1;return x%2?P[K]:(P[K-1]+P[K])/2}function l(P,x,K){const I=P.length,D=x.length,j=I*D;if(j===0||j>h)return null;const E=new Float64Array(j);let $=0;for(let re=0;re<I;re++)for(let oe=0;oe<D;oe++)E[$++]=P[re]-x[oe];E.sort();const q=v(E),X=Math.sqrt(I*D*(I+D+1)/12),Q=s(1-(1-K)/2);let J=Math.round(j/2-Q*X);J>=0||(J=0);const ne=Math.floor((j-1)/2);return J>ne&&(J=ne),{estimate:q,lower:E[J],upper:E[j-1-J],confidence:K,method:"hodges-lehmann (normal approximation)"}}function a(P,x,K){const I=P.length,D=x.length;if(I<1||D<1)return null;const j=g(K),E=I+D,$=new Array(E);for(let te=0;te<I;te++)$[te]={v:P[te],g:0};for(let te=0;te<D;te++)$[I+te]={v:x[te],g:1};$.sort((te,ce)=>te.v-ce.v);let q=0,X=0,Q=0;for(;Q<E;){let te=Q;for(;te<E&&$[te].v===$[Q].v;)te++;const ce=te-Q,ue=(Q+1+te)/2;for(let ae=Q;ae<te;ae++)$[ae].g===0&&(q+=ue);X+=ce*ce*ce-ce,Q=te}const J=q-I*(I+1)/2,ne=I*D/2,re=I*D/12*(E+1-X/(E*(E-1)));let oe=1;if(re>0){const te=Math.max(0,Math.abs(J-ne)-.5);oe=Math.min(1,2*i(-te/Math.sqrt(re)))}const ie=l(P,x,j);return{test:d.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:oe,interval:ie,effectSize:m(P,x),nA:I,nB:D,reliable:I>=y&&D>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function O(P,x,K,I,D){const j=S(P,x,D),E=S(K,I,D);if(!j||!E)return null;const $=j.proportion-E.proportion,q=$-Math.sqrt((j.proportion-j.lower)**2+(E.upper-E.proportion)**2),X=$+Math.sqrt((j.upper-j.proportion)**2+(E.proportion-E.lower)**2);return{lower:q,upper:X}}function T(P,x,K,I,D,j={}){if(!(x>0)||!(I>0))return null;const E=new Set([...P.keys(),...K.keys()]),$=E.size;if($<2)return null;const q=x+I;let X=0;for(const oe of E){const ie=P.get(oe)||0,te=K.get(oe)||0,ce=ie+te,ue=x*ce/q,ae=I*ce/q;ue>0&&(X+=(ie-ue)*(ie-ue)/ue),ae>0&&(X+=(te-ae)*(te-ae)/ae)}const Q=$-1,J=c(X,Q);let ne=null;j.category!==void 0&&E.has(j.category)?ne=j.category:$===2&&([ne]=[...E]);let re=null;if(ne!==null){const oe=O(P.get(ne)||0,x,K.get(ne)||0,I,g(D));oe&&(re={estimate:(P.get(ne)||0)/x-(K.get(ne)||0)/I,lower:oe.lower,upper:oe.upper,confidence:g(D),method:"newcombe (difference in this category's share)",category:ne})}return{test:d.CHI_SQUARE,statistic:X,statisticName:"chiSquare",df:Q,pValue:J,interval:re,effectSize:{name:"categoricalTotalVariation",value:H(P,x,K,I)},nA:x,nB:I,reliable:x>=y&&I>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function A(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function M(P,x,K){if(K===d.WELCH||K===d.MANN_WHITNEY)return{test:K,chosenBy:"override",reason:`caller override: ${K}`};const I=k(P),D=k(x),j=I===null?null:Math.exp(-I/2),E=D===null?null:Math.exp(-D/2);return j!==null&&j<f||E!==null&&E<f?{test:d.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${f})`}:{test:d.WELCH,chosenBy:"auto",reason:j!==null||E!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(P,x,K,I={}){if(!P||!x)return null;const D=g(I.confidence),j=F(x);let E;if(Array.isArray(I.groups)&&I.groups.length===2)E=[A(I.groups[0]),A(I.groups[1])];else{const{map:te}=B(x,K),ce=[...te.entries()].sort((ue,ae)=>ae[1]-ue[1]).slice(0,2).map(ue=>ue[0]);if(ce.length<2)return N("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;E=ce}const[$,q]=E;if($===null||q===null||$===q)return N("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const X=[],Q=[];for(let te=0;te<K.length;te++){const ce=A(j(K[te]));ce===$?X.push(K[te]):ce===q&&Q.push(K[te])}if(X.length===0||Q.length===0)return N("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=I.test&&I.test!=="auto"?String(I.test):null,ne=L(P,X.concat(Q));let re,oe,ie;if(J===d.CHI_SQUARE||!J&&!ne){oe=J?"override":"auto",ie=J?"caller override: chiSquare":"column family: categorical";const te=B(P,X),ce=B(P,Q);re=T(te.map,te.total,ce.map,ce.total,D,{category:I.category})}else{if((J===d.WELCH||J===d.MANN_WHITNEY)&&!ne)return N("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const te=_(P,X),ce=_(P,Q),ue=M(te,ce,J);oe=ue.chosenBy,ie=ue.reason,re=ue.test===d.MANN_WHITNEY?a(te,ce,D):b(te,ce,D)}return re?{...re,chosenBy:oe,reason:ie,groups:[$,q]}:(N("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),ve("packages/core/src/columns/detailcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Z="__lattice_detail",N=36;function z(W){const _=W.config&&W.config.detailColumnWidth||N;return{id:Z,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:_,min:_,max:_,pin:W.config&&W.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(U,B){return!!(B&&B.expanded)},formatValue(){return""}}}const F=z}),ve("packages/core/src/columns/treecolumn.js",function(e,V){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z="__lattice_tree",F=260;function W(U){const B=U.tree||{},H=U.config&&U.config.treeColumnWidth||F,L=()=>(U.columns&&N(U.columns.visible)?U.columns.visible():[]).find(u=>!u.generated)||null,k=(y,u)=>{if(u&&u.group)return u.groupValue;if(N(B.label))return B.label(y,u);if(typeof B.label=="string")return y==null?null:y[B.label];const o=L();return o&&N(o.getValue)?o.getValue(y,u):null},S=()=>{if(B.title)return B.title;const y=typeof B.label=="string"?U.columns&&N(U.columns.get)?U.columns.get(B.label):null:L();return y&&(y.title||y.id)||"Hierarchy"};return{id:z,get title(){return S()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:140,pin:U.config&&U.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(y,u){return k(y,u)},formatValue(y,u){if(u&&u.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";if(y==null)return"";if(!B.label){const o=L();if(o&&N(o.formatValue))return o.formatValue(y,u)}return String(y)}}}const _=W}),ve("packages/core/src/columns/pivotcolumns.js",function(e,V){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").warnOnce,z="__lattice_pivot",F=500;function W(H){const{pivot:L,valueColumns:k,config:S}=H,y=L&&L.paths||[],u=H.separator||S&&S.pivot&&S.pivot.separator||" | ",o=S&&S.pivot&&S.pivot.maxColumns||F;if(!y.length||!k.length)return{tree:[],leaves:[],error:null};const r=_(S),t=y.length*k.length+(r?k.length:0);if(t>o){const s=`pivot would generate ${t} columns, above the limit of ${o}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return N(`pivot.maxColumns:${t}`,s),{tree:[],leaves:[],error:s}}const n=[],i=[];for(const s of y){const c=[];for(const d of k){const f=B(s,d,u);c.push(f),i.push(f)}c.length===1?(c[0].title=String(s),n.push(c[0])):n.push({id:`${z}:group:${s}`,title:String(s),columns:c,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(r){const s=k.map(d=>U(d,S));i.push(...s);const c=S&&S.pivot&&S.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=c,r==="before"?n.unshift(s[0]):n.push(s[0]);else{const d={id:`${z}:group:__totals`,title:c,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};r==="before"?n.unshift(d):n.push(d)}}return{tree:n,leaves:i,error:null}}function _(H){const L=H&&H.pivot&&H.pivot.groupTotals;return L==="before"||L==="after"?L:null}function U(H,L){return{id:`${z}:__total${L&&L.pivot&&L.pivot.separator||" | "}${H.id}`,field:null,title:H.title||H.id,type:H.type,dataType:H.dataType,nullable:!0,align:H.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:H.id,total:!0},value:{pure:!0},cell:{align:H.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:H.total,lookup:null,layout:{width:H.layout&&H.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(k,S){const y=S&&S.totals;return y&&Object.hasOwn(y,H.id)?y[H.id]:null},formatValue(k,S){return k==null?"":H.formatValue?H.formatValue(k,S):String(k)}}}function B(H,L,k){return{id:`${z}:${H}${k}${L.id}`,field:null,title:L.title||L.id,type:L.type,dataType:L.dataType,nullable:!0,align:L.align,generated:!0,pivot:{enabled:!1,index:0,path:H,sourceId:L.id},value:{pure:!0},cell:{align:L.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:L.total,lookup:null,layout:{width:L.layout&&L.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(S,y){return S==null?"":L.formatValue?L.formatValue(S,y):String(S)}}}}),ve("packages/core/src/compute/group.js",function(e,V){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return S}});const Z=V("packages/core/src/compute/handle.js"),N=Z.dictSize,z=Z.identity,F=Z.presenceReader,W=Z.rowCount,_=Z.valueReader,U="",B="\0",H=1<<20;function L(y,u,o,r){const t=y.length,n=y.map(h=>_(h)),i=Array.isArray(r)&&r.some(Boolean),s=i?n.map((h,g)=>r[g]?w=>r[g](h(w)):h):n;if(!i&&t>0&&y.every(h=>h&&h.kind==="dictionary"&&h.dict)){const h=y.map(w=>N(w.dict)+1);let g=1;for(let w=0;w<t;w++)g*=h[w];if(g<=Number.MAX_SAFE_INTEGER){const w=y.map(v=>v.values),p=y.map(v=>F(v)),m=v=>{let l=0;for(let a=0;a<t;a++){const O=p[a],T=O&&O(v)===0?h[a]-1:w[a][v];l=l*h[a]+T}return l},b=new Float64Array(o);for(let v=0;v<o;v++)b[v]=m(u[v]);return{packed:b,strings:null,product:g,readers:s,keyOf:m}}}const d=h=>{let g="";for(let w=0;w<t;w++){const p=s[w](h);g+=(w===0?"":U)+(p==null?B:String(p))}return g},f=new Array(o);for(let h=0;h<o;h++)f[h]=d(u[h]);return{packed:null,strings:f,product:1/0,readers:s,keyOf:d}}function k(y,u,o,r){const t=new Uint32Array(r+1);for(let c=0;c<o;c++)t[u[c]+1]++;for(let c=0;c<r;c++)t[c+1]+=t[c];const n=new Uint32Array(o),i=t.slice(0,r);for(let c=0;c<o;c++)n[i[u[c]]++]=y[c];const s=new Array(r);for(let c=0;c<r;c++)s[c]=n.subarray(t[c],t[c+1]);return s}function S(y,u,o={}){const r=y||[],t=u||z(W(r[0],o)),n=t.length;if(r.length===0||n===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:c,readers:d}=L(r,t,n,o.project),f=new Uint32Array(n);let h=0,g=null;if(i&&c<=Math.max(1024,Math.min(H,n*4))){const b=c,v=new Int32Array(b).fill(-1);for(let l=0;l<n;l++)v[i[l]]=0;for(let l=0;l<b;l++)v[l]===0&&(v[l]=h++);for(let l=0;l<n;l++)f[l]=v[i[l]];g=new Float64Array(h);for(let l=0;l<b;l++)v[l]>=0&&(g[v[l]]=l)}else if(i){const b=new Map;for(let v=0;v<n;v++){const l=i[v];let a=b.get(l);a===void 0&&(a=h++,b.set(l,a)),f[v]=a}g=new Float64Array(h);for(const[v,l]of b)g[l]=v}else{const b=new Map;for(let v=0;v<n;v++){const l=s[v];let a=b.get(l);a===void 0&&(a=h++,b.set(l,a)),f[v]=a}}const w=k(t,f,n,h),p=new Array(h);for(let b=0;b<h;b++){const v=w[b][0],l=new Array(d.length);for(let a=0;a<d.length;a++)l[a]=d[a](v);p[b]=l}const m={keys:p,buckets:w};return g&&(m.packed=g),m}}),ve("packages/core/src/compute/pivot.js",function(e,V){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return n}});const N=V("packages/core/src/internal/util.js").warnOnce,F=V("packages/core/src/compute/handle.js").valueComparator,_=V("packages/core/src/compute/group.js").packKeys,B=V("packages/core/src/compute/total.js").total,H="|",L="/",k=2e3;function S(c,d,f){return`${c}${H}${d}${H}${f}`}function y(c,d){let f="";for(let h=0;h<c.length;h++){const g=c[h];f+=(h===0?"":d)+(g==null?"":String(g))}return f}function u(c,d,f={}){const h=f.separator||L,g=d.length,{keyOf:w,readers:p}=_(c,d,0),m=new Map,b=[],v=[];for(let C=0;C<g;C++){const P=d[C],x=w(P);if(m.has(x))continue;m.set(x,b.length),v.push(x);const K=new Array(p.length);for(let I=0;I<p.length;I++)K[I]=p[I](P);b.push(K)}const l=F(f.locale),a=b.map((C,P)=>P);a.sort((C,P)=>{const x=b[C],K=b[P];for(let I=0;I<x.length;I++){const D=o(x[I],K[I],l);if(D!==0)return D}return C-P});const O=new Array(a.length),T=new Array(a.length),A=new Map;for(let C=0;C<a.length;C++){const P=a[C];O[C]=b[P],T[C]=y(b[P],h),A.set(v[P],C)}return{keys:O,paths:T,idOf:C=>{const P=A.get(w(C));return P===void 0?-1:P}}}function o(c,d,f){const h=c==null,g=d==null;return h||g?h&&g?0:h?1:-1:f(c,d)}function r(c){const d=c.values||c.totals||[];if(d.length&&typeof d[0]=="object"&&d[0]!==null)return d.filter(w=>w&&w.handle);const f=typeof c.handle=="function"?c.handle:null;if(!f)return d.length&&N("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 h=typeof c.totalOf=="function"?c.totalOf:null,g=[];for(const w of d){const p=f(w);p&&g.push({colId:w,handle:p,fn:h?h(w):"sum"})}return g}function t(c,d,f){if(Array.isArray(c)){const h=f||{};return{...h,pivotHandles:c,order:d||null,groups:h.groups||null}}return c||{}}function n(c,d,f){const h=t(c,d,f),g=h.separator||L,w=r(h),p=h.maxColumns===void 0?k:h.maxColumns,m=h.groups&&h.groups.buckets?h.groups:null,b=m?m.buckets:[h.order||new Uint32Array(0)],v=h.groupPaths||(m?m.keys.map(x=>y(x,g)):[""]),l=s(b),{keys:a,paths:O,idOf:T}=u(h.pivotHandles||[],l,h),A=O.length*Math.max(1,w.length),M=i(O,w,g);if(p&&A>p){const x=new Map;return{keys:a,paths:O,fields:M,groupPaths:v,columns:A,values:x,cells:x,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${A} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:A,maxColumns:p}}}const C=new Map,P=O.length;for(let x=0;x<b.length;x++){const K=b[x],I=v[x]===void 0?"":v[x],D=K.length;if(D===0)continue;const j=new Int32Array(D),E=new Uint32Array(P+1);for(let X=0;X<D;X++){const Q=T(K[X]);j[X]=Q,Q>=0&&E[Q+1]++}for(let X=0;X<P;X++)E[X+1]+=E[X];const $=new Uint32Array(D),q=E.slice(0,P);for(let X=0;X<D;X++){const Q=j[X];Q>=0&&($[q[Q]++]=K[X])}for(let X=0;X<P;X++){const Q=E[X],J=E[X+1];if(J===Q)continue;const ne=$.subarray(Q,J);for(let re=0;re<w.length;re++){const oe=w[re],ie=B(oe.handle,ne,oe.fn,h.totalContext||{locale:h.locale});C.set(S(I,O[X],oe.colId),ie)}}}return{keys:a,paths:O,fields:M,groupPaths:v,columns:A,values:C,cells:C,error:null}}function i(c,d,f){if(d.length===0)return c.slice();const h=[];for(const g of c)for(const w of d)h.push(`${g}${f}${w.colId}`);return h}function s(c){if(c.length===1)return c[0]||new Uint32Array(0);let d=0;for(const g of c)d+=g?g.length:0;const f=new Uint32Array(d);let h=0;for(const g of c)!g||g.length===0||(f.set(g,h),h+=g.length);return f}}),ve("packages/core/src/store/bitset.js",function(e,V){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return N}});const Z=8;class N{static#e=new Uint8Array(256);static{for(let F=1;F<256;F++)N.#e[F]=N.#e[F>>1]+(F&1)}#t;#n;constructor(F=0){const W=Math.max(0,F|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/Z))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(F){return F<0||F>=this.#n?0:this.#t[F>>3]>>(F&7)&1}set(F){return F>=0&&F<this.#n&&(this.#t[F>>3]|=1<<(F&7)),this}clear(F){return F>=0&&F<this.#n&&(this.#t[F>>3]&=~(1<<(F&7))),this}assign(F,W){return W?this.set(F):this.clear(F)}fill(F=!1){return this.#t.fill(F?255:0),F&&this.#r(),this}grow(F){const W=Math.max(0,F|0);if(W<=this.#n)return this;const _=Math.ceil(W/Z);if(_>this.#t.length){const U=new Uint8Array(_);U.set(this.#t),this.#t=U}return this.#n=W,this}count(){const F=this.#t,W=N.#e;let _=0;for(let U=0;U<F.length;U++)_+=W[F[U]];return _}and(F){const W=F instanceof N?F.words:F,_=this.#t,U=Math.min(_.length,W.length);for(let B=0;B<U;B++)_[B]&=W[B];for(let B=U;B<_.length;B++)_[B]=0;return this}or(F){const W=F instanceof N?F.words:F,_=this.#t,U=Math.min(_.length,W.length);for(let B=0;B<U;B++)_[B]|=W[B];return this}not(){const F=this.#t;for(let W=0;W<F.length;W++)F[W]=~F[W]&255;return this.#r(),this}clone(){const F=new N(this.#n);return F.words.set(this.#t.subarray(0,F.words.length)),F}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const F=this.#n&7;if(F===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<F)-1)}static from(F){const W=Array.isArray(F)?F:Array.from(F),_=new N(W.length);for(let U=0;U<W.length;U++)W[U]&&_.set(U);return _}}}),ve("packages/core/src/store/dictionary.js",function(e,V){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return F}});const Z=V("packages/core/src/internal/util.js"),N=Z.collator,z=Z.defaultCompare;class F{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(_=[]){this.#e=[];for(let U=0;U<_.length;U++){const B=_[U];this.#t.has(B)||(this.#t.set(B,this.#e.length),this.#e.push(B))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let _=this.#e.length*8;for(let U=0;U<this.#e.length;U++){const B=this.#e[U];typeof B=="string"&&(_+=B.length*2),_+=16}return _}codeOf(_){const U=this.#t.get(_);if(U!==void 0)return U;const B=this.#e.length;return this.#e.push(_),this.#t.set(_,B),this.#n++,B}lookup(_){const U=this.#t.get(_);return U===void 0?-1:U}has(_){return this.#t.has(_)}valueOf(_){return this.#e[_]}values(){return this.#e}ranks(_){const U=_||"";if(this.#r&&this.#o===this.#n&&this.#i===U)return this.#r;const B=this.#e.length,H=new Array(B);for(let y=0;y<B;y++)H[y]=y;const L=N(_).compare,k=this.#e;H.sort((y,u)=>this.#a(k[y],k[u],L));const S=new Uint32Array(B);for(let y=0;y<B;y++)S[H[y]]=y;return this.#r=S,this.#o=this.#n,this.#i=U,S}#a(_,U,B){return typeof _=="string"&&typeof U=="string"?B(_,U):z(_,U)}}}),ve("packages/core/src/store/multivalue.js",function(e,V){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Z}});class Z{#e;#t;#n=0;#r=0;constructor(z={}){const F=Math.max(1,z.rows??16),W=Math.max(1,z.values??F);this.#e=new Int32Array(W),this.#t=new Uint32Array(F+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(z){return z<0||z>=this.#n?0:this.#t[z+1]-this.#t[z]}at(z){return z<0||z>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[z],this.#t[z+1])}has(z,F){if(z<0||z>=this.#n)return!1;const W=this.#e,_=this.#t[z+1];for(let U=this.#t[z];U<_;U++)if(W[U]===F)return!0;return!1}hasAny(z,F){for(let W=0;W<F.length;W++)if(this.has(z,F[W]))return!0;return!1}hasAll(z,F){for(let W=0;W<F.length;W++)if(!this.has(z,F[W]))return!1;return!0}hasNone(z,F){return!this.hasAny(z,F)}push(z){const F=this.#n,W=z.length;this.#o(F+1),this.#i(this.#r+W);const _=this.#r;for(let U=0;U<W;U++)this.#e[_+U]=z[U]|0;return this.#r+=W,this.#n=F+1,this.#t[F]=_,this.#t[F+1]=this.#r,F}write(z,F){if(z===this.#n){this.push(F);return}if(z<0||z>this.#n)return;const W=this.#t[z],_=this.#t[z+1],U=F.length;if(_-W===U){for(let B=0;B<U;B++)this.#e[W+B]=F[B]|0;return}this.#a(z,F)}compact(z,F,W){const _=this.#e,U=this.#t,B=this.#n,H=new Int32Array(Math.max(1,this.#r)),L=new Uint32Array(F+1);let k=0;for(let S=0;S<B;S++){if(z[S]===W)continue;const y=U[S],u=U[S+1];L[z[S]]=k;for(let o=y;o<u;o++)H[k++]=_[o];L[z[S]+1]=k}this.#e=H,this.#t=L,this.#n=F,this.#r=k}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(z){if(z+1<=this.#t.length)return;let F=this.#t.length-1;for(;F<z;)F=F*2||16;const W=new Uint32Array(F+1);W.set(this.#t),this.#t=W}#i(z){if(z<=this.#e.length)return;let F=this.#e.length;for(;F<z;)F=F*2||16;const W=new Int32Array(F);W.set(this.#e),this.#e=W}#a(z,F){const W=this.#e,_=this.#t,U=this.#n,B=F.length-(_[z+1]-_[z]),H=new Int32Array(Math.max(1,this.#r+B)),L=new Uint32Array(_.length);let k=0;for(let S=0;S<U;S++){if(L[S]=k,S===z)for(let y=0;y<F.length;y++)H[k++]=F[y]|0;else for(let y=_[S];y<_[S+1];y++)H[k++]=W[y];L[S+1]=k}this.#e=H,this.#t=L,this.#r=k}}}),ve("packages/core/src/compute/sort.js",function(e,V){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const Z=V("packages/core/src/compute/handle.js"),N=Z.bitReader,z=Z.dictRanks,F=Z.dictSize,W=Z.identity,_=Z.isMissing,U=Z.presenceReader,B=Z.rowCount,H=Z.valueComparator,L=Z.valueReader,k=new Uint32Array(0),S=new ArrayBuffer(8),y=new Float64Array(S),u=new Uint32Array(S),o=(y[0]=-1,(u[1]&2147483648)!==0?1:0),r=o===1?0:1;function t(K,I){y[0]=K;let D=u[o],j=u[r];(D&2147483648)!==0?(D=~D>>>0,j=~j>>>0):D=(D^2147483648)>>>0,I[0]=j,I[1]=D}function n(K,I,D,j){if(j<2)return K;const E=new Uint32Array(256*8);for(let oe=0;oe<j;oe++){const ie=I[oe],te=D[oe];E[ie&255]++,E[256+(ie>>>8&255)]++,E[512+(ie>>>16&255)]++,E[768+(ie>>>24&255)]++,E[1024+(te&255)]++,E[1280+(te>>>8&255)]++,E[1536+(te>>>16&255)]++,E[1792+(te>>>24&255)]++}let $=K,q=I,X=D,Q=new Uint32Array(j),J=new Uint32Array(j),ne=new Uint32Array(j);const re=new Uint32Array(256);for(let oe=0;oe<8;oe++){const ie=oe<<8,te=(oe&3)<<3,ce=oe>=4;let ue=!1;for(let he=0;he<256;he++)if(E[ie+he]===j){ue=!0;break}if(ue)continue;let ae=0;for(let he=0;he<256;he++)re[he]=ae,ae+=E[ie+he];for(let he=0;he<j;he++){const ke=q[he],Oe=X[he],De=(ce?Oe:ke)>>>te&255,_e=re[De]++;Q[_e]=$[he],J[_e]=ke,ne[_e]=Oe}let pe=$;$=Q,Q=pe,pe=q,q=J,J=pe,pe=X,X=ne,ne=pe}return $}function i(K,I,D){if(D<2)return K;const j=new Uint32Array(256*4);for(let J=0;J<D;J++){const ne=I[J];j[ne&255]++,j[256+(ne>>>8&255)]++,j[512+(ne>>>16&255)]++,j[768+(ne>>>24&255)]++}let E=K,$=I,q=new Uint32Array(D),X=new Uint32Array(D);const Q=new Uint32Array(256);for(let J=0;J<4;J++){const ne=J<<8,re=J<<3;let oe=!1;for(let ce=0;ce<256;ce++)if(j[ne+ce]===D){oe=!0;break}if(oe)continue;let ie=0;for(let ce=0;ce<256;ce++)Q[ce]=ie,ie+=j[ne+ce];for(let ce=0;ce<D;ce++){const ue=$[ce],ae=Q[ue>>>re&255]++;q[ae]=E[ce],X[ae]=ue}let te=E;E=q,q=te,te=$,$=X,X=te}return E}function s(K,I,D,j){const E=new Uint32Array(j+1);for(let X=0;X<D;X++)E[I[X]]++;let $=0;for(let X=0;X<=j;X++){const Q=E[X];E[X]=$,$+=Q}const q=new Uint32Array(D);for(let X=0;X<D;X++)q[E[I[X]]++]=K[X];return q}function c(K,I,D,j){return D<2?K:j<=65536||j<=D*2?s(K,I,D,j):i(K,I,D)}function d(K,I){return K.length===I&&K.byteOffset===0?K:Uint32Array.prototype.slice.call(K,0,I)}function f(K,I,D=!1){const j=I||W(K.length),E=j.length;if(E<2)return Uint32Array.from(j);const $=new Uint32Array(E),q=new Uint32Array(E),X=new Uint32Array(E),Q=new Uint32Array(E),J=new Uint32Array(2);let ne=0,re=0;for(let te=0;te<E;te++){const ce=j[te],ue=K[ce];if(Number.isNaN(ue)){Q[re++]=ce;continue}t(ue,J),D?(q[ne]=~J[0]>>>0,X[ne]=~J[1]>>>0):(q[ne]=J[0],X[ne]=J[1]),$[ne++]=ce}const oe=n($.subarray(0,ne),q.subarray(0,ne),X.subarray(0,ne),ne);if(re===0)return d(oe,ne);const ie=new Uint32Array(E);return ie.set(oe.subarray(0,ne),0),ie.set(Q.subarray(0,re),ne),ie}function h(K,I,D=!1){const j=I||W(K.length),E=j.length;if(E<2)return Uint32Array.from(j);const $=Uint32Array.from(j),q=new Uint32Array(E);for(let X=0;X<E;X++){const Q=(K[$[X]]^2147483648)>>>0;q[X]=D?~Q>>>0:Q}return d(i($,q,E),E)}function g(K,I,D={}){const j=I||W(B(K,D)),E=j.length;if(E<2)return Uint32Array.from(j);const $=z(K.dict,D.locale),q=K.values,X=U(K),Q=Math.max(F(K.dict),$.length),J=Q,ne=Uint32Array.from(j),re=new Uint32Array(E),oe=!!D.descending;for(let ie=0;ie<E;ie++){const te=ne[ie];let ce=X&&X(te)===0?J:$[q[te]];ce===void 0&&(ce=J),re[ie]=oe?J-ce:ce}return d(c(ne,re,E,Q+1),E)}function w(K,I,D){const j=I.length;let E=Uint32Array.from(I);if(j<2)return E;let $=new Uint32Array(j);for(let q=1;q<j;q<<=1){for(let Q=0;Q<j;Q+=q<<1){const J=Math.min(Q+q,j),ne=Math.min(Q+(q<<1),j);let re=Q,oe=J,ie=Q;for(;re<J&&oe<ne;)$[ie++]=D(K[E[re]],K[E[oe]])<=0?E[re++]:E[oe++];for(;re<J;)$[ie++]=E[re++];for(;oe<ne;)$[ie++]=E[oe++]}const X=E;E=$,$=X}return E}function p(K,I,D){const j=N(K.values),E=I.length,$=new Uint32Array(E),q=D?1:0;let X=0;for(let Q=0;Q<E;Q++)j(I[Q])===q&&($[X++]=I[Q]);for(let Q=0;Q<E;Q++)j(I[Q])!==q&&($[X++]=I[Q]);return $}function m(K,I){const D=K.values,j=K.kind;if((j==="object"||j===void 0)&&(Array.isArray(D)||ArrayBuffer.isView(D))&&!K.presence)return D;const $=L(K),q=new Array(B(K)||0);for(let X=0;X<I.length;X++){const Q=I[X];q[Q]=$(Q)}return q}function b(K,I){for(let D=0;D<I.length;D++)if(typeof K[I[D]]!="string")return!1;return!0}function v(K,I,D,j,E){const $=K.length,q=Uint32Array.from(K);if($<2||j<1)return q;const X=new Uint32Array($),Q=j-1;for(let J=0;J<$;J++){const ne=D[I[J]];X[J]=E?Q-ne:ne}return d(c(q,X,$,j),$)}function l(K,I,D){const j=H(D),E=new Array(I);for(let q=0;q<I;q++)E[q]=q;E.sort((q,X)=>j(K[q],K[X])||q-X);const $=new Uint32Array(I);for(let q=0;q<I;q++)$[E[q]]=q;return $}function a(K,I,D){const j=I.length,E=new Map,$=[],q=new Uint32Array(j);for(let J=0;J<j;J++){const ne=K[I[J]];let re=E.get(ne);re===void 0&&(re=$.length,E.set(ne,re),$.push(ne)),q[J]=re}const X=$.length,Q=l($,X,D.locale);return v(I,q,Q,X,!!D.descending)}function O(K,I,D){const j=m(K,I);if(I.length>=2&&b(j,I)){const q=K.stringRank;return q&&q.version===K.version&&q.usable(I,j,D.locale)?q.sort(I,D):a(j,I,D)}const E=H(D.locale),$=D.descending?(q,X)=>E(X,q):E;return w(j,I,$)}function T(K,I,D){const j=m(K,I),E=D.compare,q=!!D.descending?(X,Q)=>-E(X,Q,void 0,void 0,!0):(X,Q)=>E(X,Q,void 0,void 0,!1);return w(j,I,q)}function A(K,I){const D=I.length,j=U(K),E=K.values,$=K.kind==="float64"&&!!E,q=K.kind==="object"||K.kind==="multi"||K.kind===void 0;if(!j&&!$&&!q)return{present:I,absent:k};const X=new Uint32Array(D),Q=new Uint32Array(D);let J=0,ne=0;if(j&&$)for(let re=0;re<D;re++){const oe=I[re];j(oe)===1&&!Number.isNaN(E[oe])?X[J++]=oe:Q[ne++]=oe}else if($&&!j)for(let re=0;re<D;re++){const oe=I[re];Number.isNaN(E[oe])?Q[ne++]=oe:X[J++]=oe}else if(j&&!q)for(let re=0;re<D;re++){const oe=I[re];j(oe)===1?X[J++]=oe:Q[ne++]=oe}else{const re=L(K);for(let oe=0;oe<D;oe++){const ie=I[oe];_(re(ie))?Q[ne++]=ie:X[J++]=ie}}return ne===0?{present:I,absent:k}:{present:X.subarray(0,J),absent:Q.subarray(0,ne)}}function M(K,I,D){if(I.length===0)return K;const j=new Uint32Array(K.length+I.length);return D?(j.set(I,0),j.set(K,I.length)):(j.set(K,0),j.set(I,K.length)),j}function C(K,I,D={}){const j=I||W(B(K,D));if(!K||j.length<2)return Uint32Array.from(j);const{present:E,absent:$}=A(K,j);if(E.length===0)return Uint32Array.from(j);const q=!!D.descending;let X;if(typeof D.compare=="function")X=T(K,E,D);else switch(K.kind){case"float64":X=f(K.values,E,q);break;case"int32":X=h(K.values,E,q);break;case"dictionary":X=g(K,E,D);break;case"bitset":X=p(K,E,q);break;default:X=O(K,E,D);break}return M(X,$,!!D.nullsFirst)}function P(K,I,D,j={}){const E=I||[],$=E.length&&(E[0].handle||x(K,E[0].col))||K&&K[0];let q=D||W(B($,j));for(let X=E.length-1;X>=0;X--){const Q=E[X],J=Q.handle||x(K,Q.col)||K&&K[X];J&&(q=C(J,q,{descending:Q.descending!==void 0?!!Q.descending:Q.dir==="desc",nullsFirst:!!Q.nullsFirst,locale:Q.locale!==void 0?Q.locale:j.locale,compare:Q.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function x(K,I){if(!(!K||I===void 0)){for(let D=0;D<K.length;D++)if(K[D]&&K[D].id===I)return K[D]}}}),ve("packages/core/src/store/stringrank.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const Z=V("packages/core/src/compute/sort.js"),N=Z.collateStringRanks,z=Z.rankSortStrings,F=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#a;#s=!1;#l=null;#u=-1;#c="\0";constructor(U=F){this.#a=U>0?U:F,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(U){this.#i=U}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#s}get length(){return this.#r}get bytes(){let U=this.#n.byteLength;const B=this.#e;for(let H=0;H<B.length;H++)U+=B[H].length*2+24;return U}#d(U,B){const H=this.#t.get(U);if(H!==void 0)return H;if(this.#s)return-1;if(B&&this.#e.length>=this.#a)return this.#s=!0,-1;const L=this.#e.length;return this.#e.push(U),this.#t.set(U,L),this.#o++,L}build(U,B){const H=B|0;this.#e=[],this.#t=new Map,this.#o=0,this.#s=!1,this.#l=null,this.#u=-1,this.#n=new Uint32Array(H);for(let L=0;L<H;L++){const k=U[L],S=typeof k=="string"?this.#d(k,!1):-1;this.#n[L]=S<0?0:S}this.#r=H}append(U,B,H){const L=(B|0)+(H|0);if(L>this.#n.length){const k=new Uint32Array(L);k.set(this.#n.subarray(0,this.#r)),this.#n=k}for(let k=B|0;k<L;k++){const S=U[k],y=typeof S=="string"?this.#d(S,!0):-1;this.#n[k]=y<0?0:y}this.#r=Math.max(this.#r,L)}ranks(U){const B=U||"";if(this.#l&&this.#u===this.#o&&this.#c===B)return this.#l;const H=N(this.#e,this.#e.length,U);return this.#l=H,this.#u=this.#o,this.#c=B,H}usable(U,B,H){if(this.#s||this.#e.length===0)return!1;const L=this.#n,k=this.#e,S=this.#r;for(let y=0;y<U.length;y++){const u=U[y];if(u>=S||k[L[u]]!==B[u])return!1}return!0}sort(U,B){const H=this.ranks(B.locale),L=this.#e.length,k=U.length,S=new Uint32Array(k),y=this.#n;for(let u=0;u<k;u++)S[u]=y[U[u]];return z(U,S,H,L,!!B.descending)}}}),ve("packages/core/src/store/columnstore.js",function(e,V){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return g}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isFunction,F=Z.pathGetter,_=V("packages/core/src/store/bitset.js").Bitset,B=V("packages/core/src/store/dictionary.js").Dictionary,L=V("packages/core/src/store/multivalue.js").MultiValue,S=V("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,u=1024,o=5e3,r=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function n(w){return w==null}function i(w){if(typeof w=="number")return w;if(w instanceof Date)return w.getTime();if(typeof w=="boolean")return w?1:0;const p=Number(w);return Number.isNaN(p)&&typeof w=="string"?Date.parse(w):p}function s(w){const p=i(w);return Number.isFinite(p)?p|0:0}function c(w){return n(w)?[]:Array.isArray(w)?w:[w]}function d(w,p){switch(w.kind){case"float64":case"int32":return w.buf[p];case"bitset":return w.bits.get(p)===1;case"dictionary":return w.dict.valueOf(w.buf[p]);case"multi":{const m=w.mv.at(p),b=new Array(m.length);for(let v=0;v<m.length;v++)b[v]=w.dict.valueOf(m[v]);return b}default:return w.buf[p]}}function f(w,p){switch(w.kind){case"float64":case"int32":return w.values[p];case"bitset":return(w.values[p>>3]&1<<(p&7))!==0;case"dictionary":return(w.table||[])[w.values[p]];case"multi":{const m=w.offsets[p],b=w.offsets[p+1],v=w.table||[],l=new Array(b-m);for(let a=m;a<b;a++)l[a-m]=v[w.values[a]];return l}default:return w.values[p]}}class h{#e;#t;#n;#r;#o;#i;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#v=0;#b=0;#y=null;#w=null;#S=!1;constructor(p,m){this.#e=p.id;const b=t.has(p.kind)?p.kind:"object";p.kind&&!t.has(p.kind)&&N(`store.kind.${p.id}`,`column "${p.id}" declares unknown storage kind "${p.kind}"; falling back to object`),this.#n=b,this.#t=b,this.#r=p.nullable!==!1,this.#a=p.dictionary??null,this.#i=m,this.#o=z(p.read)?p.read:F(p.field||p.id),this.#f=p.stringRankIndex!=="off",this.#m=typeof p.stringRankMaxDistinct=="number"?p.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#e}get kind(){return this.#s?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#s?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#l:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#s?this.#g:this.#T().presence}get dict(){return this.#S||!this.#s?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const p=this.values,m=this.#i.physical();if(!p||m===0)return null;if(this.#h===null){if(typeof p[0]!="string")return null;const b=new S(this.#j());return b.build(p,m),b.version=this.#b,this.#h=b,this.#p=this.#b,b.capped?null:b}return this.#h.length<m&&this.#h.append(p,this.#h.length,m-this.#h.length),this.#h.version=this.#b,this.#p=this.#b,this.#h.capped?null:this.#h}#j(){return this.#m}#A(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#s||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let p=0;return this.#l&&(p+=this.#l.byteLength??this.#l.length*8),this.#u&&(p+=this.#u.bytes),this.#c&&(p+=this.#c.bytes),this.#g&&(p+=this.#g.bytes),this.#d&&(p+=this.#d.bytes),this.#y&&(p+=this.#y.size*24),p}get(p){if(!this.#S&&!(p<0||p>=this.#i.physical())){if(!this.#s)return this.#E(p);if(this.#r&&this.#g.get(p)===0)return null;switch(this.#t){case"float64":case"int32":return this.#l[p];case"bitset":return this.#u.get(p)===1;case"dictionary":return this.#d.valueOf(this.#l[p]);case"multi":{const m=this.#c.at(p),b=new Array(m.length);for(let v=0;v<m.length;v++)b[v]=this.#d.valueOf(m[v]);return b}default:return this.#l[p]}}}set(p,m){this.#S||(this.#s?this.#C(p,m):this.#y.set(p,m===void 0?null:m),this.#h&&this.#A(),this.#b++)}read(p){return this.#o(p)}appendColumn(p,m,b){if(this.#S||b<=0)return;if(!this.#s){this.#b++;return}const v=this.#o,l=this.#r,a=this.#g;let O=!1;switch(this.#t){case"float64":{const T=this.#l;for(let A=0;A<b;A++){const M=v(p[A]);if(typeof M=="number"){l&&a.set(m+A),T[m+A]=M;continue}const C=M==null;l?a.assign(m+A,!C):C&&(O=!0),T[m+A]=C?NaN:i(M)}break}case"int32":{const T=this.#l;for(let A=0;A<b;A++){const M=v(p[A]),C=M==null;l?a.assign(m+A,!C):C&&(O=!0),T[m+A]=C?0:s(M)}break}case"bitset":{const T=this.#u;for(let A=0;A<b;A++){const M=v(p[A]),C=M==null;l?a.assign(m+A,!C):C&&(O=!0),T.assign(m+A,!C&&!!M)}break}case"dictionary":{const T=this.#l,A=this.#d;for(let M=0;M<b;M++){const C=v(p[M]),P=C==null;l?a.assign(m+M,!P):P&&(O=!0),T[m+M]=P?0:A.codeOf(C)}break}case"multi":{const T=this.#c,A=this.#d;for(let M=0;M<b;M++){const C=v(p[M]),P=C==null;l?a.assign(m+M,!P):P&&(O=!0);const x=c(C),K=new Array(x.length);for(let I=0;I<x.length;I++)K[I]=A.codeOf(x[I]);T.write(m+M,K)}break}default:{const T=this.#l;for(let A=0;A<b;A++){const M=v(p[A]),C=M==null;l?a.assign(m+A,!C):C&&(O=!0),T[m+A]=C?null:M}break}}O&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#l,m,b),this.#h.version=this.#b+1,this.#p=this.#b+1),this.#b++}appendPacked(p,m,b){if(this.#S||b<=0||!p)return;if(!this.#s){this.#b++;return}const v=this.#g,l=p.presence;if(v)if(l)for(let O=0;O<b;O++)v.assign(m+O,(l[O>>3]&1<<(O&7))!==0);else for(let O=0;O<b;O++)v.set(m+O);const a=p.kind===this.#t;if(a&&(this.#t==="float64"||this.#t==="int32")){this.#l.set(p.values,m),this.#b++;return}if(a&&this.#t==="bitset"){const O=p.values;for(let T=0;T<b;T++)this.#u.assign(m+T,(O[T>>3]&1<<(T&7))!==0);this.#b++;return}if(a&&this.#t==="dictionary"){const O=p.table||[],T=new Uint32Array(O.length);for(let P=0;P<O.length;P++)T[P]=this.#d.codeOf(O[P]);const A=p.values,M=this.#l,C=v;for(let P=0;P<b;P++){if(C&&(l&&(l[P>>3]&1<<(P&7))===0)){M[m+P]=0;continue}M[m+P]=T[A[P]]??0}this.#b++;return}if(a&&this.#t==="multi"){const O=p.table||[],T=new Uint32Array(O.length);for(let C=0;C<O.length;C++)T[C]=this.#d.codeOf(O[C]);const A=p.values,M=p.offsets;for(let C=0;C<b;C++){const P=M[C],x=M[C+1],K=new Array(x-P);for(let I=P;I<x;I++)K[I-P]=T[A[I]]??0;this.#c.write(m+C,K)}this.#b++;return}for(let O=0;O<b;O++){const T=l?(l[O>>3]&1<<(O&7))===0:p.kind==="object"?p.values[O]===null:!1;this.#C(m+O,T?null:f(p,O))}this.#b++}touch(){this.#b++}columnarise(p,m){if(this.#s||this.#S)return;const b=new Array(m);for(let v=0;v<m;v++)b[v]=this.#E(v);this.#t=this.#n,this.#s=!0,this.#O(p);for(let v=0;v<m;v++)this.#C(v,b[v]);this.#y.clear(),this.#w=null,this.#A(),this.#b++}grow(p){if(!(!this.#s||this.#S||p<=this.#v)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#l.constructor(p);m.set(this.#l),this.#l=m;break}case"bitset":this.#u.grow(p);break;case"multi":break;default:this.#l.length=p;break}this.#g&&this.#g.grow(p),this.#v=p,this.#b++}}convert(p){if(this.#S||!t.has(p)||(this.#n=p,!this.#s||p===this.#t))return!1;const m={kind:this.#t,buf:this.#l,bits:this.#u,mv:this.#c,dict:this.#d},b=this.#i.physical(),v=this.#g;this.#t=p,this.#O(this.#v);for(let l=0;l<b;l++){const a=v!==null&&v.get(l)===0;a&&p!=="multi"||this.#C(l,a?null:d(m,l))}return this.#A(),this.#b++,!0}compact(p,m,b){if(!this.#S){if(this.#A(),!this.#s){const v=this.#y;if(v.size){const l=new Map;for(const[a,O]of v)p[a]!==y&&l.set(p[a],O);this.#y=l}this.#w=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#l;for(let l=0;l<m;l++)p[l]!==y&&(v[p[l]]=v[l]);if(this.#t==="object")for(let l=b;l<m;l++)v[l]=void 0;break}case"bitset":{const v=this.#u;for(let l=0;l<m;l++)p[l]!==y&&v.assign(p[l],v.get(l)===1);for(let l=b;l<m;l++)v.clear(l);break}case"multi":this.#c.compact(p,b,y);break;default:break}if(this.#g){const v=this.#g;for(let l=0;l<m;l++)p[l]!==y&&v.assign(p[l],v.get(l)===1);for(let l=b;l<m;l++)v.clear(l)}this.#b++}}release(){this.#S||(this.#S=!0,this.#l=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#y=new Map,this.#w=null,this.#v=0,this.#b++)}#O(p){const m=Math.max(1,p);switch(this.#l=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#l=new Float64Array(m);break;case"int32":this.#l=new Int32Array(m);break;case"bitset":this.#u=new _(m);break;case"dictionary":this.#l=new Uint32Array(m),this.#d=this.#d??new B(this.#a??[]);break;case"multi":this.#c=new L({rows:m,values:m}),this.#d=this.#d??new B(this.#a??[]);break;default:this.#l=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new _(m)),this.#v=m}#C(p,m){const b=n(m);switch(this.#r?this.#g.assign(p,!b):b&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#l[p]=b?NaN:i(m);break;case"int32":this.#l[p]=b?0:s(m);break;case"bitset":this.#u.assign(p,!b&&!!m);break;case"dictionary":this.#l[p]=b?0:this.#d.codeOf(m);break;case"multi":{const v=c(m),l=new Array(v.length);for(let a=0;a<v.length;a++)l[a]=this.#d.codeOf(v[a]);this.#c.write(p,l);break}default:this.#l[p]=b?null:m;break}}#E(p){if(this.#y.has(p))return this.#y.get(p);const m=this.#o(this.#i.rowAt(p));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#b)return this.#w;const p=this.#i.physical(),m=new Array(p),b=this.#r?new _(p):null;for(let v=0;v<p;v++){const l=this.#E(v);m[v]=l,b&&!n(l)&&b.set(v)}return this.#w={version:this.#b,values:m,presence:b},this.#w}}class g{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#a=0;#s=0;#l=new _(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(p,m={}){this.#e=Array.isArray(p)?p:[],this.#h=Math.max(1,m.initialCapacity??u),this.#c=m.retainSource!==!1,this.#d=this.#c?m.columnarBelow??o:0,this.#f=m.compactRatio??r;const b={rowAt:v=>this.#r[v],physical:()=>this.#o};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){N(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const l=new h(v,b);this.#t.set(v.id,l),this.#n.push(l)}this.#d<=0&&this.#v()}get count(){return this.#a}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#s}get columnar(){return this.#u}get destroyed(){return this.#m}get bytes(){let p=this.#l.bytes+this.#r.length*8;for(const m of this.#n)p+=m.bytes;return p}append(p){const m=this.#o;if(this.#m||!p)return{from:m,to:m};const b=p.length|0;if(b===0)return{from:m,to:m};if(this.#c)for(let l=0;l<b;l++)this.#r[m+l]=p[l];if(this.#o=m+b,this.#a+=b,this.#l.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#v();else for(const l of this.#n)l.touch();return{from:m,to:this.#o}}this.#p(this.#o);const v=this.#n;for(let l=0;l<v.length;l++)v[l].appendColumn(p,m,b);return{from:m,to:this.#o}}appendPacked(p,m){const b=this.#o;if(this.#m||!p)return{from:b,to:b};const v=p.count|0;if(v===0)return{from:b,to:b};if(this.#c&&m)for(let a=0;a<v;a++)this.#r[b+a]=m[a];this.#o=b+v,this.#a+=v,this.#l.grow(this.#o),this.#u||this.#v(),this.#p(this.#o);const l=new Map;for(const a of p.columns)l.set(a.id,a);for(const a of this.#n){const O=l.get(a.id);O?a.appendPacked(O,b,v):a.grow(this.#i)}return{from:b,to:this.#o}}source(p){if(this.#c)return this.#r[p];if(!(p<0||p>=this.#o))return this.#g(p)}setSource(p,m){this.#m||p<0||p>=this.#o||this.#c&&(this.#r[p]=m)}get(p,m){const b=this.#t.get(p);return b?b.get(m):void 0}set(p,m,b){if(this.#m||m<0||m>=this.#o)return;const v=this.#t.get(p);if(!v){N(`store.set.${p}`,`set() on unknown column "${p}"`);return}v.set(m,b)}remove(p){return this.#m||p<0||p>=this.#o||this.#l.get(p)===1?!1:(this.#l.set(p),this.#s++,this.#a--,!0)}live(p){return p<0||p>=this.#o?!1:this.#l.get(p)===0}compact(p={}){if(this.#m||this.#s===0||!p.force&&this.#s/this.#o<this.#f)return null;const m=this.#o,b=new Uint32Array(m);let v=0;for(let l=0;l<m;l++)b[l]=this.#l.get(l)===1?y:v++;for(const l of this.#n)l.compact(b,m,v);if(this.#c){const l=this.#r;for(let a=0;a<m;a++)b[a]!==y&&(l[b[a]]=l[a]);l.length=v}return this.#o=v,this.#a=v,this.#s=0,this.#l=new _(Math.max(this.#i,v)),b}column(p){return this.#t.get(p)}columns(){return this.#n.slice()}liveIndices(){const p=new Uint32Array(this.#a);if(this.#s===0){for(let b=0;b<this.#o;b++)p[b]=b;return p}let m=0;for(let b=0;b<this.#o;b++)this.#l.get(b)===0&&(p[m++]=b);return p}convert(p,m){const b=this.#t.get(p);return b?b.convert(m):!1}destroy(){if(!this.#m){this.#m=!0;for(const p of this.#n)p.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#l.release(),this.#o=0,this.#a=0,this.#s=0,this.#i=0}}#p(p){if(p<=this.#i)return;let m=this.#i||this.#h;for(;m<p;)m*=2;for(const b of this.#n)b.grow(m);this.#l.grow(m),this.#i=m}#g(p){const m={};for(const b of this.#n)m[b.id]=b.get(p);return m}#v(){if(this.#u)return;let p=this.#h;for(;p<this.#o;)p*=2;this.#u=!0,this.#i=p,this.#l.grow(p);for(const m of this.#n)m.columnarise(p,this.#o)}}}),ve("packages/core/src/store/pool.js",function(e,V){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const Z=64,N=8;function z(U){let B=Z;for(;B<U;)B*=2;return B}class F{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(B={}){this.#n=B.limit??N}get bytes(){return this.#r}mask(B){const H=new Uint8Array(this.#i(B),0,B);return H.fill(0),H}indices(B){return new Uint32Array(this.#i(B*4),0,B)}release(B){if(!B||!B.buffer)return!1;const H=B.buffer;if(!this.#t.has(H))return!1;this.#t.delete(H),this.#o.released++;const L=H.byteLength;let k=this.#e.get(L);return k||this.#e.set(L,k=[]),k.length>=this.#n||(k.push(H),this.#r+=L),!0}releaseAll(B){for(const H of B)this.release(H)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(B){const H=z(B),L=this.#e.get(H);this.#o.acquired++;let k;return L&&L.length?(k=L.pop(),this.#r-=H,this.#o.reused++):k=new ArrayBuffer(H),this.#t.add(k),k}}function W(){return _??=new F,_}let _=null}),ve("packages/core/src/compute/sortspec.js",function(e,V){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function Z(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function N(_){return!!_&&typeof _.compare!="function"}function z(_){if(!_)return!0;for(let U=0;U<_.length;U++)if(!N(_[U]))return!1;return!0}function F(_,U){const B=_.col!==void 0?_.col:_.handle&&_.handle.id,H=_.locale!==void 0?_.locale:U;return{col:B,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:Z(H)}}function W(_,U){const B=_||[],H=new Array(B.length);for(let L=0;L<B.length;L++)H[L]=F(B[L],U);return H}}),ve("packages/core/src/compute/filter.js",function(e,V){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return I}});const Z=V("packages/core/src/internal/util.js"),N=Z.isBlank,z=Z.toArray,F=Z.warnOnce,_=V("packages/core/src/format/date.js").toIsoDate,U=V("packages/core/src/compute/handle.js"),B=U.bitReader,H=U.dictSize,L=U.dictValue,k=U.presenceReader,S=U.valueComparator,y=U.valueReader,u=/^\d{4}-\d{2}-\d{2}$/,o="\0null\0";function r(D,j){const E=D&&D.pool;if(E){const $=E.mask||E.acquireMask||E.acquire||E.take;if(typeof $=="function"){const q=$.call(E,j);if(q&&q.length>=j)return q}}return new Uint8Array(j)}function t(D,j){const E=D&&D.pool;if(!E||!j)return;const $=E.release||E.releaseMask||E.free||E.recycle;typeof $=="function"&&$.call(E,j)}function n(D,j,E){return D.fill(E,0,j),D}function i(D){return D==null||typeof D=="number"&&Number.isNaN(D)}function s(D,j){if(D==null)return D;if(j==="number")return typeof D=="number"?D:Number(D);if(j==="date"||j==="dateString"){const E=_(D);return E===null?c(D):E}return j==="boolean"?typeof D=="boolean"?D:D==="true"||D===1?!0:D==="false"||D===0?!1:!!D:D}function c(D){return D instanceof Date?D.getTime():typeof D=="number"?D:Date.parse(String(D))}function d(D){return typeof D=="number"?D:D instanceof Date?D.getTime():D==null||D===""?NaN:Number(D)}function f(D,j){const E=typeof D=="string"?D:String(D);return j?E:E.toLowerCase()}function h(D,j){return D==null?o:typeof D=="string"?j?D:D.toLowerCase():D instanceof Date?D.getTime():D}function g(D,j,E){const $=new Set;for(const q of z(D)){const X=s(q,E);$.add(h(X,j)),typeof X=="string"&&X!==""&&Number.isFinite(Number(X))?$.add(Number(X)):typeof X=="number"&&Number.isFinite(X)&&$.add(h(String(X),j))}return $}function w(D,j,E){if(D==null||j===null||j===void 0)return D==null&&j==null;const $=typeof D,q=typeof j;return $==="string"&&q==="string"?E?D===j:D.toLowerCase()===j.toLowerCase():D instanceof Date||j instanceof Date?c(D)===c(j):$==="number"&&q==="number"?D===j||Number.isNaN(D)&&Number.isNaN(j):$==="number"&&q==="string"?D===Number(j):$==="string"&&q==="number"?Number(D)===j:$==="boolean"||q==="boolean"?D===j:Array.isArray(D)&&Array.isArray(j)?D.length===j.length&&D.every((X,Q)=>w(X,j[Q],E)):D===j}function p(D,j){try{if(D instanceof RegExp){const E=D.flags.replace(/[gy]/g,"");return new RegExp(D.source,j||E.includes("i")?E:`${E}i`)}return new RegExp(String(D),j?"":"i")}catch(E){return F(`regex:${String(D)}`,`filter operator "matches" received an invalid pattern: ${String(D)}`,E),null}}function m(D,j){const E=b(D,j),$=D&&D.type;return $!=="date"&&$!=="dateString"?E:q=>E(typeof q=="string"&&u.test(q)?q:_(q)??q)}function b(D,j){const E=D&&D.op,$=!!(D&&D.caseSensitive),q=D&&D.type,X=S(j),Q=J=>ne=>!J(ne);switch(E){case"eq":{const J=s(D.value,q);return ne=>w(ne,J,$)}case"ne":{const J=s(D.value,q);return ne=>!w(ne,J,$)}case"lt":case"lte":case"gt":case"gte":{const J=s(D.value,q);if(i(J))return()=>!1;const ne=E==="lt"?-1:E==="lte"?0:E==="gt"?1:2;return re=>{if(i(re))return!1;const oe=X(re,J);return ne===-1?oe<0:ne===0?oe<=0:ne===1?oe>0:oe>=0}}case"between":case"notBetween":{const J=z(D.value),ne=s(J[0],q),re=s(J[1],q),oe=D.bounds||"[]",ie=oe.charAt(0)!=="(",te=oe.charAt(1)!==")";if(i(ne)||i(re))return E==="between"?()=>!1:()=>!0;const ce=ue=>{if(i(ue))return!1;const ae=X(ue,ne),pe=X(ue,re);return(ie?ae>=0:ae>0)&&(te?pe<=0:pe<0)};return E==="between"?ce:Q(ce)}case"in":case"notIn":{const J=g(D.value,$,q),ne=re=>J.has(h(re,$));return E==="in"?ne:Q(ne)}case"contains":case"notContains":{const J=f(s(D.value,q),$),ne=re=>re==null?!1:f(re,$).includes(J);return E==="contains"?ne:Q(ne)}case"startsWith":{const J=f(s(D.value,q),$);return ne=>ne==null?!1:f(ne,$).startsWith(J)}case"endsWith":{const J=f(s(D.value,q),$);return ne=>ne==null?!1:f(ne,$).endsWith(J)}case"matches":{const J=p(D.value,$);return J?ne=>ne==null?!1:J.test(String(ne)):()=>!1}case"blank":return J=>N(J)||Array.isArray(J)&&J.length===0;case"notBlank":return J=>!(N(J)||Array.isArray(J)&&J.length===0);case"containsAny":case"containsNone":{const J=g(D.value,$,q),ne=re=>{const oe=re==null?[]:z(re);for(let ie=0;ie<oe.length;ie++)if(J.has(h(oe[ie],$)))return!0;return!1};return E==="containsAny"?ne:Q(ne)}case"containsAll":{const J=z(D.value).map(ne=>h(s(ne,q),$));return ne=>{const re=ne==null?[]:z(ne);if(J.length===0)return!0;const oe=new Set(re.map(ie=>h(ie,$)));for(let ie=0;ie<J.length;ie++)if(!oe.has(J[ie]))return!1;return!0}}default:return F(`op:${String(E)}`,`unknown filter operator "${String(E)}"; the condition passes every row`),()=>!0}}function v(D,j,E){return m(j,E)(D)}function l(D,j,E,$){const q=k(D);if(q){const J=j?1:0;for(let ne=0;ne<$;ne++)E[ne]=q(ne)===J?1:0;return E}const X=D.kind;if(X==="float64"||X==="int32"||X==="bitset")return n(E,$,j?1:0);const Q=y(D);for(let J=0;J<$;J++){const ne=Q(J),re=N(ne)||Array.isArray(ne)&&ne.length===0;E[J]=re===j?0:1}return E}function a(D,j,E,$){const q=D.dict,X=H(q),Q=new Uint8Array(X);for(let oe=0;oe<X;oe++)Q[oe]=j(L(q,oe))?1:0;const J=D.values,ne=k(D);if(!ne){for(let oe=0;oe<$;oe++)E[oe]=Q[J[oe]];return E}const re=j(null)?1:0;for(let oe=0;oe<$;oe++)E[oe]=ne(oe)===1?Q[J[oe]]:re;return E}function O(D,j,E,$){const q=B(D.values),X=j(!0)?1:0,Q=j(!1)?1:0,J=k(D);if(!J){for(let re=0;re<$;re++)E[re]=q(re)===1?X:Q;return E}const ne=j(null)?1:0;for(let re=0;re<$;re++)E[re]=J(re)===0?ne:q(re)===1?X:Q;return E}function T(D,j,E,$,q){const X=D.values,Q=j.type,J=j.op;let ne=!0;switch(J){case"eq":case"ne":{const oe=d(s(j.value,Q)),ie=typeof j.value=="number"&&Number.isNaN(j.value),te=J==="ne"?1:0;if(ie)for(let ce=0;ce<q;ce++)$[ce]=(Number.isNaN(X[ce])?1:0)^te;else for(let ce=0;ce<q;ce++)$[ce]=(X[ce]===oe?1:0)^te;break}case"lt":{const oe=d(s(j.value,Q));for(let ie=0;ie<q;ie++)$[ie]=X[ie]<oe?1:0;break}case"lte":{const oe=d(s(j.value,Q));for(let ie=0;ie<q;ie++)$[ie]=X[ie]<=oe?1:0;break}case"gt":{const oe=d(s(j.value,Q));for(let ie=0;ie<q;ie++)$[ie]=X[ie]>oe?1:0;break}case"gte":{const oe=d(s(j.value,Q));for(let ie=0;ie<q;ie++)$[ie]=X[ie]>=oe?1:0;break}case"between":case"notBetween":{const oe=z(j.value),ie=d(s(oe[0],Q)),te=d(s(oe[1],Q)),ce=j.bounds||"[]",ue=ce.charAt(0)!=="(",ae=ce.charAt(1)!==")",pe=J==="notBetween"?1:0;if(ue&&ae)for(let he=0;he<q;he++)$[he]=(X[he]>=ie&X[he]<=te?1:0)^pe;else if(ue)for(let he=0;he<q;he++)$[he]=(X[he]>=ie&X[he]<te?1:0)^pe;else if(ae)for(let he=0;he<q;he++)$[he]=(X[he]>ie&X[he]<=te?1:0)^pe;else for(let he=0;he<q;he++)$[he]=(X[he]>ie&X[he]<te?1:0)^pe;break}case"in":case"notIn":{const oe=new Set;for(const te of z(j.value)){const ce=d(s(te,Q));Number.isNaN(ce)||oe.add(ce)}const ie=J==="notIn"?1:0;for(let te=0;te<q;te++)$[te]=(oe.has(X[te])?1:0)^ie;break}default:ne=!1;break}if(!ne)return!1;const re=k(D);if(re){const oe=E(null)?1:0;for(let ie=0;ie<q;ie++)re(ie)===0&&($[ie]=oe)}return!0}function A(D,j,E,$){const q=y(D);for(let X=0;X<$;X++)E[X]=j(q(X))?1:0;return E}function M(D,j,E){const $=j.count|0,q=E||r(j,$);if(!D)return n(q,$,1);const X=typeof j.handle=="function"?j.handle(D.col):void 0,Q=typeof j.custom=="function"?j.custom:null;if(!X){if(Q){for(let re=0;re<$;re++)q[re]=Q(D,re)?1:0;return q}return F(`filter:col:${String(D.col)}`,`filter references unknown column "${String(D.col)}"; the condition passes every row`),n(q,$,1)}const J=D.op;if(J==="blank"||J==="notBlank")return l(X,J==="notBlank",q,$);const ne=m(D,j.locale);switch(X.kind){case"dictionary":return a(X,ne,q,$);case"bitset":return O(X,ne,q,$);case"float64":case"int32":return T(X,D,ne,q,$)?q:A(X,ne,q,$);default:return A(X,ne,q,$)}}function C(D,j,E){if(!D)return n(r(j,E),E,1);if(Array.isArray(D.conditions)){const $=D.conditions.filter(Q=>Q!=null),q=D.op==="or"?"or":D.op==="not"?"not":"and";if($.length===0)return n(r(j,E),E,1);const X=C($[0],j,E);for(let Q=1;Q<$.length;Q++){const J=C($[Q],j,E);if(q==="or")for(let ne=0;ne<E;ne++)X[ne]|=J[ne];else for(let ne=0;ne<E;ne++)X[ne]&=J[ne];t(j,J)}if(q==="not")for(let Q=0;Q<E;Q++)X[Q]^=1;return X}return M(D,j,r(j,E))}function P(D,j){return C(D,j,j.count|0)}function x(D,j){if(!D||!j)return D||null;const E=D;if(Array.isArray(E.conditions)){if((E.op==="or"?"or":E.op==="not"?"not":"and")!=="and")return K(E,j)?null:D;const q=[];for(const X of E.conditions){const Q=x(X,j);Q&&q.push(Q)}return q.length?{...E,op:"and",conditions:q}:null}return E.col===j?null:D}function K(D,j){if(!D||typeof D!="object")return!1;const E=D;if(E.col===j)return!0;if(Array.isArray(E.conditions)){for(const $ of E.conditions)if(K($,j))return!0}return!1}function I(D,j,E){if(E&&E.length>=j){let Q=0;for(let J=0;J<j;J++)D[J]&&(E[Q++]=J);return E.subarray(0,Q)}let $=0;for(let Q=0;Q<j;Q++)$+=D[Q]?1:0;const q=new Uint32Array($);let X=0;for(let Q=0;Q<j;Q++)D[Q]&&(q[X++]=Q);return q}}),ve("packages/core/src/compute/facet.js",function(e,V){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/core/src/compute/handle.js"),N=Z.presenceReader,z=Z.valueReader,F=Z.dictSize,W=Z.dictValue,_=Object.freeze(["equal","quantile","log"]),U=Object.freeze(["hour","day","week","month","quarter","year"]),B=20,H=50,L=1e4;function k(l,a){if(!l)return"none";const O=a&&a.base;if(O==="date"||O==="datetime"||O==="time"||O==="dateString")return"date";switch(l.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return O==="number"?"numeric":O==="boolean"?"boolean":O==="text"?"category":"none"}}function S(l){const a=l.values,O=l.kind;if((O==="float64"||O==="int32")&&a)return A=>a[A];const T=z(l);return A=>y(T(A))}function y(l){if(typeof l=="number")return l;if(l instanceof Date)return l.getTime();if(l==null||l==="")return NaN;if(typeof l=="boolean")return l?1:0;if(typeof l=="string"){const a=Number(l);if(Number.isFinite(a))return a;const O=Date.parse(l);return Number.isFinite(O)?O:NaN}return NaN}function u(l,a,O,T=H){if(!l)return{cardinality:0,exact:!0};if(l.dict)return{cardinality:F(l.dict),exact:!0};if(l.kind==="bitset")return{cardinality:2,exact:!0};const A=z(l),M=a?a.length:O,C=new Set;for(let P=0;P<M;P++){const x=A(a?a[P]:P);if(x!=null&&(C.add(x),C.size>T))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const o=36e5,r=864e5;function t(l,a=B){const O=Number.isFinite(l)&&l>0?l:0,T=Math.max(1,a)*2;return O/o<=T?"hour":O/r<=T?"day":O/(7*r)<=T?"week":O/(30*r)<=T?"month":O/(91*r)<=T?"quarter":"year"}function n(l,a){if(!Number.isFinite(l))return NaN;const O=new Date(l);switch(a){case"hour":return O.setMinutes(0,0,0),O.getTime();case"day":return O.setHours(0,0,0,0),O.getTime();case"week":{O.setHours(0,0,0,0);const T=(O.getDay()+6)%7;return O.setDate(O.getDate()-T),O.getTime()}case"month":return O.setDate(1),O.setHours(0,0,0,0),O.getTime();case"quarter":return O.setMonth(Math.floor(O.getMonth()/3)*3,1),O.setHours(0,0,0,0),O.getTime();default:return O.setMonth(0,1),O.setHours(0,0,0,0),O.getTime()}}function i(l,a){const O=new Date(l);switch(a){case"hour":O.setHours(O.getHours()+1);break;case"day":O.setDate(O.getDate()+1);break;case"week":O.setDate(O.getDate()+7);break;case"month":O.setMonth(O.getMonth()+1);break;case"quarter":O.setMonth(O.getMonth()+3);break;default:O.setFullYear(O.getFullYear()+1);break}return O.getTime()}function s(l,a,O){const T=S(l),A=N(l),M=a?a.length:O;let C=1/0,P=-1/0,x=0,K=0;for(let I=0;I<M;I++){const D=a?a[I]:I;if(A&&!A(D)){x++;continue}const j=T(D);if(!Number.isFinite(j)){x++;continue}j<C&&(C=j),j>P&&(P=j),K++}return{min:C,max:P,nulls:x,finite:K}}function c(l,a,O,T){const A=S(l),M=N(l),C=a?a.length:O,P=C>T?C/T:1,x=[];for(let I=0;I<C;I+=P){const D=a?a[Math.floor(I)]:Math.floor(I);if(M&&!M(D))continue;const j=A(D);Number.isFinite(j)&&x.push(j)}const K=Float64Array.from(x);return K.sort(),K}function d(l,a,O,T={}){const A=T.kind||k(l,T.type);return A==="none"||!l?{kind:"none",buckets:[],suppressed:"type"}:A==="boolean"?f(l,a,O):A==="category"?h(l,a,O,T):g(l,a,O,A,T)}function f(l,a,O){const T=N(l);let A=0;if(T){const C=a?a.length:O;for(let P=0;P<C;P++)T(a?a[P]:P)||A++}const M=[{value:!1,label:"false"},{value:!0,label:"true"}];return A>0&&M.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:M}}function h(l,a,O,T){const A=T.cardinalityLimit??H,{cardinality:M}=u(l,a,O,A);if(M>A&&(T.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:M};const C=z(l),P=a?a.length:O,x=new Map;let K=0;for(let $=0;$<P;$++){const q=C(a?a[$]:$);if(q==null||q===""){K++;continue}if(Array.isArray(q)){if(!q.length){K++;continue}for(const X of q)x.set(X,(x.get(X)||0)+1);continue}x.set(q,(x.get(q)||0)+1)}let I=[...x.entries()];T.order==="alpha"?I.sort(($,q)=>String($[0]).localeCompare(String(q[0]))):I.sort(($,q)=>q[1]-$[1]);let D=0,j=0;if(I.length>A){j=I.length-A;for(let $=A;$<I.length;$++)D+=I[$][1];I=I.slice(0,A)}const E=I.map(([$])=>({value:$,label:String($)}));return D>0&&E.push({remainder:!0,label:`Other (${j} values)`}),K>0&&E.push({null:!0,label:"Empty"}),{kind:"category",buckets:E,cardinality:M}}function g(l,a,O,T,A){const{min:M,max:C,nulls:P,finite:x}=s(l,a,O);if(!x)return{kind:T,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const K=Math.max(1,Math.floor(A.buckets||B));let I=[];if(T==="date"){const j=U.includes(A.granularity)?A.granularity:t(C-M,K);let E=n(M,j);for(;E<=C&&I.length<4096;){const $=i(E,j);if(!($>E))break;I.push({from:E,to:$}),E=$}return{kind:T,buckets:w(I,P),granularity:j}}const D=_.includes(A.strategy)?A.strategy:"equal";if(D==="quantile"){const j=c(l,a,O,L);if(j.length){const E=[j[0]];for(let $=1;$<K;$++){const q=j[Math.min(j.length-1,Math.floor($/K*j.length))];q>E[E.length-1]&&E.push(q)}E.push(C);for(let $=0;$<E.length-1;$++)I.push({from:E[$],to:E[$+1]})}}else if(D==="log"&&M>0){const j=Math.log10(M),$=(Math.log10(C)-j)/K||1;for(let q=0;q<K;q++)I.push({from:10**(j+q*$),to:10**(j+(q+1)*$)})}if(!I.length){const j=(C-M)/K||1;for(let E=0;E<K;E++)I.push({from:M+E*j,to:M+(E+1)*j})}return I[I.length-1].to=C,{kind:T,buckets:w(I,P),strategy:D,min:M,max:C}}function w(l,a){return a>0?[...l,{null:!0,label:"Empty"}]:l}function p(l,a,O,T,A){const M=T&&T.buckets||[],C=A&&A.length>=M.length?A.subarray(0,M.length):new Uint32Array(M.length);if(C.fill(0),!l||!M.length)return C;const P=M.length-1,x=!!M[P]&&M[P].null===!0,K=a?a.length:O;if(T.kind==="boolean"){const $=z(l);for(let q=0;q<K;q++){const X=$(a?a[q]:q);if(X==null){x&&C[P]++;continue}C[X?1:0]++}return C}if(T.kind==="category"){const $=new Map;for(let Q=0;Q<M.length;Q++)!M[Q].null&&!M[Q].remainder&&$.set(M[Q].value,Q);const q=M.findIndex(Q=>Q.remainder),X=z(l);for(let Q=0;Q<K;Q++){const J=X(a?a[Q]:Q);if(J==null||J===""){x&&C[P]++;continue}if(Array.isArray(J)){if(!J.length){x&&C[P]++;continue}for(const re of J){const oe=$.get(re);oe!==void 0?C[oe]++:q>=0&&C[q]++}continue}const ne=$.get(J);ne!==void 0?C[ne]++:q>=0&&C[q]++}return C}const I=x?M.length-1:M.length,D=new Float64Array(I+1);for(let $=0;$<I;$++)D[$]=M[$].from;D[I]=I?M[I-1].to:0;const j=S(l),E=N(l);for(let $=0;$<K;$++){const q=a?a[$]:$;if(E&&!E(q)){x&&C[P]++;continue}const X=j(q);if(!Number.isFinite(X)){x&&C[P]++;continue}const Q=m(D,I,X);Q>=0&&C[Q]++}return C}function m(l,a,O){if(!a||O<l[0])return-1;if(O>=l[a])return O===l[a]?a-1:-1;let T=0,A=a-1;for(;T<A;){const M=T+A+1>>>1;O>=l[M]?T=M:A=M-1}return T}function b(l,a,O,T={}){const A=T.bounds||d(l,T.boundsIndices??a,O,T);return{bounds:A,counts:p(l,a,O,A)}}const v=b}),ve("packages/core/src/compute/pivotmatrix.js",function(e,V){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return n}});const N=V("packages/core/src/compute/handle.js").valueComparator,F=V("packages/core/src/compute/total.js").total,_=V("packages/core/src/compute/group.js").packKeys,U=V("packages/core/src/compute/pivot.js"),B=U.joinPath,H=U.DEFAULT_PATH_SEPARATOR,L=U.DEFAULT_MAX_COLUMNS,k="";function S(i,s,c={}){const d=c.separator||H,f=i||[],h=s instanceof Uint32Array?s:Uint32Array.from(s||[]),g=h.length;if(f.length===0)return{tuples:[[]],paths:[k],buckets:[h]};const{keyOf:w,readers:p}=_(f,h,0),m=new Map,b=[],v=[],l=[];for(let C=0;C<g;C++){const P=h[C],x=w(P);let K=m.get(x);if(K===void 0){K=b.length,m.set(x,K),v.push(x);const I=new Array(p.length);for(let D=0;D<p.length;D++)I[D]=p[D](P);b.push(I),l.push([])}l[K].push(P)}const a=N(c.locale),O=b.map((C,P)=>P);O.sort((C,P)=>{const x=b[C],K=b[P];for(let I=0;I<x.length;I++){const D=y(x[I],K[I],a);if(D!==0)return D}return C-P});const T=new Array(O.length),A=new Array(O.length),M=new Array(O.length);for(let C=0;C<O.length;C++){const P=O[C];T[C]=b[P],A[C]=B(b[P],d),M[C]=Uint32Array.from(l[P])}return{tuples:T,paths:A,buckets:M}}function y(i,s,c){const d=i==null,f=s==null;return d||f?d&&f?0:d?1:-1:c(i,s)}function u(i,s,c){const d=[];for(let f=0;f<i.length;f++)c.has(i[f])&&d.push(i[f]);return Uint32Array.from(d)}function o(i,s,c,d){return{value:s.length?F(i,s,c,d):null,leaves:s,count:s.length}}function r(i){const s=i&&i.opts||{},c=s.separator||H,d=s.totalContext||{locale:s.locale},f=(i.measures||[]).filter(A=>A&&A.handle),h=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),g=S(i.rowHandles||[],h,{...s,separator:c}),w=S(i.columnHandles||[],h,{...s,separator:c}),p=s.maxColumns===void 0?L:s.maxColumns,m=w.paths.length*Math.max(1,f.length),b=new Map;if(p&&m>p)return{rowAxis:g,columnAxis:w,measures:f.map(A=>({colId:A.colId,fn:A.fn})),body:b,rowMargin:b,columnMargin:b,grand:b,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:p}};const v=new Map,l=new Map,a=new Map,O=new Map,T=w.buckets.map(A=>new Set(A));for(let A=0;A<w.paths.length;A++){const M=w.buckets[A],C=w.paths[A];for(const P of f)a.set(n(C,P.colId),o(P.handle,M,P.fn,d))}for(let A=0;A<g.paths.length;A++){const M=g.buckets[A],C=g.paths[A];for(const P of f)l.set(n(C,P.colId),o(P.handle,M,P.fn,d));for(let P=0;P<w.paths.length;P++){const x=u(M,w.buckets[P],T[P]);if(x.length===0)continue;const K=w.paths[P];for(const I of f)v.set(t(C,K,I.colId),o(I.handle,x,I.fn,d))}}for(const A of f)O.set(A.colId,o(A.handle,h,A.fn,d));return{rowAxis:g,columnAxis:w,measures:f.map(A=>({colId:A.colId,fn:A.fn})),body:v,rowMargin:l,columnMargin:a,grand:O,columns:m,error:null}}function t(i,s,c){return`${i}\0${s}\0${c}`}function n(i,s){return`${i}\0${s}`}}),ve("packages/core/src/compute/reference.js",function(e,V){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return r}});const N=V("packages/core/src/internal/util.js").getPath,z=V("packages/core/src/compute/handle.js"),F=z.isMissing,W=z.valueComparator,U=V("packages/core/src/compute/filter.js").testValue,B="",H="\0";function L(i,s){const c=s.includes(".")?N(i,s):i?.[s];return c===void 0?null:c}function k(i,s,c={}){const d=s||[];let f=i.map((h,g)=>g);if(d.length===0)return f;for(let h=d.length-1;h>=0;h--)f=S(i,f,d[h],c);return f}function S(i,s,c,d){const f=c.locale!==void 0?c.locale:d.locale,h=W(f),g=c.descending!==void 0?!!c.descending:c.dir==="desc",w=[],p=[];for(const v of s){const l=L(i[v],c.col);F(l)?p.push(v):w.push(v)}const m=new Map;for(let v=0;v<w.length;v++)m.set(w[v],v);const b=(v,l)=>{const a=L(i[v],c.col),O=L(i[l],c.col);let T;return typeof c.compare=="function"?(T=c.compare(a,O,i[v],i[l],g),g&&(T=-T)):T=g?h(O,a):h(a,O),T!==0?T:m.get(v)-m.get(l)};return w.sort(b),c.nullsFirst?p.concat(w):w.concat(p)}function y(i,s,c={}){const d=[];for(let f=0;f<i.length;f++)u(i[f],s,c,f)&&d.push(f);return d}function u(i,s,c,d){if(!s)return!0;if(Array.isArray(s.conditions)){const f=s.conditions.filter(g=>g!=null);if(f.length===0)return!0;if(s.op==="or")return f.some(g=>u(i,g,c,d));const h=f.every(g=>u(i,g,c,d));return s.op==="not"?!h:h}return s.col===void 0&&typeof c.custom=="function"?!!c.custom(s,i,d):U(L(i,s.col),s,c.locale)}function o(i,s,c,d){const f=c||i.map((p,m)=>m),h=new Map,g=[],w=[];for(const p of f){const m=s.map((l,a)=>{const O=L(i[p],l);return d&&d[a]?d[a](O):O}),b=m.map(l=>l==null?H:String(l)).join(B);let v=h.get(b);v===void 0&&(v=g.length,h.set(b,v),g.push(m),w.push([])),w[v].push(p)}return{keys:g,buckets:w}}function r(i,s,c={}){const d=W(c.locale),f=i.filter(g=>!F(g)),h=f.map(t).filter(g=>g!==null);switch(s){case"count":return i.length;case"countValues":return f.length;case"sum":return h.reduce((g,w)=>g+w,0);case"avg":return f.length===0?null:h.reduce((g,w)=>g+w,0)/f.length;case"min":return f.length===0?null:f.reduce((g,w)=>d(w,g)<0?w:g);case"max":return f.length===0?null:f.reduce((g,w)=>d(w,g)>0?w:g);case"first":return i.length===0?null:n(i[0]);case"last":return i.length===0?null:n(i[i.length-1]);default:return null}}function t(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 s=Number(i);return Number.isNaN(s)?null:s}function n(i){return i===void 0?null:i}}),ve("packages/core/src/compute/index.js",function(e,V){"use strict";const Z=V("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Z.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Z.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Z.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Z.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Z.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Z.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Z.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Z.rankSortStrings}});const N=V("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return N.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return N.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return N.describeSort}});const z=V("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return z.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return z.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return z.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return z.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return z.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return z.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return z.mentionsColumn}});const F=V("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return F.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F.packKeys}});const W=V("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return W.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return W.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return W.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return W.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return W.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return W.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return W.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return W.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return W.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return W.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return W.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return W.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return W.QUANTILE_SAMPLE}});const _=V("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const U=V("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return U.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return U.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return U.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return U.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return U.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return U.DEFAULT_MAX_COLUMNS}});const B=V("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return B.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return B.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return B.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return B.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return B.GRAND_PATH}});const H=V("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return H.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return H.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return H.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return H.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return H.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return H.referenceValue}});const L=V("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return L.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return L.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return L.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return L.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return L.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return L.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return L.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return L.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return L.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return L.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return L.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return L.isMissing}});const k=V("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return k.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return k.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return k.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return k.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return k.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return k.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k.SKETCH_BOUNDS}});const S=V("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return S.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return S.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return S.openWindow}});const y=V("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const u=V("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const o=V("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return o.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return o.forecast}})}),ve("packages/core/src/source/rows.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return u}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isFunction,F=32,W="\0";function _(o){return new U(o)}class U{#e;#t;constructor(r){this.#e=z(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||z(t)?t:F}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const n=this.#e(r);if(n!=null)return String(n)}else N("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return z(this.#t)?Number(this.#t(r))||F:this.#t}leaf(r,t,n=0,i=null){const s={key:this.keyOf(r,t),data:r,level:n,parent:i,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return s.height=this.heightOf(s),s}group(r){const t={key:y(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${W}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${W}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const n={key:`${W}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return n.height=this.heightOf(n),n}skeleton(r,t=0){const n={key:`${W}pending${W}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null};return n.height=this.heightOf(n),n}}function B(o,r,t,n){return{key:`${W}pinned${W}${t}${W}${r}`,data:o,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function H(o,r){return new Proxy([],{get(t,n,i){if(n==="length")return o();if(typeof n=="string"){const s=Number(n);if(Number.isInteger(s)&&s>=0)return r(s)}return Reflect.get(t,n,i)},has(t,n){if(typeof n=="string"){const i=Number(n);if(Number.isInteger(i)&&i>=0)return i<o()}return Reflect.has(t,n)}})}function L(o){return o==null?"":String(o)}const k="";function S(o){if(o==null)return k;const r=String(o);return r.startsWith(k)?k+r:r}function y(o){const r=o||[];let t="g";for(let n=0;n<r.length;n++)t+=W+S(r[n]);return t}function u(o){const r=new Array(o.length),t=[];for(let n=0;n<o.length;n++)t.push(o[n]),r[n]=y(t);return r}}),ve("packages/core/src/source/handles.js",function(e,V){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce;class F{#e;#t;#n;#r=new Map;#o=0;constructor(U,B,H){this.#e=U,this.#t=B,this.#n=N(H)?H:()=>!1}get store(){const U=this.#e.store;return U&&N(U.column)?U:null}invalidate(){this.#o++}handle(U){const B=this.store;if(B){const S=B.column(U);if(S)return S}const H=this.#r.get(U);if(H&&H.builtAt===this.#o)return H.handle;const L=this.#i(U);if(!L)return;if(B&&this.#n()){z(`source.dropped.${U}`,`column "${U}" 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 k=this.#a(L);return this.#r.set(U,{handle:k,builtAt:this.#o}),k}#i(U){const B=this.#e.columns;return B&&N(B.get)?B.get(U):void 0}#a(U){const B=this.#t()||[],H=B.length,L=new Array(H),k=N(U.getValue)?y=>U.getValue(y):y=>y?.[U.field||U.id];for(let y=0;y<H;y++)L[y]=B[y]===void 0?void 0:k(B[y]);const S=this.#o;return{id:U.id,kind:"object",nullable:!1,values:L,presence:null,dict:null,offsets:null,get(y){return L[y]},version:S}}}function W(_,U,B){return new F(_,U,B)}}),ve("packages/core/src/compute/incremental.js",function(e,V){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/store/columnstore.js").toFloat,z=Object.freeze(["sum","avg","countValues","min","max"]),F=Object.freeze(["float64"]),W=1e15;function _(L,k){return typeof L!="string"||!z.includes(L)?!1:!!k&&F.includes(k.kind)}function U(L){if(L==null)return null;const k=N(L);return Number.isNaN(k)?null:k}class B{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#a=!1;#s=!1;constructor(k){this.#e=k}get valid(){return this.#a&&!this.#s}get fn(){return this.#e}seed(k){this.#l();for(let S=0;S<k.length;S++){const y=U(k[S]);y!==null&&this.#u(y)}this.#a=!0}seedColumn(k,S,y){this.#l();for(let u=0;u<y.length;u++){const o=y[u];if(S&&S(o)===0)continue;const r=k[o];Number.isNaN(r)||this.#u(r)}this.#a=!0}#l(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#s=!1}#u(k){if(!Number.isFinite(k)){this.#s=!0;return}const S=this.#t+k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S+k:k-S+this.#t,this.#t=S,this.#r++,k<this.#o&&(this.#o=k),k>this.#i&&(this.#i=k)}#c(k){const S=this.#t-k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S-k:-k-S+this.#t,this.#t=S,this.#r--}update(k,S){if(!this.#a)return!1;const y=U(k),u=U(S);return y===null&&u===null?!0:y!==null&&!Number.isFinite(y)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?y===null||u===null?!1:this.#e==="min"?u<this.#o?(this.#o=u,!0):y>this.#o:u>this.#i?(this.#i=u,!0):y<this.#i:Math.abs(this.#t)>W?!1:(y!==null&&this.#c(y),u!==null&&this.#u(u),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const H=B}),ve("packages/core/src/source/filterwire.js",function(e,V){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return a}});const N=V("packages/core/src/internal/util.js").warnOnce,z="source.remote.hostFilter",F="source.where.pageRelative";function W(A,M){!Array.isArray(A)||!A.length||N(F,`filters.where (${A.join(", ")}) runs over the rows the ${M} 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 _(A){const M=(A||{}).config;!M||!M.hostFilter||N(z,"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 U="source.where.notApplied";function B(A,M){N(`${U}:${A}`,`filters.where("${A}") is registered but the ${M} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const H="source.where.overThreshold";function L(A,M,C,P){!Array.isArray(A)||!A.length||N(`${H}:${M}`,`filters.where (${A.join(", ")}) is not applied to the ${M} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${P.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 k=new Map;function S(A){let M=k.get(A);return M||(M=new Intl.DateTimeFormat("en-US",{timeZone:A,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),k.set(A,M)),M}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(A,M){const C=S(M).formatToParts(new Date(A)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const x of C)x.type==="year"?P.y=+x.value:x.type==="month"?P.m=+x.value:x.type==="day"?P.d=+x.value:x.type==="hour"?P.h=+x.value%24:x.type==="minute"?P.mi=+x.value:x.type==="second"&&(P.s=+x.value);return P}function o(A,M){const C=u(A,M);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(A/1e3)*1e3}function r(A,M,C,P){const x=Date.UTC(A,M-1,C),K=x-o(x,P);return x-o(K,P)}function t(A,M,C){const P=new Date(Date.UTC(A.y,A.m-1,A.d+M));return r(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),C)}const n=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(A,M){if(typeof A!="string")return null;const C=A.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(C);if(P){const x=P[1]==="n"?"":P[1],K=Number(x||M);return!Number.isFinite(K)||K<=0?null:{kind:"lastNDays",n:Math.floor(K)}}switch(C){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 s(A,M={}){const C=i(A,M.n);if(!C)return null;const P=M.tz||y(),x=M.now instanceof Date?M.now.getTime():typeof M.now=="number"?M.now:Date.now(),K=u(x,P),I=r(K.y,K.m,K.d,P),D=t(K,1,P);let j=I,E=D;switch(C.kind){case"today":break;case"yesterday":j=t(K,-1,P),E=I;break;case"lastNDays":E=M.includeToday?D:I,j=t(K,M.includeToday?-(C.n-1):-C.n,P);break;case"thisWeek":{const $=Number.isFinite(M.weekStartsOn)?Number(M.weekStartsOn):1,X=(new Date(Date.UTC(K.y,K.m-1,K.d)).getUTCDay()-$+7)%7;j=t(K,-X,P),E=t(K,-X+7,P);break}case"thisMonth":j=r(K.y,K.m,1,P),E=r(K.m===12?K.y+1:K.y,K.m===12?1:K.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const $=Math.floor((K.m-1)/3)*3+1;j=r(K.y,$,1,P),E=C.kind==="quarterToDate"?D:$===10?r(K.y+1,1,1,P):r(K.y,$+3,1,P);break}case"thisYear":case"yearToDate":j=r(K.y,1,1,P),E=C.kind==="yearToDate"?D:r(K.y+1,1,1,P);break;default:return null}return{from:new Date(j).toISOString(),to:new Date(E).toISOString(),bounds:"[)",tz:P,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function c(A){if(!A||typeof A!="object")return null;const M=A.value;if(M&&typeof M=="object"&&!Array.isArray(M)&&"relative"in M)return{token:String(M.relative),n:typeof M.n=="number"?M.n:void 0};if(A.op==="relative"&&typeof A.value=="string")return{token:A.value,n:void 0};const C=A.meta;return C&&typeof C.relative=="string"&&A.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function d(){return`Known tokens: ${n.filter(M=>M!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function f(A){const M=c(A);return M?i(M.token,M.n)!==null:!1}function h(A,M={}){const C=c(A);if(!C)return A;const P=s(C.token,{...M,n:C.n});return P?{...A,type:A.type||"date",op:"between",value:[P.from,P.to],bounds:A.bounds||P.bounds,meta:{...A.meta||{},relative:P.relative,tz:P.tz}}:(N(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,d()),A)}function g(A){return!!A&&typeof A=="object"&&Array.isArray(A.conditions)}function w(A,M){if(A){if(g(A)){for(const C of A.conditions)w(C,M);return}M(A)}}function p(A,M){if(!A)return null;if(!g(A))return M(A);const C=A;let P=!1;const x=[];for(const K of C.conditions){const I=p(K,M);I!==K&&(P=!0),I&&x.push(I)}return!P&&x.length===C.conditions.length?A:x.length?{...C,conditions:x}:null}function m(A){if(!A)return null;if(!g(A))return A;const M=A,C=[];for(const P of M.conditions){const x=m(P);x&&C.push(x)}return C.length?{op:M.op,conditions:C}:null}function b(A){const M=m(A);return M?g(M)&&M.op==="and"?M:{op:"and",conditions:[M]}:null}function v(A){const M=(A||[]).filter(Boolean);return M.length?{op:"and",conditions:M}:null}function l(A,M={}){const C=p(A,P=>h(P,M));return b(C)}function a(A){const M=O(A.filters??null);return JSON.stringify([M,A.sort??null,A.quick??"",A.groupBy??null,A.pivotBy??null,T(A.context)])}function O(A){if(!A)return null;if(g(A)){const P=A;return{op:P.op,conditions:P.conditions.map(O)}}const M=A,C=M.meta&&typeof M.meta.relative=="string"?M.meta.relative:c(M)?.token;return{col:M.col,op:M.op,bounds:M.bounds??null,caseSensitive:M.caseSensitive??!1,value:C?`rel:${C}`:M.value??null}}function T(A){if(A==null)return null;try{return JSON.parse(JSON.stringify(A))}catch{return N("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),ve("packages/core/src/source/tree.js",function(e,V){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F="",W="\0tree:";function _(u,o){return{physical:u,key:o,level:0,children:[],value:void 0}}function U(u,o){const r=[],t=new Map;for(let n=0;n<u.length;n++){const i=u[n],s=o.pathOf(i),c=Array.isArray(s)?s.map(f=>String(f)):[];if(!c.length){const f=_(i,o.keyOf(i));r.push(f);continue}let d=null;for(let f=0;f<c.length;f++){const h=c.slice(0,f+1).join(F),g=f===c.length-1;let w=t.get(h);w&&g&&w.physical===-1&&(w.physical=i,w.key=o.keyOf(i)),w||(w=_(g?i:-1,g?o.keyOf(i):W+h),w.level=f,w.value=c[f],t.set(h,w),d?d.children.push(w):r.push(w)),d=w}}return{roots:r,nodes:t}}function B(u,o){const r=new Map,t=[];for(let c=0;c<u.length;c++){const d=u[c],f=o.keyOf(d),h=_(d,f);r.set(f,h);const g=o.parentOf(d);g!=null&&g!==""&&t.push({node:h,parent:String(g)})}let n=null;const i=new Map;for(const{node:c,parent:d}of t){const f=r.get(d);if(f){i.set(c.key,f);continue}o.orphans&&o.orphans!=="root"&&(n||(n=_(-1,`${W}orphans`),n.value=o.orphans),i.set(c.key,n))}const s=[];for(const c of r.values()){const d=i.get(c.key);d?d.children.push(c):s.push(c)}return n&&n.children.length&&s.push(n),{roots:H(s,r,o.orphans,n),nodes:r}}function H(u,o,r,t){const n=new Set,i=[...u];for(;i.length;){const h=i.pop();if(!n.has(h.key)){n.add(h.key);for(const g of h.children)i.push(g)}}const s=[];for(const h of o.values())n.has(h.key)||s.push(h);if(!s.length)return u;const c=!!r&&r!=="root";z("tree.cycle",`tree.parentKey produced ${s.length} row(s) inside a parent cycle; `+(c?`they are shown under "${r}".`:"they are shown at the root."));for(const h of s)h.children=h.children.filter(g=>n.has(g.key));if(!c)return[...u,...s];let d=t;const f=[...u];return d||(d=_(-1,`${W}orphans`),d.value=r,f.push(d)),d.children.push(...s),f}function L(u){let o=0;const r=(t,n)=>{for(const i of t)i.level=n,n>o&&(o=n),i.children.length&&r(i.children,n+1)};return r(u,0),o}function k(u,o){if(!u||typeof u!="object")return null;const r=u.path,t=u.parentKey,n=N(u.hasChildren)?i=>!!u.hasChildren(o.dataAt(i)):null;if(N(r))return{mode:"path",pathOf:i=>r(o.dataAt(i)),keyOf:o.keyOf,declaresChildren:n};if(t!=null){const i=N(t)?t:s=>s?.[t];return{mode:"parentKey",parentOf:s=>i(o.dataAt(s)),keyOf:o.keyOf,orphans:u.orphans||"root",declaresChildren:n}}return z("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function S(u,o){const r=o.mode==="path"?U(u,o):B(u,o),t=L(r.roots);return{...r,depth:t}}function y(u,o){const r=new Map,t=n=>{for(let i=0;i<n.length;i++){const s=n[i];if(s.physical>=0){const c=o?o(s.physical):!1,d=c&&s.children.length===0;r.set(s.physical,{level:s.level,posinset:i+1,setsize:n.length,hasChildren:s.children.length>0||c,lazy:d})}s.children.length&&t(s.children)}};return t(u),r}}),ve("packages/core/src/source/memory.js",function(e,V){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return I}});const Z=V("packages/core/src/internal/util.js"),N=Z.Lru,z=Z.warnOnce,F=Z.fail,W=Z.isFunction,_=Z.defaultCompare,U=Z.mergeRow,B=V("packages/core/src/source/rows.js"),H=B.createRowFactory,L=B.groupKey,k=B.groupPathElement,S=B.groupPrefixKeys,y=B.lazyRowView,o=V("packages/core/src/source/handles.js").createHandleProvider,r=V("packages/core/src/compute/incremental.js"),t=r.RunningTotal,n=r.isIncremental,s=V("packages/core/src/compute/handle.js").presenceReader,c=V("packages/core/src/source/filterwire.js"),d=c.querySignature,f=c.mapConditions,h=c.resolveRelativeCondition,g=V("packages/core/src/source/tree.js"),w=g.buildTree,p=g.resolveTree,m=g.indexTree,b=Object.freeze(["filter","sort","group","total","pivot","flatten"]),v=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function l(D){const j=D&&typeof D=="object"?D.reason:null;return typeof j=="string"&&v.includes(j)}const a=Object.freeze([]);function O(D,j){if(!D)return null;const E=j==="grand"?D.grandTotal:D.groupTotal;return E??D.total}function T(D){return!!D&&!D.running}function A(D){if(D)return D.value&&W(D.value.compare)?D.value.compare:W(D.compare)?D.compare:void 0}function M(D){return!!D&&(typeof D=="object"||typeof D=="function")&&W(D.then)}const C=new Uint32Array(0),P=4096;function x(D,j){return new I(D,j)}function K(D,j){if(j==="regex")try{const E=new RegExp(D,"iu");return $=>E.test($)}catch{return E=>E.includes(D)}if(j==="fuzzy"){const E=[...D].filter($=>$!==" ");return E.length?$=>{let q=0;for(let X=0;X<$.length&&q<E.length;X++)$[X]===E[q]&&q++;return q===E.length}:()=>!0}if(j==="words"){const E=D.split(/\s+/).filter(Boolean);return E.length?$=>E.every(q=>$.includes(q)):()=>!0}return E=>E.includes(D)}class I{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#a;#s=new Map;#l=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=I.#g();static#g(){return{slots:[],groupHeadings:a,unnumbered:a,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#v=new Map;#b=null;#y=new Map;#w=-1;#S=[];#j=new Map;#A=-1;#O=[];#C=null;#E=null;#T=null;#x=null;#R=null;#N=null;#M=null;#_=null;#U=Symbol("unset");#L=new Map;#Y=null;get#D(){return this.#p.slots}set#D(j){this.#p.slots=j}get#Z(){return this.#p.inlineLeaves}set#Z(j){this.#p.inlineLeaves=j}get#te(){return this.#p.groupHeadings}set#te(j){this.#p.groupHeadings=j}get#le(){return this.#p.unnumbered}set#le(j){this.#p.unnumbered=j}get#se(){return this.#p.pivot}set#se(j){this.#p.pivot=j}constructor(j,E){this.#t=j||{mode:"memory"},this.#e=E||{};const $=this.#e.config||{};this.#n=this.#t.rows||$.rows||[],this.#i=H(this.#e),this.#a=o(this.#e,()=>this.#n,()=>this.#r),this.#f=new N(Number($.rowCacheSize)||P);for(const q of b)this.#s.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#W();const j=this.#ne();return j?j.length:this.#D.length}#ne(){const j=Number(this.#B("pageSize",0))||0;if(j<=0)return null;const E=this.#D.length,$=Math.max(1,Math.ceil(E/j)),X=Math.min(Math.max(0,Number(this.#B("page",0))||0),$-1)*j;return{offset:X,length:Math.max(0,Math.min(j,E-X))}}pageInfo(){this.#W();const j=Number(this.#B("pageSize",0))||0,E=this.#D.length;if(j<=0)return{page:0,pageSize:0,total:E,pageCount:1};const $=Math.max(1,Math.ceil(E/j));return{page:Math.min(Math.max(0,Number(this.#B("page",0))||0),$-1),pageSize:j,total:E,pageCount:$}}totalCount(){return this.#Ae().length}matchCount(){return this.#W(),this.#p.matchCount}at(j){this.#W();const E=this.#ne();if(E)return j<0||j>=E.length?void 0:this.#pt(E.offset+j,j);if(!(j<0||j>=this.#D.length))return this.#pt(j,j)}byKey(j){this.#W(),this.#m||this.#X();const E=this.#m.get(j);if(E!==void 0)return this.#Pe(E);for(let $=0;$<this.#D.length;$++){const q=this.#D[$];if(typeof q!="number"&&q&&q.key===j)return this.#pt($)}}loaded(j){return j>=0&&j<this.count()}hint(j,E){}display(){return this.#W(),this.#Y||(this.#Y=this.#Et()),this.#Y}invalidateQuickText(){this.#L.clear(),this.invalidate("filter")}invalidate(j){const E=b.indexOf(j);E<0&&F(`unknown pipeline stage "${j}"; expected one of ${b.join(", ")}`);for(let $=E;$<b.length;$++){const q=this.#s.get(b[$]);q.key=null,q.computed=!1}this.#Y=null}apply(j){const E=[],$={added:[],updated:[],removed:[],rejected:E};if(!j)return $;let q=!1;const X=new Set;if(j.remove&&j.remove.length)for(const Q of j.remove){const J=this.#we(Q);if(J===void 0){E.push({operation:"remove",id:this.#G(Q),reason:"unknown-id"});continue}$.removed.push(this.#i.keyOf(this.#r?this.#ze(J):this.#n[J],J)),this.#r||(this.#n[J]=void 0),this.#f.delete(J),this.#L.delete(J),q=!0}if(j.update&&j.update.length){const Q=this.#y.size||this.#nt()?this.#qe():null,J=this.#j.size?this.#bt():null,ne=J&&J.length?this.#qe():null;for(const re of j.update){const oe=this.#we(re);if(oe===void 0){E.push({operation:"update",id:this.#K(re),reason:"unknown-id"});continue}const ie=this.#r?this.#o&&this.#o.has(oe)?this.#o.get(oe):this.#ze(oe):this.#n[oe],te=U(ie,re);for(const ce of this.#Se(ie,te))X.add(ce);if(this.#r||(this.#n[oe]=te),Q&&this.#be(Q,oe,ie,te),ne&&this.#P(J,ne,oe,ie,te),this.#m){const ce=this.#i.keyOf(ie,oe),ue=this.#i.keyOf(te,oe);ce!==ue&&(this.#m.delete(ce),this.#m.set(ue,oe))}this.#f.delete(oe),this.#L.delete(oe),$.updated.push(this.#Pe(oe))}}if(j.add&&j.add.length&&this.#r){typeof j.at=="number"&&j.at<this.#mt()&&(this.#f.clear(),this.#L.clear()),this.#m=null;for(const Q of j.add){const J=this.#z(this.#K(Q));J!==void 0&&$.added.push(this.#Pe(J))}q=!0}else if(j.add&&j.add.length){const Q=typeof j.at=="number"?j.at:this.#n.length,J=this.#n.length;let ne=j.add===this.#n?j.add.slice():j.add;if(this.#i.keyed){const re=[];for(const oe of ne){const ie=this.#K(oe);if(this.#we(ie)!==void 0){E.push({operation:"add",id:ie,reason:"duplicate-id"});continue}re.push(oe)}re.length!==ne.length&&(ne=re)}if(!ne.length)return $;if(Q>=J)for(let re=0;re<ne.length;re++)this.#n.push(ne[re]);else this.#n.splice(Q,0,...ne),this.#f.clear(),this.#L.clear();for(let re=0;re<ne.length;re++)$.added.push(this.#Pe(Q>=J?J+re:Q+re));q=!0}return this.#u++,q&&(this.#m=null,this.#Be()),this.#a.invalidate(),this.#Y=null,q||this.#ve(X)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:$.added.length,updated:$.updated.length,removed:$.removed.length}),this.#o=null,$}groupHeadingsAt(j){this.#W();const E=this.#te;if(!E.length||!Number.isInteger(j)||j<0)return a;let $=0,q=E.length-1,X=-1;for(;$<=q;){const J=$+q>>1;E[J].at<=j?(X=J,$=J+1):q=J-1}if(X<0)return a;const Q=[];for(let J=E[X].row;J;J=J.parent)Q.push(J);return Q.reverse(),Q}unnumberedRowCount(j){this.#W();const E=this.#le;if(!E.length||!Number.isInteger(j)||j<0)return 0;let $=0,q=E.length-1,X=-1;for(;$<=q;){const Q=$+q>>1;E[Q].at<=j?(X=Q,$=Q+1):q=Q-1}return X+1}moveRow(j,E){if(this.#r)return z("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 $=this.#n;if(!Number.isInteger(j)||!Number.isInteger(E)||j<0||j>=$.length)return!1;const q=Math.max(0,Math.min($.length-1,E));if(q===j)return!1;const[X]=$.splice(j,1);return $.splice(q,0,X),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#L.clear(),this.#Be(),this.#a.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(j){this.#ge(),this.#u++,this.#c++,this.#m=null,this.#L.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#f.clear(),this.#L.clear(),this.#m=null,this.#D=[],this.#Z=null,this.#Y=null,this.#Be();for(const j of b)this.#s.set(j,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:j}of this.#v.values())try{j.abort()}catch{}this.#v.clear()}setRows(j){this.#n=j||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#L.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(j){this.#o=j||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#L.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const j=this.#e.store;if(!j||!W(j.source))return this.#n;const E=j.physical||0,$=new Array(E);for(let q=0;q<E;q++)$[q]=j.live&&!j.live(q)?void 0:j.source(q);return $}#V(){const j=this.#B("detail",null);return!j||!W(j.isOpen)||j.inline===!1?null:j}#ee(){const j=(this.#e.config||{}).tree;return this.#U!==j&&(this.#U=j,this.#_=p(j,{dataAt:E=>this.#ze(E),keyOf:E=>this.#i.keyOf(this.#ze(E),E)})),this.#_}#I(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#I())return null;this.#W();const j=this.#p.grand;return j?this.#i.grandTotal(j,this.#ke(this.#p.grandLeaves)):null}pivot(){return this.#W(),this.#se}pivotMatrix(){this.#W();const j=this.#p.groupLeaves,E=(this.#e.compute||{}).pivotMatrix;if(!W(E))return null;const $=this.#B("groupBy",[]),q=this.#B("pivotBy",[]);if(!$.length&&!q.length)return null;const X=this.#qe().map(J=>({colId:J.id,handle:this.#a.handle(J.id),fn:O(J,"group")})).filter(J=>J.handle&&J.fn),Q=this.#e.config||{};return E({rowHandles:$.map(J=>this.#a.handle(J)).filter(Boolean),columnHandles:q.map(J=>this.#a.handle(J)).filter(Boolean),measures:X,leaves:j||new Uint32Array(0),opts:{locale:Q.locale,separator:(Q.pivot||{}).separator,maxColumns:(Q.pivot||{}).maxColumns}})}keysForLeaves(j){const E=[];if(!j)return E;for(let $=0;$<j.length;$++){const q=this.#Pe(j[$]);q&&q.key!=null&&E.push(String(q.key))}return E}leavesOf(j){this.#W();const E=this.#s.get("group"),$=E&&E.result;if(!$||!$.nodes)return[];const q=$.nodes.get(j);if(!q)return[];const X=[],Q=J=>{const ne=J.row&&J.row.children;if(ne&&ne.length){for(const re of ne){const oe=$.nodes.get(re.key);oe&&Q(oe)}return}if(J.leaves)for(let re=0;re<J.leaves.length;re++)X.push(this.#Pe(J.leaves[re]))};return Q(q),X}#G(j){return typeof j=="string"?j:this.#K(j)}#K(j){try{return this.#i.keyOf(j,-1)}catch{return"(unkeyed)"}}#we(j){if(typeof j=="string")return this.#z(j);if(this.#i.keyed){const $=this.#i.keyOf(j,-1),q=this.#z($);if(q!==void 0)return q}if(this.#r)return;const E=this.#n.indexOf(j);return E>=0?E:void 0}#z(j){return this.#m||this.#X(),this.#m.get(j)}#X(){this.#m=new Map;const j=this.#mt(),E=this.#e.store,$=E&&W(E.live)?q=>E.live(q):null;for(let q=0;q<j;q++){if($&&!$(q))continue;const X=this.#ze(q);X!==void 0&&this.#m.set(this.#i.keyOf(X,q),q)}}#Se(j,E){const $=[];for(const q of this.#ye())this.#Ne(q)&&this.#Oe(q,j,E,new Set)&&$.push(q);return $}#Oe(j,E,$,q){if(q.has(j))return!1;q.add(j);const X=this.#Ne(j);if(!X)return!1;const Q=X.value&&X.value.deps;return Array.isArray(Q)&&Q.length?Q.some(J=>this.#Oe(String(J),E,$,q)):W(X.getValue)?!Object.is(X.getValue(E),X.getValue($)):!1}#ye(){const j=new Set;for(const $ of this.#B("sort",[]))j.add($.col);for(const $ of this.#B("groupBy",[]))j.add($);const E=$=>{if($){if(Array.isArray($.conditions)){$.conditions.forEach(E);return}$.col&&j.add($.col)}};return E(this.#B("filters",null)),[...j]}#ve(j){if(!j.size)return!1;if(this.#B("quick",""))return!0;for(const E of this.#ye())if(j.has(E))return!0;return!1}#W(){if(!this.#l){this.#l=!0;try{this.#Re()}finally{this.#l=!1}}}pipelineRunning(){return this.#l}#Re(){const j=this.#k("filter",()=>this.#Te(),()=>this.#me()),E=this.#re(j),$=this.#k("group",()=>this.#Fe(),()=>this.#q(E)),q=this.#k("total",()=>this.#Le(),()=>this.#Je($));this.#k("pivot",()=>this.#xe(),()=>this.#it($)),this.#k("flatten",()=>this.#Ve(),()=>this.#ot($)),this.#ae($,q)}#re(j){const E=this.#s.get("sort"),$=this.#je();if(E.computed&&E.key===$&&!this.#v.has("sort"))return E.result;const q=this.#v.get("sort");return q&&q.key===$?E.result:E.result&&this.#H(j)?(this.#$(j,$),E.result):this.#k("sort",()=>$,()=>this.#Ge(j))}#fe(){if(this.#b===null){const j=this.#e.pipelineWorker,E=W(j)?j():null;this.#b=E||!1}return this.#b||null}#ie(){const j=this.#B("sort",[]);if(!Array.isArray(j)||!j.length)return null;const E=(this.#e.config||{}).locale,$=[],q=[];for(const X of j){const Q=this.#Ne(X.col);if(Q&&Q.running)continue;if(Q&&Q.value&&W(Q.value.compare))return null;const J=this.#a.handle(X.col);if(!J)return null;$.push({col:X.col,descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,locale:E}),q.push(J)}return $.length?{entries:$,handles:q,locale:E}:null}#H(j){const E=this.#fe();if(!E)return!1;const $=Number(E.threshold);return Number.isFinite($)&&j.length<$?!1:!!this.#ie()}#$(j,E){const $=this.#fe(),q=$&&this.#ie();if(!q){this.#k("sort",()=>E,()=>this.#Ge(j));return}const X=new AbortController;this.#v.set("sort",{key:E,controller:X});const Q=q.entries.length===1?$.sortColumn(q.handles[0],j,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:X.signal,key:"sort"}):$.sortMulti(q.handles,q.entries.map((J,ne)=>({...J,handle:q.handles[ne]})),j,{signal:X.signal,key:"sort"});if(!M(Q)){this.#v.delete("sort"),this.#k("sort",()=>E,()=>Q);return}Q.then(J=>this.#oe(E,J),J=>this.#ue("sort",E,J))}#oe(j,E){const $=this.#v.get("sort");if(!(!$||$.key!==j)){if(this.#je()!==j){this.#v.delete("sort");return}this.#v.delete("sort"),this.#k("sort",()=>j,()=>E),this.#Y=null,this.#W(),this.#Qe("model:changed",{reason:v[0]})}}#ue(j,E,$){const q=this.#v.get(j);if(!(!q||q.key!==E)&&(this.#v.delete(j),!($&&$.name==="AbortError")&&j==="sort"&&this.#je()===E)){const X=this.#k("filter",()=>this.#Te(),()=>this.#me());this.#k("sort",()=>E,()=>this.#Ge(X)),this.#Y=null,this.#W(),z("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",$),this.#Qe("model:changed",{reason:v[1]})}}#ae(j,E){const $=j&&j.leaves?j.leaves.length:this.#p.slots.length;this.#p.matchCount=$,this.#p.grand=E&&E.grand||null,this.#p.grandLeaves=j&&j.leaves?j.leaves.length:0,this.#p.groupLeaves=j&&j.leaves?j.leaves:null}#k(j,E,$){const q=this.#s.get(j),X=E();return q.computed&&q.key===X||(q.result=$(),q.key=X,q.computed=!0,q.id++,j==="flatten"&&(this.#Y=null)),q.result}#ce(j){return this.#s.get(j).id}#Te(){const j=(this.#e.config||{}).hostFilter,E=j&&W(j.active)&&j.active()?1:0,$=this.#B("where",null),q=$?$.version:0,X=this.#at("filter.sig",`${this.#Ye()}`,()=>d({filters:this.#B("filters",null),quick:this.#B("quick",""),quickMode:this.#B("quickMode","contains")}));return`${this.#c}|${X}|${E}|${q}`}#je(){return`${this.#ce("filter")}|${JSON.stringify(this.#B("sort",[]))}`}#Fe(){return`${this.#ce("sort")}|${JSON.stringify(this.#B("groupBy",[]))}`}#Le(){const j=this.#de()?"f":"a",E=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#ce("group")}|${JSON.stringify(this.#B("totals",[]))}|${j}${E}|${this.#u}`}#xe(){return`${this.#ce("group")}|${JSON.stringify(this.#B("pivotBy",[]))}`}#Ve(){const E=this.#Ze()||!this.#I()?this.#ce("total"):"x",$=`${this.#Ye()}`,q=this.#at("flatten.keys",$,()=>{const Q=this.#B("expanded",null);return Q?[...Q].sort().join(""):"*"}),X=this.#at("flatten.detail",$,()=>{const Q=this.#B("detail",null);return Q&&W(Q.signature)?Q.signature():""});return`${E}|${this.#ce("pivot")}|${q}|${X}`}#Ze(){const j=this.#B("groupBy",[]);return Array.isArray(j)&&j.length>0}stageState(){const j=[];for(const[E,$]of this.#s){const q=$.result;j.push({stage:E,materialised:!!$.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:$.id})}return j}facetIndices(j){return this.#me(j||null)}facetRows(j){const E=this.facetIndices(j),$=[];for(let q=0;q<E.length;q++){const X=this.#Pe(E[q]);X&&$.push(X)}return $}invalidateRows(){this.#f.clear(),this.#L.clear(),this.#Y=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ae()}filteredIndices(){const j=this.#s.get("filter");if(j&&j.computed&&j.key===this.#Te())return j.result||this.#Ae();this.#W();const E=this.#s.get("filter");return(E&&E.computed?E.result:null)||this.#Ae()}unfilteredRows(){const j=this.#Ae(),E=[];for(let $=0;$<j.length;$++){const q=this.#Pe(j[$]);q&&E.push(q)}return E}#me(j=null){const E=this.#Ae(),$=this.#B("filters",null),q=j?this.#Xe("pruneColumn")($,j):$,X=this.#vt(q),Q=String(this.#B("quick","")||"").trim().toLowerCase(),J=Q?K(Q,String(this.#B("quickMode","contains")||"contains")):null,ne=(this.#e.config||{}).hostFilter,re=!!(ne&&W(ne.active)&&ne.active()),oe=this.#B("where",null),ie=!!(oe&&oe.active);if(!X&&!Q&&!re&&!ie)return E;let te=null;X&&(te=this.#Xe("evaluateFilters")(X,{handle:pe=>this.#a.handle(pe),count:this.#mt(),pool:this.#e.pool,locale:(this.#e.config||{}).locale}));const ce=new Uint32Array(E.length);let ue=0;for(let ae=0;ae<E.length;ae++){const pe=E[ae];if(!(te&&!te[pe])&&!(J&&!this.#gt(pe,J))){if(re||ie){const he=this.#Pe(pe);if(re&&!ne.passes(he)||ie&&!oe.passes(he.data,he.key))continue}ce[ue++]=pe}}if(te){const ae=(this.#e.compute||{}).releaseMask;W(ae)&&ae({pool:this.#e.pool},te)}return ce.subarray(0,ue)}handleFor(j){return this.#a.handle(j)}#Ge(j){const E=this.#B("sort",[]).filter(X=>{const Q=this.#Ne(X.col);return!Q||!Q.running?!0:(z(`source.sort.running.${X.col}`,`sort ignores "${X.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(!E.length)return j;const $=(this.#e.config||{}).locale;if(E.length===1){const X=E[0],Q=this.#a.handle(X.col);if(!Q)return z(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`),j;const J=this.#Ne(X.col);return this.#Xe("sortColumn")(Q,j,{descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:$,compare:A(J)})}const q=[];for(const X of E){const Q=this.#a.handle(X.col);if(!Q){z(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`);continue}q.push({handle:Q,descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:$,compare:A(this.#Ne(X.col))})}return q.length?this.#Xe("sortMulti")(q.map(X=>X.handle),q,j):j}#q(j){const E=this.#B("groupBy",[]),$=this.#ee();if($&&!E.length){const ae=w(j,$);return this.#N=m(ae.roots,$.declaresChildren),{roots:null,leaves:j,nodes:new Map,tree:ae}}if(this.#N=null,$&&E.length&&z("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!E.length)return{roots:null,leaves:j,nodes:new Map};const q=(this.#e.config||{}).timeZone,X=[],Q=[];let J=!1;for(const ae of E){const pe=this.#a.handle(ae);if(!pe){z(`source.group.${ae}`,`grouping ignores unknown column "${ae}".`);continue}X.push(pe);const he=this.#Ne(ae),ke=he&&he.dataType;if(ke&&W(ke.groupProjector)){const Oe=he.typeOptions&&he.typeOptions.timeZone||he.timeZone||q||void 0,De=ke.groupProjector(he,Oe);Q.push(De||null),De&&(J=!0)}else Q.push(null)}if(!X.length)return{roots:null,leaves:j,nodes:new Map};const{keys:ne,buckets:re}=this.#Xe("groupByColumns")(X,j,{locale:(this.#e.config||{}).locale,project:J?Q:void 0}),oe=this.#B("pivotBy",[]).length>0,ie=[],te=new Map;for(let ae=0;ae<re.length;ae++){const pe=ne[ae];let he=null;const ke=[];for(let Oe=0;Oe<pe.length;Oe++){ke.push(k(pe[Oe]));const De=L(ke),_e=Oe===pe.length-1;let Se=te.get(De);if(!Se){const xe=this.#i.group({path:[...ke],column:E[Oe],value:pe[Oe],level:Oe,parent:he,expanded:oe&&_e?!1:this.#De(De,{key:De,column:E[Oe],value:pe[Oe],level:Oe,path:[...ke]}),hasChildren:!(oe&&_e)});Se={row:xe,leaves:null},te.set(De,Se),he?he.children.push(xe):ie.push(xe)}Se.row.leafCount+=re[ae].length,Oe===pe.length-1&&(Se.leaves=re[ae]),he=Se.row}}const ce=this.#B("sort",[])||[],ue=(ae,pe)=>{if(!ae||ae.length<2){if(ae)for(const De of ae)ue(De.children,pe+1);return}const he=E[pe],ke=ce.find(De=>De.col===he),Oe=ke&&ke.dir==="desc"?-1:1;ae.sort((De,_e)=>Oe*_(De.groupValue,_e.groupValue));for(const De of ae)ue(De.children,pe+1)};return ue(ie,0),{roots:ie,leaves:j,nodes:te,keys:ne,buckets:re}}#$e(j,E){const $=new Map,q=new Map,X=Q=>{const J=Q.physical>=0?[Q.physical]:[];for(const ne of Q.children)J.push(...X(ne));if(Q.children.length){const ne=this.#Ue(E,Uint32Array.from(J),null);Q.physical>=0?$.set(Q.physical,ne):q.set(Q.key,ne)}return J};for(const Q of j.roots)X(Q);return{byPhysical:$,byKey:q}}#Je(j){const E=this.#qe();if(!E.length)return this.#E=null,this.#T=null,{grand:null};const $={id:this.#ce("group"),columns:E.map(ce=>ce.id).join("")},q=this.#E&&this.#E.id===$.id&&this.#E.columns===$.columns,X=this.#nt()&&q?this.#C:null,Q=X?E.filter(ce=>X.has(ce.id)):E,J=q?this.#T:null,ne=this.#de()?null:this.#ht(),re=this.#et(E),oe=ce=>{const ue=j.nodes.get(ce.key);let ae=ue&&ue.leaves?ue.leaves:null;if(ce.children&&ce.children.length){const ke=ce.children.map(oe);let Oe=0;for(const Se of ke)Oe+=Se.length;const De=new Uint32Array(Oe);let _e=0;for(const Se of ke)De.set(Se,_e),_e+=Se.length;ae=De}ae=ae||new Uint32Array(0);const pe=ne?ne.get(ce.key)||C:ae,he=this.#he(ce,X?Q:E,pe,re);return ce.totals=X?{...ce.totals,...he}:he,ae};if(j.roots&&Q.length)for(const ce of j.roots)oe(ce);if(this.#M=j.tree?this.#$e(j.tree,E):null,this.#E=$,this.#C=this.#nt()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const te=ne?this.#We():j.leaves;return this.#T=this.#Ke(E,te,X,J),{grand:this.#T}}#Ke(j,E,$,q){const X={},Q=this.#ce("group");Q!==this.#w&&(this.#rt(),this.#w=Q);const J=this.#S;this.#S=[];for(const ne of j){if(!T(ne))continue;const re=this.#a.handle(ne.id);if(!re)continue;const oe=O(ne,"grand");if(!n(oe,re)){if($&&!$.has(ne.id)&&q&&ne.id in q){X[ne.id]=q[ne.id];continue}X[ne.id]=this.#Ue([ne],E,null,"grand")[ne.id];continue}let ie=this.#y.get(ne.id);if((!ie||ie.fn!==oe)&&(ie=new t(oe),this.#y.set(ne.id,ie)),ie.valid){let te=!0;for(const ce of J)if(ce.colId===ne.id&&!ie.update(ce.before,ce.after)){te=!1;break}if(te){X[ne.id]=ie.value();continue}ie.invalidate()}ie.seedColumn(re.values,s(re),E),X[ne.id]=ie.valid?ie.value():this.#Ue([ne],E,null,"grand")[ne.id]}return X}#et(j){const E=this.#ce("group");E!==this.#A&&(this.#j.clear(),this.#A=E);const $=new Map;for(const X of j){if(!T(X))continue;const Q=this.#a.handle(X.id),J=O(X,"group");n(J,Q)&&$.set(X.id,{fn:J})}if(!$.size)return this.#O.length=0,$;const q=this.#O;this.#O=[];for(const X of q){const{beforeKeys:Q,afterKeys:J,colDeltas:ne}=X,re=Q.length?new Set(Q):null,oe=J.length?new Set(J):null;for(const{colId:ie,before:te,after:ce}of ne)if($.has(ie)){for(const ue of Q)oe&&oe.has(ue)||this.#Me(ue,ie,te,null);for(const ue of J)re&&re.has(ue)||this.#Me(ue,ie,null,ce);for(const ue of Q)oe&&!oe.has(ue)||this.#Me(ue,ie,te,ce)}}return $}#Me(j,E,$,q){const X=this.#j.get(j),Q=X&&X.get(E);!Q||!Q.valid||Q.update($,q)||Q.invalidate()}#he(j,E,$,q){if(!q||!q.size)return this.#Ue(E,$,j);const X={};let Q=null,J=this.#j.get(j.key);for(const ne of E){const re=q.get(ne.id);if(!re){(Q||(Q=[])).push(ne);continue}const oe=this.#a.handle(ne.id);if(!oe)continue;J||(J=new Map,this.#j.set(j.key,J));let ie=J.get(ne.id);if((!ie||ie.fn!==re.fn)&&(ie=new t(re.fn),J.set(ne.id,ie)),ie.valid||ie.seedColumn(oe.values,s(oe),$),ie.valid){X[ne.id]=ie.value();continue}(Q||(Q=[])).push(ne)}return Q&&Object.assign(X,this.#Ue(Q,$,j)),X}#be(j,E,$,q){const X=!this.#de()||this.#Ie(E);for(const Q of j){const J=Q.getValue;if(!W(J))continue;const ne=J($),re=J(q);Object.is(ne,re)||(this.#C&&this.#C.add(Q.id),X&&this.#y.has(Q.id)&&this.#S.push({colId:Q.id,before:ne,after:re}))}}#bt(){const j=this.#B("groupBy",[]),E=[];for(const $ of j){const q=this.#Ne($);q&&E.push(q)}return E}#ft(j,E){const $=new Array(j.length);for(let q=0;q<j.length;q++){const X=j[q].getValue;$[q]=k(W(X)?X(E):void 0)}return $}#P(j,E,$,q,X){if(this.#de()&&!this.#Ie($))return;const Q=S(this.#ft(j,q)),J=S(this.#ft(j,X)),ne=Q.length!==J.length||Q.some((oe,ie)=>oe!==J[ie]),re=[];for(const oe of E){const ie=oe.getValue;if(!W(ie))continue;const te=ie(q),ce=ie(X);!ne&&Object.is(te,ce)||re.push({colId:oe.id,before:te,after:ce})}!re.length&&!ne||this.#O.push({beforeKeys:Q,afterKeys:J,colDeltas:re})}#Ie(j){const E=this.#s.get("filter"),$=E&&E.computed?E.result:null;if(!$)return!0;let q=0,X=$.length-1;for(;q<=X;){const Q=q+X>>1,J=$[Q];if(J===j)return!0;J<j?q=Q+1:X=Q-1}return!1}#de(){return(this.#e.config||{}).totalFilteredOnly!==!1}#ke(j){return this.#de()?j:this.#We().length}#We(){return(!this.#x||this.#x.version!==this.#c)&&(this.#x={version:this.#c,indices:this.#Ae()}),this.#x.indices}#ht(){const j=this.#B("groupBy",[]),E=`${this.#c}|${JSON.stringify(j)}`;if(this.#R&&this.#R.key===E)return this.#R.map;const $=new Map,q=[];for(const X of j){const Q=this.#a.handle(X);Q&&q.push(Q)}if(q.length){const X=this.#We(),{keys:Q,buckets:J}=this.#Xe("groupByColumns")(q,X,{locale:(this.#e.config||{}).locale}),ne=new Map;for(let re=0;re<J.length;re++){const oe=Q[re],ie=[];for(let te=0;te<oe.length;te++){ie.push(k(oe[te]));const ce=L(ie);let ue=ne.get(ce);ue||(ue=[],ne.set(ce,ue));for(let ae=0;ae<J[re].length;ae++)ue.push(J[re][ae])}}for(const[re,oe]of ne)$.set(re,Uint32Array.from(oe))}return this.#R={key:E,map:$},$}#nt(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Be(){this.#rt(),this.#tt(),this.#C=null,this.#E=null,this.#T=null}#rt(){this.#y.clear(),this.#S.length=0,this.#w=-1}#tt(){this.#j.clear(),this.#O.length=0,this.#A=-1}#it(j){const E=this.#B("pivotBy",[]);if(!E.length)return this.#se=null,null;const $=(this.#e.compute||{}).pivot;if(!W($))return z("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#se=null,null;const q=E.map(Q=>this.#a.handle(Q)).filter(Boolean),X=this.#qe();return this.#se=$(q,j.leaves,{groups:j.keys&&j.buckets?{keys:j.keys,buckets:j.buckets}:null,totals:X.map(Q=>Q.id),handle:Q=>this.#a.handle(Q),totalOf:Q=>O(X.find(J=>J.id===Q),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#se}#ot(j){const E=this.#s.get("total").result,$=!!(this.#e.config||{}).groupFooter,q=this.#V();if(j.tree)return this.#wt(j,E,q);if(!j.roots&&!q){if(E&&E.grand&&!this.#I()){const oe=this.#i.grandTotal(E.grand,this.#ke(j.leaves.length));if(this.#Z===j.leaves&&Array.isArray(this.#D))this.#D[this.#D.length-1]=oe;else{const ie=Array.from(j.leaves);ie.push(oe),this.#D=ie,this.#Z=j.leaves}this.#le=[{at:this.#D.length-1}]}else this.#Z=null,this.#D=j.leaves,this.#le=a;return this.#te=a,this.#D}const X=[],Q=[],J=[],ne=oe=>{if(X.push(oe),!q)return;const ie=this.#Pe(oe);!ie||!q.isOpen(ie.key)||(ie.master=!0,ie.expanded=!0,J.push({at:X.length}),X.push(this.#i.detail(ie,q.heightOf(ie))))};if(!j.roots){for(let oe=0;oe<j.leaves.length;oe++)ne(j.leaves[oe]);return E&&E.grand&&!this.#I()&&(J.push({at:X.length}),X.push(this.#i.grandTotal(E.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=a,this.#le=J.length?J:a,this.#D=X,X}const re=(oe,ie,te)=>{if(oe.expanded=oe.hasChildren===!1?!1:this.#De(oe.key,{key:oe.key,column:oe.groupColumn,value:oe.groupValue,level:oe.level,path:oe.groupPath}),oe.posinset=ie+1,oe.setsize=te,Q.push({at:X.length,row:oe}),J.push({at:X.length}),X.push(oe),!!oe.expanded){if(oe.children&&oe.children.length)for(let ce=0;ce<oe.children.length;ce++)re(oe.children[ce],ce,oe.children.length);else{const ce=j.nodes.get(oe.key),ue=ce&&ce.leaves?ce.leaves:null;if(ue)for(let ae=0;ae<ue.length;ae++)ne(ue[ae])}$&&oe.totals&&(J.push({at:X.length}),X.push(this.#i.footer(oe)))}};for(let oe=0;oe<j.roots.length;oe++)re(j.roots[oe],oe,j.roots.length);return E&&E.grand&&!this.#I()&&(J.push({at:X.length}),X.push(this.#i.grandTotal(E.grand,this.#ke(j.leaves.length)))),this.#te=Q,this.#le=J,this.#D=X,X}#Ae(){const j=this.#e.store;if(j&&W(j.liveIndices))return j.liveIndices();const E=new Uint32Array(this.#n.length);let $=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(E[$++]=q);return E.subarray(0,$)}#mt(){const j=this.#e.store;return j&&typeof j.physical=="number"?j.physical:this.#n.length}#ze(j){const E=this.#e.store;return E&&W(E.source)?E.source(j):this.#n[j]}#pt(j,E=j){const $=this.#D[j];if(typeof $!="number")return $.index=E,$;const q=this.#Pe($);return q.index=E,q}#Pe(j){let E=this.#f.get(j);E||(E=this.#i.leaf(this.#ze(j),j),this.#f.set(j,E));const $=this.#N?this.#N.get(j):null;if($){E.level=$.level,E.posinset=$.posinset,E.setsize=$.setsize,E.hasChildren=$.hasChildren,E.expanded=$.hasChildren&&!$.lazy&&this.#De(E.key);const q=this.#M?this.#M.byPhysical.get(j):void 0;q?E.totals=q:E.totals&&(E.totals=null)}else E.hasChildren&&(E.level=0,E.hasChildren=!1,E.expanded=!1,E.posinset=void 0,E.setsize=void 0);return E}#wt(j,E,$){const q=[],X=[],Q=ne=>{if(ne.leafCount!==void 0)return ne.leafCount;let re=ne.physical>=0?1:0;for(const oe of ne.children)re+=Q(oe);return ne.leafCount=re,re},J=ne=>{const re=this.#De(ne.key);if(ne.physical>=0){if(q.push(ne.physical),$&&$.isOpen(this.#Pe(ne.physical).key)){const oe=this.#Pe(ne.physical);X.push({at:q.length}),q.push(this.#i.detail(oe,$.heightOf(oe)))}}else q.push(this.#i.group({path:[ne.key],column:null,value:ne.value,level:ne.level,parent:null,expanded:re,hasChildren:ne.children.length>0,leafCount:Q(ne),totals:this.#M?this.#M.byKey.get(ne.key):void 0}));if(re)for(const oe of ne.children)J(oe)};for(const ne of j.tree.roots)J(ne);return E&&E.grand&&!this.#I()&&(X.push({at:q.length}),q.push(this.#i.grandTotal(E.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=a,this.#le=X.length?X:a,this.#D=q,q}#Et(){return y(()=>this.count(),j=>this.at(j))}#gt(j,E){let $=this.#L.get(j);if($===void 0){const q=this.#ze(j),X=this.#kt(),Q=[],J=this.#e.columnHidden;for(const ne of X){if(ne.quickFilter===!1||W(J)&&J(ne.id))continue;const re=ne.value&&W(ne.value.quickFilterText)?ne.value.quickFilterText({value:void 0,data:q,row:null,column:ne,colId:ne.id,grid:null,context:this.#B("context",null)}):null,oe=re??(W(ne.formatValue)?ne.formatValue(W(ne.getValue)?ne.getValue(q):void 0):"");oe!=null&&oe!==""&&Q.push(String(oe))}$=Q.join(" ").toLowerCase(),this.#L.set(j,$)}return E($)}#qe(){const j=this.#B("totals",[]),E=j&&j.length?new Set(j):null;return this.#kt().filter($=>E?E.has($.id):!!($.total||$.groupTotal||$.grandTotal))}#Ue(j,E,$,q="group"){const X={},Q=(this.#e.compute||{}).total;for(const J of j){if(!T(J))continue;const ne=this.#a.handle(J.id);if(!ne)continue;const re=O(J,q);if(re)if(W(re)){const oe=new Array(E.length);for(let ie=0;ie<E.length;ie++)oe[ie]=ne.get(E[ie]);X[J.id]=re(oe,{row:$,column:J,grid:this.#e.grid||null,context:this.#B("context",null),valueAt:(ie,te)=>{const ce=this.#a.handle(ie);return ce&&te>=0&&te<E.length?ce.get(E[te]):null}})}else W(Q)&&(X[J.id]=Q(ne,E,re))}return X}#vt(j){if(!j)return j;const E=this.#e.config||{},$={tz:E.timeZone,weekStartsOn:E.weekStartsOn};return f(j,q=>{const X=h(q,$);if(X&&X.type)return X;const Q=this.#Ne(X&&X.col),J=Q&&(Q.dataType?.base||Q.type);return J?{...X,type:J}:X})}#De(j,E){const $=this.#B("expanded",null);return $?W($.has)?$.has(j,E):Array.prototype.includes.call($,j):!0}#B(j,E){if(j==="context"||!W(this.#e.stateVersion))return this.#st(j,E);const $=this.#Mt(j),q=this.#d.get(j);if(q&&q.version===$)return q.value;const X=this.#st(j,E);return this.#d.set(j,{version:$,value:X}),X}#st(j,E){const $=this.#e.state;if($&&W($[j])){const q=$[j]();return q??E}return E}#Ye(){const j=this.#e.stateVersion;return W(j)?j():0}#Tt(){const j=this.#e.columnsVersion,E=this.#e.permissionsVersion;return`${W(j)?j():0}|${W(E)?E():0}`}#Mt(j){return j==="totals"?this.#Tt():`${this.#Ye()}`}#at(j,E,$){if(!W(this.#e.stateVersion))return $();const q=this.#h.get(j);if(q&&q.version===E)return q.key;const X=$();return this.#h.set(j,{version:E,key:X}),X}#Xe(j){const E=(this.#e.compute||{})[j];return W(E)||F(`ctx.compute.${j} is required by the memory source pipeline`),E}#kt(){const j=this.#e.columns;return j&&W(j.all)?j.all():[]}#Ne(j){const E=this.#e.columns;return E&&W(E.get)?E.get(j):void 0}#Qe(j,E){const $=this.#e.emit;W($)&&$(j,E)}}}),ve("packages/core/src/source/abort.js",function(e,V){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class Z extends Error{constructor(U,B="superseded"){super(`[lattice] request ${U?`"${U}" `:""}${B}`),this.name="SupersededError",this.superseded=!0,this.key=U}}class N{#e;constructor(U,B,H,L){this.#e=U,this.key=B,this.controller=H,this.signal=H.signal,this.seq=L}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(U){this.signal.aborted||this.controller.abort(new Z(this.key,U)),this.#e.settle(this)}}class z{#e=new Map;#t=0;begin(U="",B="superseded"){const H=this.#e.get(U);H&&!H.signal.aborted&&H.controller.abort(new Z(U,B));const L=new N(this,U,new AbortController,++this.#t);return this.#e.set(U,L),L}tokenFor(U){return this.#e.get(U)}pending(U=""){const B=this.#e.get(U);return!!B&&!B.signal.aborted}get size(){return this.#e.size}settle(U){this.#e.get(U.key)===U&&this.#e.delete(U.key)}abort(U="",B="superseded"){const H=this.#e.get(U);H&&H.abort(B)}abortAll(U="superseded"){for(const B of[...this.#e.values()])B.abort(U);this.#e.clear()}}function F(){return new z}function W(_){if(!_||typeof _!="object")return!1;const U=_;return U.superseded===!0||U.name==="AbortError"||U.name==="SupersededError"}}),ve("packages/core/src/source/blockcache.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return F}});const Z=100,N=32;class z{constructor(_){this.id=_,this.rows=null,this.state="pending",this.token=null,this.error=null}}class F{#e=new Map;#t;#n;#r=0;#o=-1;constructor(_={}){this.#t=Math.max(1,Math.floor(Number(_.pageSize)||Z)),this.#n=Math.max(1,Math.floor(Number(_.maxCachedPages)||N))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(_){return Math.floor(_/this.#t)}rangeOf(_){return{start:_*this.#t,end:(_+1)*this.#t}}has(_){return this.#e.has(_)}pending(_){const U=this.#e.get(_);return!!U&&U.state==="pending"}loaded(_){const U=this.#e.get(_);return!!U&&U.state==="loaded"}begin(_,U){let B=this.#e.get(_);return B||(B=new z(_)),B.state="pending",B.token=U,B.error=null,this.#i(_,B),B}fill(_,U){const B=this.#e.get(_)||new z(_);B.rows=U,B.state="loaded",B.token=null,this.#i(_,B)}failed(_,U){const B=this.#e.get(_)||new z(_);B.state="error",B.error=U,B.token=null,this.#i(_,B)}delete(_){return this.#e.delete(_)}rowAt(_){const U=this.blockOf(_),B=this.#e.get(U);if(!(!B||B.state!=="loaded"||!B.rows))return this.#i(U,B),B.rows[_-U*this.#t]}rowLoaded(_){const U=this.blockOf(_),B=this.#e.get(U);return!!B&&B.state==="loaded"&&!!B.rows&&_-U*this.#t<B.rows.length}loadedExtent(){let _=0;for(const U of this.#e.values()){if(U.state!=="loaded"||!U.rows)continue;const B=U.id*this.#t+U.rows.length;B>_&&(_=B)}return _}fillOf(_){const U=this.#e.get(_);return U&&U.state==="loaded"&&U.rows?U.rows.length:null}protect(_,U){this.#r=this.blockOf(Math.max(0,_)),this.#o=this.blockOf(Math.max(0,U))}evict(){const _=[];if(this.#e.size<=this.#n)return _;for(const[U,B]of this.#e){if(this.#e.size-_.length<=this.#n)break;U>=this.#r&&U<=this.#o||B.state!=="pending"&&_.push(U)}for(const U of _)this.#e.delete(U);return _}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(_,U){this.#e.delete(_),this.#e.set(_,U)}}}),ve("packages/core/src/source/paged.js",function(e,V){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/internal/util.js"),N=Z.Lru,z=Z.isFunction,F=Z.warnOnce,W=Z.settleDebounce,_=V("packages/core/src/source/abort.js"),U=_.createAbortScope,B=_.isAbortError,H=V("packages/core/src/source/blockcache.js"),L=H.BlockCache,k=H.DEFAULT_PAGE_SIZE,S=H.DEFAULT_MAX_CACHED_PAGES,u=V("packages/core/src/source/rows.js").createRowFactory,o=V("packages/core/src/source/filterwire.js"),r=o.wireFilters,t=o.querySignature,n=o.warnHostFilterNotApplied,i=120;function s(d,f){return new c(d,f)}class c{mode="paged";#e;#t;#n;#r=U();#o;#i;#a=new Map;#s=null;#l=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(f,h){this.#e=f||{mode:"paged"},this.#t=h||{},this.#n=new L({pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S}),this.#o=u(this.#t),this.#i=new N(this.#n.pageSize*4),this.#h=W((g,w)=>this.#m(g,w),i),this.#c=this.#y(),z(this.#e.fetch)||F("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){if(this.#v(),this.#s!==null)return this.#s;const f=Math.max(this.#u,this.#n.loadedExtent());return this.#l?f:f+this.#n.pageSize}at(f){if(this.#v(),f<0||f>=this.count())return;const h=this.#i.get(f);if(h&&(h.data!==null||!this.#n.rowLoaded(f)))return h;const g=this.#n.rowAt(f);if(g===void 0){const p=this.#o.skeleton(f);return this.#i.set(f,p),p}const w=this.#o.leaf(g,f);return w.index=f,this.#i.set(f,w),this.#a.set(w.key,f),w}byKey(f){const h=this.#a.get(f);return h===void 0?void 0:this.at(h)}loaded(f){return this.#n.rowLoaded(f)}hint(f,h){if(this.#f)return;const g=this.#v(),w=Math.max(0,Math.floor(f)),p=Math.max(w,Math.floor(h));this.#d={start:w,end:p},this.#n.protect(w,p);for(const m of this.#n.evict())this.#g(m);this.#h(w,p),g&&this.#h.flush()}#m(f,h){if(this.#f)return;this.#n.protect(f,h);const g=this.#n.blockOf(f),w=this.#n.blockOf(h);for(let p=g;p<=w&&!(this.#s!==null&&p*this.#n.pageSize>=this.#s);p++)this.#n.has(p)||this.#p(p)}apply(f){const h={added:[],updated:[],removed:[]};if(!f)return h;if(f.update)for(const g of f.update){const w=this.#o.keyOf(g,-1),p=this.#a.get(w);if(p===void 0)continue;const m=this.#o.leaf(g,p);m.index=p,this.#i.set(p,m),h.updated.push(m)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload(),h}reload(f){this.#b("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#f=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#a.clear()}exact(){return this.#s!==null||this.#l}pending(){return this.#r.size}async#p(f){if(!z(this.#e.fetch))return;const h=this.#r.begin(`block:${f}`);this.#n.begin(f,h);const{start:g,end:w}=this.#n.rangeOf(f),p=this.#c;try{const m=await this.#e.fetch({range:{start:g,end:w},sort:this.#S("sort",[]),filters:r(this.#S("filters",null),this.#w()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:h.signal});if(!h.current||p!==this.#c||this.#f)return;h.settle();const b=m&&m.rows||[];this.#n.fill(f,b);for(let l=0;l<b.length;l++)this.#i.delete(g+l);const v=m&&typeof m.total=="number"?m.total:m&&typeof m.count=="number"?m.count:null;v!==null?(this.#s=v,this.#l=!0):b.length<this.#n.pageSize?(this.#l=!0,this.#s=g+b.length):this.#u=Math.max(this.#u,g+b.length),this.#j("model:changed",{reason:"page",block:f,from:g,to:g+b.length})}catch(m){if(h.settle(),B(m))return;this.#n.failed(f,m),this.#j("source:error",{error:m,block:f,range:{start:g,end:w}})}}#g(f){const{start:h,end:g}=this.#n.rangeOf(f);for(let w=h;w<g;w++){const p=this.#i.peek(w);p&&this.#a.delete(p.key),this.#i.delete(w)}}#v(){const f=this.#y();return f===this.#c?!1:(this.#c=f,this.#b("query"),!0)}#b(f){this.#r.abortAll(f),this.#n.clear(),this.#i.clear(),this.#a.clear(),this.#s=null,this.#l=!1,this.#u=0,this.#j("model:changed",{reason:f})}#y(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#w(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#S(f,h){const g=this.#t.state;if(g&&z(g[f])){const w=g[f]();return w??h}return h}#j(f,h){const g=this.#t.emit;z(g)&&g(f,h)}}}),ve("packages/core/src/source/remote.js",function(e,V){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return w}});const Z=V("packages/core/src/internal/util.js"),N=Z.Lru,z=Z.isFunction,F=Z.warnOnce,W=Z.settleDebounce,_=V("packages/core/src/source/abort.js"),U=_.createAbortScope,B=_.isAbortError,H=V("packages/core/src/source/blockcache.js"),L=H.BlockCache,k=H.DEFAULT_PAGE_SIZE,S=H.DEFAULT_MAX_CACHED_PAGES,y=V("packages/core/src/source/rows.js"),u=y.createRowFactory,o=y.groupKey,r=V("packages/core/src/source/filterwire.js"),t=r.wireFilters,n=r.querySignature,i=r.warnHostFilterNotApplied,c=V("packages/core/src/source/memory.js").MemorySource,d=1,f=120;function h(p,m){return new w(p,m)}class g{constructor(m,b,v,l){this.path=m,this.keyPath=l||m,this.values=[],this.level=b,this.key=o(this.keyPath),this.cache=new L(v),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null}}class w{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#a=U();#s;#l;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(m,b){this.#e=m||{mode:"remote"},this.#t=b||{},z(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#j(),this.handleFor=a=>this.#A(a),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#E(),this.unfilteredRows=()=>this.#R(),this.facetIndices=a=>this.#C(a));const v=this.#e.counts;z(v)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const l=this.#e.grandTotals;z(l)&&(this.grandTotalRow=()=>this.#x()),this.#n={pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S},this.#s=u(this.#t),this.#l=new N(this.#n.pageSize*4),this.#h=W((a,O)=>this.#v(a,O),f),this.#r=new g([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ge(),z(this.#e.fetch)||F("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#K()}count(){const m=this.#y();return m?m.count():(this.#se(),this.#L(this.#r))}at(m){const b=this.#y();if(b)return b.at(m);if(this.#se(),m<0||m>=this.count())return;const v=this.#D(this.#r,m);if(!v)return;const l=this.#Z(v.node,v.local);return l&&(l.index=m),l||this.#s.skeleton(m,v.node.level)}byKey(m){const b=this.#y();if(b)return b.byKey(m);const v=this.#u.get(m);if(!v)return;const l=v.lastIndexOf(":"),a=this.#o.get(v.slice(0,l));return a&&this.#Z(a,Number(v.slice(l+1)))||void 0}loaded(m){const b=this.#y();if(b)return b.loaded(m);if(m<0||m>=this.count())return!1;const v=this.#D(this.#r,m);return!!v&&v.node.cache.rowLoaded(v.local)}hint(m,b){if(this.#f)return;const v=this.#se(),l=Math.max(0,Math.floor(m)),a=Math.max(l,Math.floor(b));for(const[O,T]of this.#g(l,a)){O.cache.protect(T.min,T.max);for(const A of O.cache.evict())this.#le(O,A)}this.#h(l,a),v&&this.#h.flush()}#g(m,b){const v=this.count(),l=new Map;for(let a=m;a<=b&&a<v;a++){const O=this.#D(this.#r,a);if(!O)continue;const T=l.get(O.node);T?(T.min=Math.min(T.min,O.local),T.max=Math.max(T.max,O.local)):l.set(O.node,{min:O.local,max:O.local})}return l.size||l.set(this.#r,{min:m,max:m}),l}#v(m,b){if(!this.#f)for(const[v,l]of this.#g(m,b)){v.cache.protect(l.min,l.max);const a=v.cache.blockOf(l.min),O=v.cache.blockOf(l.max);for(let T=a;T<=O&&!(v.count!==null&&T*v.cache.pageSize>=v.count);T++)v.cache.has(T)||this.#M(v,T)}}apply(m){const b={added:[],updated:[],removed:[]};if(!m)return b;if(m.update)for(const v of m.update){const l=this.#u.get(this.#s.keyOf(v,-1));if(!l)continue;this.#l.delete(l);const a=l.lastIndexOf(":"),O=this.#o.get(l.slice(0,a));if(!O)continue;const T=Number(l.slice(a+1)),A=O.cache.blockOf(T);if(!O.cache.loaded(A))continue;const{start:M}=O.cache.rangeOf(A),C=[];for(let x=M;x<M+O.cache.pageSize;x++){const K=O.cache.rowAt(x);if(K===void 0)break;C.push(x===T?v:K)}O.cache.fill(A,C);const P=this.#Z(O,T);P&&b.updated.push(P)}return(m.add&&m.add.length||m.remove&&m.remove.length)&&this.reload({keepExpanded:!0}),b}reload(m){this.#a.abortAll("reload"),this.#h.cancel(),m&&m.keepExpanded===!1&&this.#i.clear(),this.#ne(),this.#X("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#ne(),this.#o.clear(),this.#i.clear(),this.#m&&z(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(m){this.#i.has(m)||(this.#i.add(m),this.#X("group:toggled",{key:m,expanded:!0}),this.#X("model:changed",{reason:"expand",key:m}))}collapse(m){this.#i.delete(m)&&(this.#X("group:toggled",{key:m,expanded:!1}),this.#X("model:changed",{reason:"collapse",key:m}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}invalidateHandles(){this.#m&&(z(this.#m.invalidateHandles)&&this.#m.invalidateHandles(),z(this.#m.invalidate)&&this.#m.invalidate("filter"))}#b(){const m=this.#e.fullFrame;return z(m)?m():null}#y(){const m=this.#b();return m?(this.#m||(this.#m=new c({mode:"memory"},this.#w())),m.version!==this.#p&&(this.#m.setRows(m.rows),this.#p=m.version),this.#m):null}#w(){const m=this.#t,b=m.state||{};return{...m,state:{...b,page:()=>0,pageSize:()=>0}}}#S(){const m=this.#y();return m?m.filteredIndices():new Uint32Array(0)}#j(){const m=this.#y();return m?m.unfilteredIndices():new Uint32Array(0)}#A(m){const b=this.#y();return b?b.handleFor(m):void 0}#O(){const m=this.#y();return m?m.display():[]}#C(m){const b=this.#y();return b&&z(b.facetIndices)?b.facetIndices(m):new Uint32Array(0)}#E(){const m=this.#y();return m&&z(m.grandTotalRow)?m.grandTotalRow():null}#T(m){const b=this.#y();if(b){const O=m==="match"?b.matchCount:b.totalCount;if(z(O))return O.call(b)}const v=this.#e.counts,l=z(v)?v():null,a=l?l[m]:null;return typeof a=="number"?a:this.count()}#x(){const m=this.#y();if(m&&z(m.grandTotalRow))return m.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const v=this.#e.grandTotals,l=z(v)?v():null;return!l||!l.totals?null:this.#s.grandTotal(l.totals,l.leafCount||0)}#R(){const m=this.#y();if(m&&z(m.unfilteredRows))return m.unfilteredRows();const b=[],v=this.count();for(let l=0;l<v;l++){const a=this.at(l);a&&b.push(a)}return b}#N(m,b,v){const{start:l,end:a}=m.cache.rangeOf(b),O=this.#z("groupBy",[]),T=this.#z("pivotBy",[]),A=this.#z("quick",""),M=this.#ee(),C={protocol:d,range:{start:l,end:a},groupPath:m.path,groupValues:m.values,groupBy:O,totals:M,totalFns:this.#I(M),pivotBy:T,pivotMode:T.length>0,filters:t(this.#z("filters",null),this.#we()),sort:this.#z("sort",[]),context:this.#z("context",null),signal:v};A&&(C.quick=A);const P=this.#z("where",null);return P&&P.active&&(C.where=P),C}async#M(m,b){if(!z(this.#e.fetch))return;const v=this.#a.begin(`${m.key}:${b}`);m.cache.begin(b,v);const l=this.#d,{start:a}=m.cache.rangeOf(b);try{const O=await this.#e.fetch(this.#N(m,b,v.signal));if(!v.current||l!==this.#d||this.#f)return;v.settle();const T=O&&O.rows||[];m.cache.fill(b,T);for(let C=0;C<T.length;C++)this.#l.delete(`${m.key}:${a+C}`);const A=O&&typeof O.count=="number"?O.count:O&&typeof O.total=="number"?O.total:null,M=O&&z(O.pendingTotal?.then)?O.pendingTotal:null;A!==null?(m.count=A,m.complete=!0):T.length<m.cache.pageSize?(m.count=a+T.length,m.complete=!0):M&&(m.counting=!0),O&&Array.isArray(O.pivotFields)&&this.#U(O.pivotFields),this.#X("model:changed",{reason:"page",groupPath:m.path,block:b}),M&&this.#_(m,M,l)}catch(O){if(v.settle(),B(O))return;m.cache.failed(b,O),this.#X("source:error",{error:O,groupPath:m.path,block:b})}}async#_(m,b,v){let l;try{l=await b}catch(a){if(v!==this.#d||this.#f)return;m.counting=!1,B(a)||this.#X("source:error",{error:a,groupPath:m.path});return}v!==this.#d||this.#f||(m.counting=!1,typeof l=="number"&&(m.count=l,m.complete=!0,this.#X("source:total",{total:l,groupPath:m.path}),this.#X("model:changed",{reason:"total",count:l,groupPath:m.path})))}totalPending(){return this.#r.counting===!0}#U(m){m.length===this.#c.length&&m.every((b,v)=>b===this.#c[v])||(this.#c=m,this.#X("column:pivoted",{pivotFields:m,remote:!0}))}#L(m){let b=this.#Y(m);for(const v of m.children.values())this.#V(v.key)&&(b+=this.#L(v));return b}#Y(m){if(m.count!==null)return m.count;const b=m.cache.loadedExtent();return m.complete?b:m.row&&m.row.leafCount>0?Math.max(b,m.row.leafCount):b+m.cache.pageSize}#D(m,b){let v=b,l=0;const a=[...m.children.entries()].filter(([,T])=>this.#V(T.key)).sort((T,A)=>T[0]-A[0]);for(const[T,A]of a){const M=T-l+1;if(v<M)return{node:m,local:l+v};v-=M,l=T+1;const C=this.#L(A);if(v<C)return this.#D(A,v);v-=C}const O=this.#Y(m);return l+v<O?{node:m,local:l+v}:null}#Z(m,b){const v=`${m.key}:${b}`,l=this.#l.get(v);if(l)return l;const a=m.cache.rowAt(b);if(a===void 0)return null;const O=this.#z("groupBy",[]);let T;if(m.level<O.length){const A=O[m.level],M=this.#G(a,A),C=M==null,P=[...m.path,C?"":String(M)],x=[...m.keyPath,C?null:String(M)];T=this.#s.group({path:P,keyPath:x,column:A,value:M,level:m.level,parent:m.row,leafCount:Number(a.leafCount)||0,expanded:this.#V(o(x))}),T.totals=this.#te(a),T.data=a;let K=this.#o.get(T.key);K?K.row=T:(K=new g(P,m.level+1,this.#n,x),K.row=T,this.#o.set(K.key,K)),K.values=[...m.values,M],m.children.set(b,K)}else T=this.#s.leaf(a,b,m.level,m.row);return this.#l.set(v,T),this.#u.set(T.key,v),T}#te(m){const b=m||{};if(b.totals&&typeof b.totals=="object")return b.totals;const v={};for(const l of this.#ee())Object.hasOwn(b,l)&&(v[l]=b[l]);return v}#le(m,b){const{start:v,end:l}=m.cache.rangeOf(b);for(let a=v;a<l;a++){const O=`${m.key}:${a}`,T=this.#l.peek(O);T&&this.#u.delete(T.key),this.#l.delete(O)}}#se(){const m=this.#ge();return m===this.#d?!1:(this.#d=m,this.#a.abortAll("query"),this.#ne(),this.#X("model:changed",{reason:"query"}),!0)}#ne(){for(const m of this.#o.values())m.cache.clear(),m.count=null,m.complete=!1,m.counting=!1,m.children.clear();this.#l.clear(),this.#u.clear()}#ge(){const m=this.#z("where",null);return`${n({filters:this.#z("filters",null),sort:this.#z("sort",[]),quick:this.#z("quick",""),groupBy:this.#z("groupBy",[]),pivotBy:this.#z("pivotBy",[]),context:this.#z("context",null)})}|${m?m.version:0}`}#V(m){const b=this.#z("expanded",null);return b?z(b.has)?b.has(m):Array.prototype.includes.call(b,m):this.#i.has(m)}#ee(){const m=this.#z("totals",[]);if(m&&m.length)return[...m];const b=this.#t.columns;return!b||!z(b.all)?[]:b.all().filter(v=>!!v.total).map(v=>v.id)}#I(m){const b=this.#t.columns,v={};if(!b||!z(b.get))return v;for(const l of m){const a=b.get(l);if(!a)continue;const O=a.groupTotal!=null?a.groupTotal:a.total;typeof O=="string"&&(v[l]=O)}return v}#G(m,b){const v=this.#t.columns,l=v&&z(v.get)?v.get(b):void 0;return l&&z(l.getValue)?l.getValue(m):m?.[b]}#K(){i(this.#t)}#we(){const m=this.#t.config||{};return{tz:m.timeZone,weekStartsOn:m.weekStartsOn}}#z(m,b){const v=this.#t.state;if(v&&z(v[m])){const l=v[m]();return l??b}return b}#X(m,b){const v=this.#t.emit;z(v)&&v(m,b)}}}),ve("packages/core/src/source/gapbuffer.js",function(e,V){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return N}});const Z=64;class N{#e;#t=0;#n=0;constructor(F=Z){this.#e=new Uint32Array(Math.max(1,F)),this.#n=this.#e.length}static from(F,W=Z){const _=new N(F.length+Math.max(1,W));return _.#e.set(F,0),_.#t=F.length,_.#n=_.#e.length,_}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(F){return F<0||F>=this.length?0:F<this.#t?this.#e[F]:this.#e[F+(this.#n-this.#t)]}insert(F,W){const _=F<0?0:F>this.length?this.length:F;this.#r(_),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(F){this.insert(this.length,F)}removeAt(F){return!Number.isInteger(F)||F<0||F>=this.length?!1:(this.#r(F),this.#n++,!0)}toArray(){const F=new Uint32Array(this.length);return F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),this.#t),F}clear(){this.#t=0,this.#n=this.#e.length}#r(F){if(F!==this.#t)if(F<this.#t){const W=this.#t-F;this.#e.copyWithin(this.#n-W,F,this.#t),this.#t=F,this.#n-=W}else{const W=F-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=F,this.#n+=W}}#o(){const F=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Z));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-F),this.#e=W,this.#n=W.length-F}}}),ve("packages/core/src/store/ingest.js",function(e,V){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const Z=V("packages/core/src/internal/util.js"),N=Z.now,z=Z.nextFrame,F=Z.infoOnce,W=Z.warnOnce,_=Z.isFunction,U=Z.pathGetter,H=V("packages/core/src/store/columnstore.js").ColumnStore,L=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function k(n,i={}){if(i.multi)return"multi";if(n.length===0)return"object";let s=0,c=0,d=0,f=0,h=0;for(let w=0;w<n.length;w++){const p=n[w];typeof p=="number"?s++:typeof p=="boolean"?c++:typeof p=="string"?d++:p instanceof Date?f++:Array.isArray(p)&&h++}const g=n.length;return s===g?"float64":c===g?"bitset":f===g?"float64":d===g?"text":h===g?"multi":"object"}function S(n,i,s){return i<=0||n<s*i?"dictionary":"object"}function y(n,i,s){const c=new Map,d=new Map;for(const a of n){if(a.computed)continue;const O=_(a.read)?a.read:U(a.field||a.id);d.set(a.id,O),c.set(a.id,O)}const f=i?.order??[],h=i?.fns??{},g=i?.deps??{},w=i?.wrapDeps??null,p=f.filter(a=>_(h[a])),m=p.some(a=>g[a]==="*");let b=new WeakMap;const v=a=>{const O={};if(m)for(const[T,A]of d)O[T]=A(a);for(const T of p){const A=g[T];let M;if(A==="*")M=O;else{M={};const C=A||[];for(let P=0;P<C.length;P++){const x=C[P];M[x]=x in O?O[x]:d.get(x)?.(a)}}O[T]=h[T](w?w(M,T):M,{data:a,row:null,column:null,grid:null,context:s})}return O},l=a=>{if(a===null||typeof a!="object"&&typeof a!="function")return v(a);let O=b.get(a);return O===void 0&&(O=v(a),b.set(a,O)),O};for(const a of p)c.set(a,O=>l(O)[a]);return{readers:c,reset(){b=new WeakMap}}}class u{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class o{#e;#t=[];#n=null;#r;#o=0;#i;#a=!1;#s=!1;#l=0;#u;constructor(i,s={},c={}){this.#e=Array.isArray(i)?i:Array.from(i||[]),this.#i={...L,...c};const d=s.columns??[];this.#r=y(d,s.computed??null,s.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(d,s.computed??null),this.#n=new H(this.#t.map(f=>({id:f.spec.id,kind:f.kind,nullable:f.nullable,read:f.read,dictionary:f.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#s}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#s=!0,!1;const i=N(),{chunkMs:s,chunkRows:c}=this.#i,d=this.#e.length;do{const f=Math.min(this.#o+c,d);this.#n.append(this.#e.slice(this.#o,f)),this.#d(this.#o,f),this.#o=f,this.#r.reset(),this.#f(!1)}while(this.#o<d&&N()-i<s);return this.#l+=N()-i,this.#i.onProgress?.({loaded:this.#o,total:d}),this.#o>=d?(this.#f(!0),this.#a=!0,!1):!0}cancel(){this.#s=!0}result(){return{store:this.#n,schema:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#h(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#l,cancelled:this.#s}}#c(i,s){const c=this.#e,d=Math.min(this.#i.sampleSize,c.length),f=this.#i.dictionaryRatio,h=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const g of i){if(!g||!g.id)continue;if(g.computed&&(g.pure===!1||s&&!h.has(g.id))){W(`ingest.impure.${g.id}`,`column "${g.id}" is an impure computed column and is not materialised into the store`);continue}const w=this.#r.readers.get(g.id)??(_(g.read)?g.read:U(g.field||g.id)),p=new u(g,w);if(g.kind)p.kind=g.kind,p.reason="declared by the caller";else if(g.dictionary)p.kind=g.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const m=[];for(let v=0;v<d&&m.length<this.#i.sampleSize;v++){const l=w(c[v]);l!=null&&m.push(l)}p.inferred=!0;const b=k(m,{multi:g.multi});if(b==="text"){const v=new Set(m).size;p.kind=S(v,m.length,f),p.candidate=this.#u,p.reason=`sampled ${v} distinct in ${m.length}`}else p.kind=b,p.reason=`inferred from ${m.length} sampled values`,b==="object"&&m.length&&F(`ingest.mixed.${g.id}`,`column "${g.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(m))}this.#t.push(p)}}#d(i,s){const c=this.#e;for(const d of this.#t){if(!d.candidate||!d.distinct)continue;const f=d.distinct;for(let h=i;h<s;h++){const g=d.read(c[h]);g!=null&&f.add(g)}}}#h(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#f(i){const s=this.#i.dictionaryRatio,c=this.#e.length;for(const d of this.#t){if(!d.candidate)continue;const f=this.#h(d);if(d.kind==="dictionary"&&f>=s*c){const h=this.#n.column(d.spec.id);d.distinct=new Set(h?.dict?h.dict.values():[]),this.#n.convert(d.spec.id,"object"),d.kind="object",d.change="demoted",d.reason=`${f} distinct values is at or above ${s*100}% of ${c} rows`;continue}if(d.kind==="object"&&f>=s*c){d.candidate=!1,d.distinct=null,d.reason=`${f} distinct values is at or above ${s*100}% of ${c} rows`;continue}i&&d.kind==="object"&&f<s*c&&(this.#n.convert(d.spec.id,"dictionary"),d.kind="dictionary",d.change=d.change==="demoted"?null:"promoted",d.reason=`${f} distinct values is below ${s*100}% of ${c} rows`,d.distinct=null),i&&(d.candidate=!1)}}}async function r(n,i={},s={}){const c=new o(n,i,s),d=s.scheduler?.frame??z;for(;c.slice();)await new Promise(f=>{d(f)});return c.result()}function t(n,i={},s={}){const c=new o(n,i,{...s,chunkMs:1/0});for(;c.slice(););return c.result()}}),ve("packages/core/src/store/columnpack.js",function(e,V){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return o}});const N=V("packages/core/src/internal/util.js").pathGetter,z=V("packages/core/src/store/ingest.js"),F=z.inferKind,W=z.decideText,_=z.INGEST_DEFAULTS,B=V("packages/core/src/store/columnstore.js").toFloat,H=new Set(["float64","int32","bitset","dictionary","object","multi"]);function L(r){if(!Array.isArray(r)||r.length===0)return!1;for(const t of r)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!H.has(t.kind))return!1;return!0}function k(r){const t=B(r);return Number.isFinite(t)?t|0:0}function S(r){return r==null?[]:Array.isArray(r)?r:[r]}function y(r,t,n,i){if(r.kind)return r.kind;const s=[];for(let f=0;f<t.length&&s.length<_.sampleSize;f++){const h=t[f];h!=null&&s.push(h)}const c=F(s,{multi:r.multi});if(c!=="text")return c;const d=new Set(s).size;return W(d,s.length,i)}function u(r,t,n={}){const i=t.length|0,s=n.dictionaryRatio??_.dictionaryRatio,c=[];for(const d of r){const f=N(d.field||d.id),h=d.nullable!==!1,g=new Array(i);for(let v=0;v<i;v++){const l=f(t[v]);g[v]=l===void 0?null:l}const w=y(d,g,i,s),p=h?new Uint8Array(i+7>>3):null,m=v=>{p&&(p[v>>3]|=1<<(v&7))};let b;switch(w){case"float64":{const v=new Float64Array(i);for(let l=0;l<i;l++){const a=g[l],O=a===null;O||m(l),v[l]=O?NaN:B(a)}b={id:d.id,kind:w,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"int32":{const v=new Int32Array(i);for(let l=0;l<i;l++){const a=g[l],O=a===null;O||m(l),v[l]=O?0:k(a)}b={id:d.id,kind:w,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"bitset":{const v=new Uint8Array(i+7>>3);for(let l=0;l<i;l++){const a=g[l],O=a===null;O||m(l),!O&&a&&(v[l>>3]|=1<<(l&7))}b={id:d.id,kind:w,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"dictionary":{const v=new Uint32Array(i),l=[],a=new Map;for(let O=0;O<i;O++){const T=g[O];if(T===null){v[O]=0;continue}m(O);let A=a.get(T);A===void 0&&(A=l.length,l.push(T),a.set(T,A)),v[O]=A}b={id:d.id,kind:w,nullable:h,values:v,presence:p,offsets:null,table:l};break}case"multi":{const v=[],l=new Map,a=new Uint32Array(i+1),O=[];for(let T=0;T<i;T++){const A=g[T];a[T]=O.length,A===null||m(T);const C=S(A);for(let P=0;P<C.length;P++){const x=C[P];let K=l.get(x);K===void 0&&(K=v.length,v.push(x),l.set(x,K)),O.push(K)}}a[i]=O.length,b={id:d.id,kind:w,nullable:h,values:Int32Array.from(O),presence:p,offsets:a,table:v};break}default:{const v=new Array(i);for(let l=0;l<i;l++){const a=g[l];a!==null&&m(l),v[l]=a}b={id:d.id,kind:"object",nullable:h,values:v,presence:p,offsets:null,table:null};break}}c.push(b)}return{count:i,columns:c}}function o(r){const t=[];if(!r||!Array.isArray(r.columns))return t;const n=i=>{ArrayBuffer.isView(i)&&i.buffer&&!t.includes(i.buffer)&&t.push(i.buffer)};for(const i of r.columns)n(i.values),n(i.presence),n(i.offsets);return t}}),ve("packages/core/src/source/stream.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const Z=V("packages/core/src/internal/util.js"),N=Z.Lru,z=Z.isFunction,F=Z.now,W=Z.nextFrame,_=Z.cancelFrame,U=Z.whenIdle,B=Z.defaultCompare,H=Z.warnOnce,L=Z.infoOnce,k=Z.getPath,S=V("packages/core/src/source/abort.js"),y=S.createAbortScope,u=S.isAbortError,o=V("packages/core/src/source/rows.js"),r=o.createRowFactory,t=o.lazyRowView,i=V("packages/core/src/source/gapbuffer.js").GapBuffer,c=V("packages/core/src/source/memory.js").createMemorySource,f=V("packages/core/src/source/filterwire.js").querySignature,g=V("packages/core/src/store/columnpack.js").isPortableSchema,w=25e4,p=Symbol("lattice.stream.storeBacked"),m=8,b=.1,v=1e3,l=50;function a(M){return Math.min(v,Math.max(l,Math.floor(M/4)))}function O(M){if(M instanceof Date)return M.getTime();if(typeof M=="number")return Number.isFinite(M)?M:NaN;if(typeof M=="string"){const C=M.trim();if(!C)return NaN;const P=Date.parse(C);return Number.isNaN(P)?Number(C):P}return NaN}function T(M,C){return new A(M,C)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#a;#s;#l=new Map;#u=y();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#m=0;#p=0;#g=null;#v=null;#b=null;#y=!1;#w=!1;#S=!1;#j=!1;#A="";#O=0;#C=0;#E=0;#T=null;#x=1/0;#R=!1;#N=null;#M=null;#_=null;#U=null;#L=!1;#Y=0;#D=0;#Z=!1;constructor(C,P){this.#e=C||{mode:"stream"},this.#t=P||{},this.#a=r(this.#t),this.#s=new N(4096),this.#A=this.#Me();const x=(this.#t.config||{}).ingest;this.#L=!!x&&x.retainSource===!1,z(this.#e.open)||H("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const K=Number(this.#e.poll);Number.isFinite(K)&&K>0&&(this.#U=setInterval(()=>{this.#j||this.reload()},K),this.#U&&z(this.#U.unref)&&this.#U.unref()),this.#le()}#te(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#le(){const C=this.#te();if(!C)return;const P=this.#e.ageBy;z(P)?this.#M=P:typeof P=="string"&&P?this.#M=x=>k(x,P):this.#M=null,this.#T=[],this.#N=setInterval(()=>{this.#j||this.#se()&&(this.#re(),this.#Fe())},a(C)),this.#N&&z(this.#N.unref)&&this.#N.unref()}#se(){const C=this.#te();return!C||!this.#T?!1:this.#R?!0:this.#x<Date.now()-C*(1+b)}#ne(C,P){if(!this.#T)return;const x=this.#M?O(this.#M(P)):Date.now();this.#T[C]=x,Number.isNaN(x)||(x<this.#x&&(this.#x=x),x<Date.now()-this.#te()&&(this.#R=!0))}#ge(){return this.#he("groupBy",[]).length>0?!0:!!this.#he("pivotMode",!1)&&this.#he("pivotBy",[]).length>0}#V(){if(this.#g||this.#j)return;const C=this.#ge();if(C&&!this.#v){this.#v=c({mode:"memory",rows:this.#n},this.#ee()),this.#y=!1;return}!C&&this.#v&&(this.#v.destroy(),this.#v=null)}#ee(){if(this.#b)return this.#b;const C=this,P={liveIndices:()=>C.#I(),live:x=>C.#n[x]!==void 0,source:x=>C.#me(x),get physical(){return C.#n.length}};return this.#L&&(P.column=x=>{const K=C.#t.store;return K&&z(K.column)?K.column(x):void 0}),this.#b=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#b}#I(){const C=new Uint32Array(this.#n.length);let P=0;for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&(C[P++]=x);return C.subarray(0,P)}#G(){return this.#g?this.#g:this.#v?(this.#y&&(this.#y=!1,this.#v.setRows(this.#n)),this.#v):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#V(),this.#v&&this.#v.invalidate(C),(C==="filter"||C==="sort")&&this.#$()}count(){const C=this.#G();return C?C.count():this.#r?this.#r.length:this.#O}matchCount(){const C=this.#G();return C&&z(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const C=this.#G();return C&&z(C.totalCount)?C.totalCount():this.#O}unfilteredRows(){const C=this.#G();if(C&&z(C.unfilteredRows))return C.unfilteredRows();const P=[];for(let x=0;x<this.#n.length;x++){if(!this.#n[x])continue;const K=this.#q(x);K&&P.push(K)}return P}at(C){const P=this.#G();if(P)return P.at(C);if(C<0||C>=this.count())return;const x=this.#r?this.#r.at(C):C,K=this.#q(x);return K.index=C,K}byKey(C){const P=this.#G();if(P)return P.byKey(C);const x=this.#l.get(C);return x===void 0?void 0:this.#q(x)}leavesOf(C){const P=this.#G();return P&&z(P.leavesOf)?P.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,P){if(this.#g){this.#g.hint(C,P);return}this.#K(),this.#m=Math.max(0,Math.floor(C))}#K(){this.#j||this.#Me()===this.#A||this.reload()}display(){const C=this.#G();return C?C.display():t(()=>this.count(),P=>this.at(P))}apply(C){if(this.#g)return this.#g.apply(C);const P={added:[],updated:[],removed:[]};if(!C)return P;if(C.update){let x=!1;for(const K of C.update){const I=this.#l.get(this.#a.keyOf(K,-1));if(I===void 0)continue;const D=this.#ae(I);this.#L?this.#Ge(I,K):this.#n[I]=K,this.#s.delete(I),this.#k(I,D),this.#T&&(this.#ne(I,K),x=!0),this.#y=!0,P.updated.push(this.#q(I))}x&&this.#re()}if(C.add&&C.add.length){const x=this.#W(C.add);for(const K of x)P.added.push(this.#q(K))}return C.remove&&C.remove.length&&H("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#Fe(),P}reload(C){this.#u.abortAll("reload"),this.#et(),this.#v&&(this.#v.destroy(),this.#v=null),this.#y=!1,this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear(),this.#g=null,this.#O=0,this.#C=0,this.#E=0,this.#T&&(this.#T=[]),this.#x=1/0,this.#R=!1,this.#w=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#A=this.#Me(),this.#be("model:changed",{reason:"reload"}),this.start()}destroy(){this.#j=!0,this.#U!==null&&(clearInterval(this.#U),this.#U=null),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#T=null,this.#u.abortAll("destroyed"),this.#et(),this.#d!==null&&(this.#Ze(this.#d),this.#d=null),this.#v&&(this.#v.destroy(),this.#v=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear()}async start(){if(this.#S||this.#j||!z(this.#e.open))return;this.#S=!0;const C=this.#u.begin("stream");this.#$(),this.#V();let P;try{P=this.#e.open({sort:this.#he("sort",[]),filters:this.#he("filters",null),quick:this.#he("quick","")||void 0,context:this.#he("context",null),signal:C.signal})}catch(K){this.#be("source:error",{error:K});return}const x=z(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#_=x;try{for(;;){const K=await x.next();if(!C.current||this.#j)return;if(K.done){this.#je();return}if(await this.#we(K.value,C),!C.current||this.#j)return;if(K.value&&K.value.done){this.#je();return}if(await this.#Le(),!C.current||this.#j)return}}catch(K){if(u(K))return;this.#be("source:error",{error:K})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#w,live:this.#O,evicted:this.#C}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#G();C&&(z(C.invalidateHandles)&&C.invalidateHandles(),z(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#Y,inline:this.#D,storeBacked:this.#L}}#we(C,P){if(!C)return;const x=C.rows;if(x&&x.length&&this.#X(x))return this.#Oe(C,P);const K=F();x&&x.length&&(this.#W(x),this.#D++),this.#z(C),this.#f+=F()-K,this.#Fe()}#z(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#X(C){if(this.#Z||this.#g)return!1;const P=this.#ye();if(!P)return!1;const x=this.#t.store;if(!x||!z(x.appendPacked))return!1;const K=this.#ve();return!K||!g(K)?(this.#Z=!0,L("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):C.length<P.threshold?!1:!this.#Se(C)}#Se(C){if(!this.#a.keyed)return!1;const P=new Set;for(let x=0;x<C.length;x++){const K=this.#a.keyOf(C[x],this.#n.length+x);if(K!=null){if(P.has(K)||this.#l.has(K))return!0;P.add(K)}}return!1}async#Oe(C,P){const x=C.rows,K=this.#ye(),I=this.#ve();let D;try{D=await K.columnize(I,x,{key:"ingest:stream",signal:P&&P.signal})}catch(X){if(u(X)||(H("source.stream.columnize","worker columnization failed; columnizing on the main thread",X),this.#Z=!0,P&&(!P.current||this.#j)))return;this.#W(x),this.#D++,this.#z(C),this.#Fe();return}if(P&&(!P.current||this.#j))return;const j=this.#t.store,E=this.#L?void 0:x,{from:$}=j.appendPacked(D,E),q=D.count|0;for(let X=0;X<q;X++){const Q=$+X,J=x[X],ne=this.#a.keyed?this.#a.keyOf(J,Q):null;if(this.#n[Q]=this.#L?p:J,this.#O++,this.#ne(Q,J),ne!==null&&this.#l.set(ne,Q),!this.#r||!this.#oe(Q))continue;const re=this.#ce(Q);this.#r.insert(re,Q),re<=this.#m&&this.#p++}this.#y=!0,this.#re(),this.#Y++,this.#z(C),this.#Fe()}#ye(){const C=this.#t.ingestWorker;return z(C)?C():null}#ve(){const C=this.#t.storeSchema;return z(C)?C():null}#W(C){const P=[],x=this.#t.store,K=new Array(C.length),I=[],D=new Set;for(let E=0;E<C.length;E++){const $=this.#a.keyed?this.#a.keyOf(C[E],this.#n.length+I.length):null;K[E]=$,!($!==null&&(this.#l.has($)||D.has($)))&&($!==null&&D.add($),I.push(C[E]))}let j=I.length&&x&&z(x.append)?x.append(I).from:this.#n.length;for(let E=0;E<C.length;E++){const $=C[E],q=K[E];if(q!==null&&this.#l.has(q)){const J=this.#l.get(q),ne=this.#ae(J);this.#L||(this.#n[J]=$,x&&z(x.setSource)&&x.setSource(J,$)),this.#Ge(J,$),this.#s.delete(J),this.#ne(J,$),this.#k(J,ne);continue}const X=j++;if(this.#n[X]=this.#L?p:$,this.#O++,this.#ne(X,$),q!==null&&this.#l.set(q,X),P.push(X),!this.#r||!this.#oe(X))continue;const Q=this.#ce(X);this.#r.insert(Q,X),Q<=this.#m&&this.#p++}return this.#y=!0,this.#re(),P}#Re(C){const P=this.#n[C];let x=!1;if(this.#r){const j=this.#H(C);j>=0&&j<=this.#m&&(x=!0)}else C<=this.#m&&(x=!0);const K=P===p?this.#me(C):P,I=this.#a.keyed?this.#a.keyOf(K,C):null;I!==null&&this.#l.get(I)===C&&this.#l.delete(I),this.#n[C]=void 0,this.#T&&(this.#T[C]=NaN),this.#s.delete(C);const D=this.#t.store;return D&&z(D.remove)&&D.remove(C),this.#O--,x}#re(){let C=0,P=0;const x=this.#ie();C+=x.dropped,P+=x.aboveAnchor;const K=this.#fe();C+=K.dropped,P+=K.aboveAnchor,C&&(this.#y=!0,this.#C+=C,this.#$(),this.#p-=P,this.#be("stream:evicted",{evicted:C,total:this.#C,live:this.#O}))}#fe(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#O<=C)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(C*(1-b)));let x=0,K=0;for(;this.#O>P&&this.#E<this.#n.length;){const I=this.#E++;this.#n[I]!==void 0&&(this.#Re(I)&&K++,x++)}return{dropped:x,aboveAnchor:K}}#ie(){const C=this.#te();if(!C||!this.#T||!this.#se())return{dropped:0,aboveAnchor:0};const P=Date.now()-C;let x=0,K=0,I=1/0;for(let D=this.#E;D<this.#n.length;D++){if(this.#n[D]===void 0)continue;const j=this.#T[D];if(!(Number.isNaN(j)||j===void 0)){if(j>=P){j<I&&(I=j);continue}this.#Re(D)&&K++,x++}}for(this.#x=I,this.#R=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:x,aboveAnchor:K}}#H(C){if(!this.#r)return C;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===C)return P;return-1}#$(){this.#o=this.#he("sort",[]),this.#i=this.#he("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#te()>0,P=this.#he("where",null),x=(this.#t.config||{}).hostFilter,K=!!(P&&P.active)||!!(x&&z(x.active)&&x.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#he("quick","")||K)){this.#r=null;return}this.#r=new i(Math.max(64,this.#n.length+64));for(let D=0;D<this.#n.length;D++)this.#n[D]!==void 0&&this.#oe(D)&&this.#r.insert(this.#ce(D),D)}#oe(C){const P=this.#me(C);if(this.#i&&!this.#ue(this.#i,P))return!1;const x=String(this.#he("quick","")||"").toLowerCase();if(x&&!this.#Je(P).includes(x))return!1;const K=(this.#t.config||{}).hostFilter;if(K&&z(K.active)&&K.active()&&!K.passes(this.#q(C)))return!1;const I=this.#he("where",null);if(I&&I.active){const D=this.#q(C);if(!I.passes(D.data,D.key))return!1}return!0}#ue(C,P){if(!C)return!0;const x=C;if(Array.isArray(x.conditions))return x.op==="or"?x.conditions.some(D=>this.#ue(D,P)):x.op==="not"?!x.conditions.some(D=>this.#ue(D,P)):x.conditions.every(D=>this.#ue(D,P));const K=C,I=(this.#t.compute||{}).testValue;return z(I)?!!I(this.#$e(P,K.col),K,(this.#t.config||{}).locale):(H("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#ae(C){if(!this.#r)return-1;if(!this.#o.length)return this.#H(C);let P=0,x=this.#r.length;for(;P<x;){const K=P+x>>>1;this.#Te(this.#r.at(K),C)<0?P=K+1:x=K}for(let K=P;K<this.#r.length;K++){const I=this.#r.at(K);if(I===C)return K;if(this.#Te(I,C)>0)break}return this.#H(C)}#k(C,P){if(!this.#r||!this.#o.length)return;const x=this.#oe(C);if(P>=0&&this.#r.at(P)===C)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!x)return;const K=this.#ce(C);this.#r.insert(K,C),K<=this.#m&&this.#p++}#ce(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,x=this.#r.length;for(;P<x;){const K=P+x>>>1;this.#Te(C,this.#r.at(K))<0?x=K:P=K+1}return P}#Te(C,P){const x=this.#me(C),K=this.#me(P);for(const I of this.#o){const D=this.#Ke(I.col),j=this.#$e(x,I.col),E=this.#$e(K,I.col),q=(D&&D.value&&z(D.value.compare)?D.value.compare:B)(j,E);if(q!==0)return I.dir==="desc"?-q:q}return 0}#je(){this.#w=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:w;!this.#L&&this.#n.length<C&&(this.#g=c({mode:"memory",rows:this.#n},this.#t),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#v&&(this.#v.destroy(),this.#v=null)),this.#Fe(),this.#be("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#Fe(){this.#d!==null||this.#j||(this.#d=this.#Ve(()=>{this.#d=null,this.#h++;const C=this.#p;this.#p=0,this.#f=0,this.#be("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#be("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#m})}))}#Le(){return this.#h===0||this.#f<this.#xe()?Promise.resolve():(this.#f=0,new Promise(C=>{const P=(this.#t.scheduler||{}).idle;z(P)?P(()=>C()):U(()=>C())}))}#xe(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:m}#Ve(C){const P=this.#t.scheduler||{};return z(P.frame)?P.frame(C):W(C)}#Ze(C){const P=this.#t.scheduler||{};z(P.cancel)?P.cancel(C):_(C)}#me(C){const P=this.#n[C];if(P!==void 0&&P!==p)return P;if(P===void 0)return;const x=this.#t.store;return x&&z(x.source)?x.source(C):void 0}#Ge(C,P){const x=this.#t.store;if(!x||!z(x.set))return;const K=this.#ve();if(Array.isArray(K))for(const I of K){if(!I||!I.id)continue;const D=z(I.read)?I.read:j=>k(j,I.field||I.id);x.set(I.id,C,D(P))}}#q(C){let P=this.#s.get(C);return P||(P=this.#a.leaf(this.#me(C),C),this.#s.set(C,P)),P}#$e(C,P){const x=this.#Ke(P);return x&&z(x.getValue)?x.getValue(C):C?.[P]}#Je(C){const P=this.#t.columns,x=P&&z(P.all)?P.all():[],K=[];for(const I of x){const D=z(I.getValue)?I.getValue(C):void 0;D!=null&&D!==""&&K.push(String(D))}return K.join(" ").toLowerCase()}#Ke(C){const P=this.#t.columns;return P&&z(P.get)?P.get(C):void 0}#et(){const C=this.#_;if(this.#_=null,C&&z(C.return))try{C.return()}catch{}}#Me(){return f({context:this.#he("context",null)})}#he(C,P){const x=this.#t.state;if(x&&z(x[C])){const K=x[C]();return K??P}return P}#be(C,P){const x=this.#t.emit;z(x)&&x(C,P)}}}),ve("packages/core/src/source/url.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isObject,F=Z.isFunction,W=Z.getPath,U=V("packages/core/src/source/abort.js").isAbortError,B=500,H=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),L=Symbol("lattice.url.skip");function k(g,w={}){const p=z(w)?w:{},m=F(p.fetch)?p.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,b=p.format==="json"||p.format==="ndjson"?p.format:void 0,v=typeof p.rowsPath=="string"&&p.rowsPath?p.rowsPath:void 0,l=F(p.map)?p.map:void 0,a=z(p.headers)?p.headers:void 0,O=Number.isFinite(p.batchSize)&&p.batchSize>0?Math.floor(p.batchSize):B,T=p.lenient===!0,A=Number.isFinite(p.poll)&&p.poll>0?Math.floor(p.poll):void 0,M=typeof g=="string"&&g.length>0;M||N("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(x={}){if(!M)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const K=x&&x.signal;let I;try{I=await m(g,a?{signal:K,headers:a}:{signal:K})}catch(E){throw U(E)?E:new Error(`[lattice] createUrlSource: request to ${g} failed — ${E&&E.message||E}`)}if(!I||!I.ok){const E=I?I.status:"no response";throw new Error(`[lattice] createUrlSource: ${E} for ${g}`)}const D=S(g,b,I),j=I.body&&F(I.body.getReader)?I.body.getReader():null;try{if(!j){const q=await I.text();(D||o(q,g))==="ndjson"?yield*c(null,null,q,0,I,g,O,T):yield*s(q,g,v,l);return}const E=new TextDecoder("utf-8");if(D==="json"){yield*s(await i(j,E,""),g,v,l);return}if(D==="ndjson"){yield*c(j,E,"",0,I,g,O,T);return}const $=await r(j,E,g);$.format==="json"?yield*s(await i(j,E,$.seed),g,v,l):yield*c(j,E,$.seed,$.bytes,I,g,O,T)}finally{if(j&&F(j.cancel))try{await j.cancel()}catch{}}}const P={mode:"stream",open:C,autoStart:p.autoStart!==!1};return A!==void 0&&(P.poll=A),Number.isFinite(p.maxRows)&&(P.maxRows=p.maxRows),Number.isFinite(p.maxAge)&&(P.maxAge=p.maxAge),(typeof p.ageBy=="string"||F(p.ageBy))&&(P.ageBy=p.ageBy),Number.isFinite(p.coalesceMs)&&(P.coalesceMs=p.coalesceMs),Number.isFinite(p.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=p.promoteToMemoryBelow),P}function S(g,w,p){if(w)return w;const m=y(g);if(m)return m;const b=p&&p.headers&&F(p.headers.get)?p.headers.get("content-type"):null;return u(b)}function y(g){const w=String(g).split(/[?#]/)[0].toLowerCase();if(w.endsWith(".ndjson")||w.endsWith(".jsonl"))return"ndjson";if(w.endsWith(".json"))return"json"}function u(g){if(!g)return;const w=g.split(";")[0].trim().toLowerCase();if(H.has(w))return"ndjson";if(w==="application/json"||w==="text/json"||w.endsWith("+json"))return"json"}function o(g,w){const p=g.replace(/^\s+/,""),m=t(p);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${w} — pass opts.format: 'json' | 'ndjson'.`);return m}async function r(g,w,p){let m="",b=0;for(;;){const{value:l,done:a}=await g.read();if(l&&(b+=l.byteLength,m+=w.decode(l,{stream:!0})),a){m+=w.decode();break}const O=m.replace(/^\s+/,"");if(O){if(O[0]==="[")return{format:"json",seed:m,bytes:b};if(O[0]!=="{"||m.indexOf(`
|
|
8
8
|
`)!==-1)break}}const v=t(m.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${p} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:m,bytes:b}}function t(g){if(!g||g[0]==="[")return"json";if(g[0]!=="{")return"error";const w=g.indexOf(`
|
|
9
9
|
`);if(w===-1)return"json";let p=g.slice(0,w);return p.endsWith("\r")&&(p=p.slice(0,-1)),n(p)?"ndjson":"json"}function n(g){try{return JSON.parse(g),!0}catch{return!1}}async function i(g,w,p){let m=p;for(;;){const{value:b,done:v}=await g.read();if(b&&(m+=w.decode(b,{stream:!0})),v)break}return m+=w.decode(),m}function*s(g,w,p,m){let b;try{b=JSON.parse(g)}catch(l){throw new Error(`[lattice] createUrlSource: ${w} is not valid JSON — ${l.message}`)}let v=p!==void 0?W(b,p):b;if(m&&(v=m(v)),!Array.isArray(v)){const l=p!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${w} did not resolve to an array${l}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*c(g,w,p,m,b,v,l,a){const O=h(b);let T=p||"",A=m||0,M=0,C=0,P=[];function*x(){let I;for(;(I=T.indexOf(`
|
|
@@ -51,6 +51,6 @@ ${ne}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
51
51
|
`,b),T=p.slice(a,O),A=T.split(`
|
|
52
52
|
`);let M=0;const C=A.map(P=>{if(!g)return M+=v.length,v+P;if(P.startsWith(v))return M-=v.length,P.slice(v.length);const x=P.replace(/^[ \t]/,"");return M-=P.length-x.length,x}).join(`
|
|
53
53
|
`);return C===T?!1:(w.value=p.slice(0,a)+C+p.slice(O),this.#r(Math.max(a,m+(g?-v.length:v.length)),Math.max(a,b+M)),this.revalidate(),!0)}#r(g,w){const p=this.input;p&&(p.selectionStart=g,p.selectionEnd=w===void 0?g:w,U(p.setSelectionRange)&&p.setSelectionRange(p.selectionStart,p.selectionEnd))}format(g){const w=this.input;if(!w||this.language!=="json")return!1;const p=r(w.value);if(!p.ok)return this.revalidate(),!1;if(p.value===null&&w.value.trim()==="")return!1;try{const m=JSON.stringify(p.value,null,g===void 0?this.indent:g);return m===void 0?!1:(w.value=m,this.#r(m.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const g=this.input?this.input.value:"",w=s(g,this.language);this.lastResult=w;const p=this.errorNode;return p&&(p.textContent=w.ok?"":c(w),p.classList.toggle(k.errorOn,!w.ok)),this.input&&(w.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),w.ok||!p?this.input.removeAttribute("aria-errormessage"):(p.id||(p.id=B("lat-err")),this.input.setAttribute("aria-errormessage",p.id))),w}text(){return this.input?this.input.value:""}readValue(){const g=this.text();if(g.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return g;const p=r(g);return p.ok?p.value:g}checkValue(g){if(this.props.allowInvalid===!0)return!0;const w=this.revalidate();return w.ok?!0:c(w)}toClipboard(){return this.text()}fromClipboard(g){const w=g==null?"":String(g);return this.input&&(this.input.value=w),this.revalidate(),w.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:w}:{ok:!0,value:L(w)}}destroy(){for(const g of this.#e)g();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const f=d}),ve("packages/dom/src/editors/unit.js",function(e,V){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,U=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/unit.js"),H=B.parseUnit,L=B.formatUnit,k=B.findUnit;function S(o,r){return L(o,r)}class y extends N{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.props,t=this.params.column&&this.params.column.dataType||null,n=t&&t.unitConfig||{};return{system:r.system||n.system||"data",unit:r.unit??n.unit,binary:r.binary===!0||r.binary===void 0&&n.binary===!0,display:r.display??n.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const r=this.props;this.opts=this.buildOptions();const t=this.symbol(),n=`${this.id}-unit`,i=F(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});i.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const s=typeof r.step=="number"?r.step:0;return s>0&&this.#e.push(W(i,"keydown",c=>{c.key==="ArrowUp"?(U(c.preventDefault)&&c.preventDefault(),this.nudge(s)):c.key==="ArrowDown"&&(U(c.preventDefault)&&c.preventDefault(),this.nudge(-s))})),this.hint=F(this.doc,"span",{class:`${z.editor}__suffix`,text:t,attrs:{id:n,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${z.editor}__unit`,children:[i,this.hint]})}symbol(){const r=k(this.opts.system,this.opts.unit);return r?r.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&U(r.select)&&r.select()}nudge(r){const t=H(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:s}=this.props;typeof i=="number"&&n<i&&(n=i),typeof s=="number"&&n>s&&(n=s),this.input&&(this.input.value=S(n,this.opts))}readValue(){const r=this.input?this.input.value:"";if(String(r).trim()==="")return null;const t=H(r,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:n,max:i}=this.props;let s=t;return typeof n=="number"&&s<n&&(s=n),typeof i=="number"&&s>i&&(s=i),s}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:n}=this.props;if(typeof t=="number"&&r<t)return`Must be ${this.describe(t)} or more`;if(typeof n=="number"&&r>n)return`Must be ${this.describe(n)} or less`}return!0}describe(r){return L(r,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return L(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(r){const t=r==null?"":String(r);if(t.trim()==="")return{ok:!0,value:null};const n=H(t,this.opts),i=n===null?NaN:n,s=this.checkValue(i);return s!==!0?{ok:!1,message:s}:{ok:!0,value:i}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const u=y}),ve("packages/dom/src/editors/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,_=V("packages/core/src/internal/util.js"),U=_.isFunction,B=_.uid,H=V("packages/core/src/columns/types/radix.js"),L=H.compileRadixFormat,k=H.compileRadixParse,S=H.normaliseRadixOptions,y=H.radixRange,u=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),o=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),r=new Map;function t(c){const d=c||"";let f=r.get(d);if(f)return f;try{f=new Intl.NumberFormat(c||void 0,{maximumFractionDigits:0})}catch{f={format:h=>String(h)}}return r.set(d,f),f}function n(c,d){const f=d||{},h={};if(c){for(const w of o)c[w]!==void 0&&(h[w]=c[w]);const g=y(c.bitWidth??null,c.signed!==!1);typeof c.min=="number"&&c.min>g.min&&(h.min=c.min),typeof c.max=="number"&&c.max<g.max&&(h.max=c.max)}for(const g of o)f[g]!==void 0&&(h[g]=f[g]);return typeof f.min=="number"&&(h.min=f.min),typeof f.max=="number"&&(h.max=f.max),S(h)}class i extends N{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const d=this.params.column&&this.params.column.dataType;this.options=n(d&&d.radix||null,this.props),this.format=L(this.options),this.parse=k(this.options);const f=F(this.doc,"input",{class:z.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}});f.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(f.value=this.params.key),this.input=f;const h=F(this.doc,"span",{class:u.hint,attrs:{"aria-live":"polite"}});this.hint=h,this.#e.push(W(f,"input",()=>this.refresh())),this.#e.push(W(f,"keydown",w=>this.#n(w)));const g=F(this.doc,"div",{class:u.root,children:[f,h]});return this.refresh(),g}focusTarget(){return this.input}attached(){super.attached();const d=this.input;d&&!this.params.key&&this.props.selectOnFocus!==!1&&U(d.select)&&d.select()}#t(d){return d.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(d)}#n(d){const f=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;d.key==="ArrowUp"?(U(d.preventDefault)&&d.preventDefault(),this.nudge(f)):d.key==="ArrowDown"&&(U(d.preventDefault)&&d.preventDefault(),this.nudge(-f))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(d){const{min:f,max:h}=this.options;return d<f?f:d>h?h:d}evaluate(){const d=this.input?String(this.input.value):"";if(d.trim()==="")return{value:null,message:null};const f=this.parse(d);return f.ok?{value:this.mode()==="clamp"?this.clamp(f.value):f.value,message:null}:this.mode()==="clamp"&&typeof f.value=="number"&&(f.reason==="range"||f.reason==="negative")?{value:this.clamp(f.value),message:null}:{value:NaN,message:this.messageFor(f.reason)}}messageFor(d){const f=this.options;return d==="negative"?`This column holds an unsigned ${f.bitWidth}-bit pattern; enter ${this.format(0)} or more`:d==="range"?`Must be between ${this.format(f.min)} and ${this.format(f.max)}`:`Enter a ${f.name} value, e.g. ${this.format(f.radix===2?5:26)}`}refresh(){const{value:d,message:f}=this.evaluate();if(this.input&&this.input.classList&&(f?this.input.classList.add(z.invalid):this.input.classList.remove(z.invalid),this.input.setAttribute("aria-invalid",f?"true":"false"),f&&this.hint?(this.hint.id||(this.hint.id=B("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(f){this.hint.textContent=f,this.hint.classList&&this.hint.classList.add(u.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(u.hintInvalid),this.hint.textContent=d===null?"":`= ${t(this.params.locale).format(d)}`}}nudge(d){if(!this.input)return;const f=this.parse(this.input.value);let h;typeof f.value=="number"?h=f.value:typeof this.params.value=="number"?h=this.params.value:h=0,this.input.value=this.format(this.clamp(h+d)),this.refresh()}readValue(){return this.evaluate().value}checkValue(d){return d===null?!0:typeof d!="number"||Number.isNaN(d)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&d<0?this.messageFor("negative"):this.mode()==="reject"&&(d<this.options.min||d>this.options.max)?this.messageFor("range"):!0}toClipboard(){const d=this.readValue();return d===null||Number.isNaN(d)?this.input?String(this.input.value):"":this.format(d)}fromClipboard(d){const f=d==null?"":String(d);if(f.trim()==="")return{ok:!0,value:null};const h=this.parse(f);let g;if(h.ok)g=h.value;else if(this.mode()==="clamp"&&typeof h.value=="number"&&(h.reason==="range"||h.reason==="negative"))g=this.clamp(h.value);else return{ok:!1,message:this.messageFor(h.reason)};const w=this.checkValue(g);return w!==!0?{ok:!1,message:w}:{ok:!0,value:g}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const s=i}),ve("packages/dom/src/editors/segmented.js",function(e,V){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,_=Z.keyOf,U=Z.normaliseLookup,B=Z.documentFor,H=Z.lookupFor,k=V("packages/dom/src/editors/select.js").SelectEditor,y=V("packages/core/src/internal/util.js").isFunction,o=V("packages/dom/src/cell/icons.js").createIcon,r=6;class t extends N{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(c){const d=c||{},f=n(d),h=H(d,f,{colId:d.column&&(d.column.id||d.column.field)}),g=Number(f.max??r),w=h.options().length;if(Number.isFinite(g)&&w>g){const p=new k;p.init(d),this.#e=p,this.params=d,this.doc=B(d),this.props=f,this.lookup=h,this.popup=p.popup;return}super.init(d),(!this.lookup||!this.lookup.options().length)&&(this.lookup=h)}usesFallback(){return this.#e!==null}build(){const c=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const d=F(c,"div",{class:`${z.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 f=0;f<this.options.length;f++)d.appendChild(this.buildSegment(this.options[f],f));return this.props.allowClear===!0&&d.appendChild(this.buildClear()),this.#t.push(W(d,"keydown",f=>this.onKeyDown(f))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),d}buildSegment(c,d){const f=this.doc,h=F(f,"button",{class:`${z.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":d,"data-variant":c.variant??null,"aria-disabled":c.disabled===!0?"true":null}});return c.icon&&h.appendChild(o(f,c.icon,{className:z.icon})),h.appendChild(F(f,"span",{class:`${z.editor}__segment-label`,text:c.label})),this.#t.push(W(h,"mousedown",g=>{g&&y(g.preventDefault)&&g.preventDefault(),c.disabled!==!0&&(this.focused=d,this.select(d,{commit:!0}))})),this.segments.push(h),h}buildClear(){const c=F(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(c,"mousedown",d=>{d&&y(d.preventDefault)&&d.preventDefault(),this.clearSelection()})),c}indexOf(c){if(c==null)return-1;const d=_(c);for(let f=0;f<this.options.length;f++)if(_(this.options[f].id)===d)return f;return-1}paint(){for(let c=0;c<this.segments.length;c++){const d=c===this.indexOf(this.selected),f=this.segments[c];f.setAttribute("aria-checked",d?"true":"false"),f.setAttribute("tabindex",c===this.focused?"0":"-1"),f.classList.toggle(`${z.editor}__segment--active`,d),f.classList.toggle(`${z.editor}__segment--disabled`,this.options[c].disabled===!0)}}select(c,d){const f=this.options[c];!f||f.disabled===!0||(this.selected=f.id,this.paint(),d&&d.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(c){const d=this.segments.length;if(!d)return;let f=this.focused;for(let h=0;h<d;h++)if(f=(f+c+d)%d,this.options[f].disabled!==!0){this.focusAt(f);return}}focusAt(c){if(c<0||c>=this.segments.length)return;this.focused=c,this.paint();const d=this.segments[c];d&&y(d.focus)&&d.focus()}edgeIndex(c){const d=this.options.length;for(let f=0;f<d;f++){const h=c===1?f:d-1-f;if(this.options[h].disabled!==!0)return h}return-1}onKeyDown(c){const d=()=>{y(c.preventDefault)&&c.preventDefault()};switch(c.key){case"ArrowRight":case"ArrowDown":d(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":d(),this.moveFocus(-1);break;case"Home":d(),this.focusAt(this.edgeIndex(1));break;case"End":d(),this.focusAt(this.edgeIndex(-1));break;case"Enter":d(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":d(),this.select(this.focused);break;case"Escape":d(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(d(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(c){return c==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(c)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(c)}" 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 c=this.indexOf(this.selected);return this.segments[c>=0?c:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const c=this.lookup.ready();!c||!y(c.then)||c.then(()=>{if(!super.element()||this.options.length)return;const d=super.element();this.options=this.lookup.options();for(let f=0;f<this.options.length;f++)d.appendChild(this.buildSegment(this.options[f],f));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(c){return this.#e?this.#e.validate(c):super.validate(c)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(c){return this.#e?this.#e.fromClipboard(c):super.fromClipboard(c)}destroy(){for(const c of this.#t)c();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function n(s){return{...s.column&&s.column.edit&&s.column.edit.props||{},...s.props||{}}}const i=t}),ve("packages/dom/src/editors/rating.js",function(e,V){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,U=V("packages/dom/src/cell/icons.js").createIcon,B=V("packages/dom/src/cell/renderers/rating.js"),H=B.ratingFills,L=B.fillState,k=B.ratingText,S=B.clampRating,y=B.DEFAULT_RATING_ICON,u=B.DEFAULT_RATING_MAX,r=V("packages/core/src/internal/util.js").isFunction;class t extends N{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const c=Math.floor(Number(this.props.max??u));return Number.isFinite(c)&&c>0?c:u}step(){return this.props.allowHalf===!0?.5:1}build(){const c=this.doc,d=this.max();this.rating=n(this.params.value,d,this.props.allowHalf===!0);const f=F(c,"div",{class:`${z.editor}__rating`}),h=F(c,"div",{class:`${z.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(d),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let w=0;w<d;w++)h.appendChild(this.buildItem(w));f.appendChild(h),this.slider=h;const g=F(c,"span",{class:`${z.editor}__rating-value`});return f.appendChild(g),this.readout=g,this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(W(h,"keydown",w=>this.onKeyDown(w))),this.props.hoverPreview!==!1&&this.#e.push(W(h,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),d)),this.paint(),f}buildItem(c){const d=this.doc,f=String(this.props.icon??y),h=F(d,"span",{class:`${z.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[U(d,f,{className:z.icon})]}),g=F(d,"span",{class:`${z.editor}__rating-item`,attrs:{"data-index":c,"data-icon":f,"aria-hidden":"true"},children:[U(d,f,{className:z.icon}),h]});return this.fills.push(h),this.#e.push(W(g,"mousedown",w=>{w&&r(w.preventDefault)&&w.preventDefault(),this.setRating(this.ratingAt(c,w),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(g,"mousemove",w=>{const p=this.ratingAt(c,w);p!==this.preview&&(this.preview=p,this.paint())})),this.items.push(g),g}buildClear(){const c=F(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(c,"mousedown",d=>{d&&r(d.preventDefault)&&d.preventDefault(),this.setRating(null)})),c}ratingAt(c,d){if(this.props.allowHalf!==!0)return c+1;const f=this.items[c],h=f&&Number(f.offsetWidth),g=d&&Number(d.offsetX);return!Number.isFinite(h)||h<=0||!Number.isFinite(g)?c+1:g*2<h?c+.5:c+1}focusTarget(){return this.slider}setRating(c,d){this.rating=c===null?null:S(c,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),d&&d.commit&&this.commit()}nudge(c){const d=this.rating===null?0:this.rating;this.setRating(d+c)}paint(){const c=this.max(),d=this.props.allowHalf===!0,f=this.preview===null?this.rating:this.preview,h=H(f===null?0:f,c,{allowHalf:d});for(let p=0;p<this.items.length;p++){const m=L(h[p]);this.items[p].setAttribute("data-fill",m),this.items[p].classList.toggle(`${z.editor}__rating-item--filled`,m!=="empty"),this.fills[p]&&this.fills[p].style.setProperty("--lat-rating-fill",`${(h[p]*100).toFixed(2)}%`)}const g=f===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:k(f),max:c}),w=this.slider;w&&(w.setAttribute("aria-valuenow",f===null?"0":String(f)),w.setAttribute("aria-valuetext",g),w.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=g)}onKeyDown(c){const d=()=>{r(c.preventDefault)&&c.preventDefault()},f=this.step();if(/^[0-9]$/.test(c.key)){d(),this.setRating(Math.min(Number(c.key),this.max()));return}switch(c.key){case"ArrowRight":case"ArrowUp":d(),this.nudge(f);break;case"ArrowLeft":case"ArrowDown":d(),this.nudge(-f);break;case"Home":d(),this.setRating(0);break;case"End":d(),this.setRating(this.max());break;case"Enter":d(),this.commit();break;case"Escape":d(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(d(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(c){if(c==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof c!="number"||!Number.isFinite(c))return"Enter a rating";const d=this.max();return c<0?"Must be 0 or more":c>d?`Must be ${d} or less`:this.props.allowHalf!==!0&&!Number.isInteger(c)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":k(this.rating)}fromClipboard(c){const d=String(c??"").trim();if(d==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const f=Number(d);if(!Number.isFinite(f))return{ok:!1,message:`"${d}" is not a rating`};const h=this.checkValue(f);return h!==!0?{ok:!1,message:h}:{ok:!0,value:f}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function n(s,c,d){if(s==null||s==="")return null;const f=Number(s);return Number.isFinite(f)?S(f,c,d,!1):null}const i=t}),ve("packages/dom/src/editors/slider.js",function(e,V){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,_=V("packages/dom/src/editors/number.js"),U=_.parseNumberText,B=_.presentNumber,L=V("packages/core/src/internal/util.js").isFunction,k=0,S=100;class y extends N{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const i=Number(this.props.min??k);return Number.isFinite(i)?i:k}max(){const i=Number(this.props.max??S);return Number.isFinite(i)?i:S}step(){const i=Number(this.props.step??1);return Number.isFinite(i)&&i>0?i:1}build(){const i=this.doc,s=this.min(),c=this.max(),d=this.step(),f=r(this.props.marks);this.marks=f,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const h=F(i,"div",{class:`${z.editor}__slider`});this.root=h;const g=F(i,"input",{class:`${z.editor}__slider-input`,attrs:{type:"range",min:String(s),max:String(c),step:String(d),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:f.length?`${this.id}-marks`:null}});if(this.range=g,h.appendChild(g),f.length){const p=F(i,"datalist",{attrs:{id:`${this.id}-marks`}}),m=F(i,"div",{class:`${z.editor}__slider-marks`});for(const b of f){p.appendChild(F(i,"option",{attrs:{value:String(b.value),label:b.label}}));const v=F(i,"span",{class:`${z.editor}__slider-mark`,text:b.label,attrs:{"data-value":String(b.value)}});v.style&&L(v.style.setProperty)&&v.style.setProperty("--lat-slider-mark",`${(u(b.value,s,c)*100).toFixed(2)}%`),m.appendChild(v)}h.appendChild(p),h.appendChild(m)}const w=F(i,"input",{class:`${z.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=w,h.appendChild(w),this.props.showValue!==!1){const p=F(i,"span",{class:`${z.editor}__slider-value`});h.appendChild(p),this.readout=p}return this.#e.push(W(g,"input",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"change",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"keydown",p=>this.onKeyDown(p))),this.#e.push(W(w,"input",()=>this.onFieldInput())),this.#e.push(W(w,"change",()=>this.paint())),this.#e.push(W(w,"keydown",p=>this.onKeyDown(p))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(w.value=this.params.key,this.onFieldInput()),this.paint(),h}focusTarget(){return this.field}attached(){super.attached();const i=this.field;i&&!this.params.key&&this.props.selectOnFocus!==!1&&L(i.select)&&i.select()}snap(i){if(!Number.isFinite(i))return this.min();const s=this.min(),c=this.max(),d=this.step(),f=Math.min(Math.max(i,s),c),h=s+Math.round((f-s)/d)*d,g=o(d),w=g>0?Number(h.toFixed(g)):Math.round(h);return Math.min(Math.max(w,s),c)}setAmount(i,s){this.amount=i===null?null:this.snap(i),this.paint(s)}onFieldInput(){const i=this.field?String(this.field.value):"";if(i.trim()===""){this.amount=null,this.paint("field");return}const s=U(i,this.params.locale);if(s===null||Number.isNaN(s)){this.paint("field");return}this.setAmount(s,"field")}paint(i){const s=this.min(),c=this.max(),d=this.amount,f=d===null?s:d;this.range&&i!=="range"&&(this.range.value=String(f)),this.field&&i!=="field"&&(this.field.value=d===null?"":B(d,this.props));const h=this.root;h&&h.style&&L(h.style.setProperty)&&h.style.setProperty("--lat-slider-pos",`${(u(f,s,c)*100).toFixed(2)}%`),h&&h.setAttribute&&h.setAttribute("data-empty",d===null?"true":"false");const g=this.labelFor(d);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",g),this.readout&&(this.readout.textContent=g)}labelFor(i){if(i===null)return String(this.props.emptyLabel??"");const s=this.marks.find(d=>d.value===i),c=B(i,this.props);return s&&s.label!==c?`${c} (${s.label})`:c}onKeyDown(i){if(i.key==="Escape"){L(i.preventDefault)&&i.preventDefault(),this.cancel();return}if(i.key==="Enter"){L(i.preventDefault)&&i.preventDefault(),this.commit();return}i.key==="Tab"&&this.commit()}readValue(){const i=this.field?String(this.field.value):"";if(i.trim()==="")return null;const s=U(i,this.params.locale);return s===null||Number.isNaN(s)?NaN:this.snap(s)}checkValue(i){return i==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof i!="number"||Number.isNaN(i)?"Enter a number":i<this.min()?`Must be ${this.min()} or more`:i>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(i){const s=String(i??"").trim();if(s==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const c=U(s,this.params.locale);if(c===null||Number.isNaN(c))return{ok:!1,message:"Enter a number"};const d=this.snap(c),f=this.checkValue(d);return f!==!0?{ok:!1,message:f}:{ok:!0,value:d}}destroy(){for(const i of this.#e)i();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function u(n,i,s){const c=s-i;return!Number.isFinite(c)||c===0?0:Math.min(1,Math.max(0,(Number(n)-i)/c))}function o(n){if(!Number.isFinite(n))return 0;const i=String(n),s=i.indexOf("e");if(s>=0){const d=i.slice(0,s),f=d.indexOf("."),h=f<0?0:d.length-f-1;return Math.min(15,Math.max(0,h-Number(i.slice(s+1))))}const c=i.indexOf(".");return c<0?0:Math.min(15,i.length-c-1)}function r(n){if(!n)return[];const i=[];if(Array.isArray(n)){for(const s of n){if(s&&typeof s=="object"){const d=Number(s.value);Number.isFinite(d)&&i.push({value:d,label:String(s.label??d)});continue}const c=Number(s);Number.isFinite(c)&&i.push({value:c,label:String(c)})}return i}if(typeof n=="object")for(const[s,c]of Object.entries(n)){const d=Number(s);Number.isFinite(d)&&i.push({value:d,label:String(c)})}return i}const t=y}),ve("packages/dom/src/editors/colour.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,_=V("packages/dom/src/cell/renderers/colour.js"),U=_.normaliseColour,B=_.parseColour,L=V("packages/core/src/internal/util.js").isFunction,k=Object.freeze(["neutral","info","success","warning","danger","accent"]),S=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(i){if(i==null)return null;if(typeof i=="object"){const d=i,f=y(d.token??d.value??d.colour??d.color);return f?{...f,label:d.label==null?f.label:String(d.label)}:null}const s=String(i).trim();if(s==="")return null;const c=U(s);return c?{token:null,hex:c,label:c}:Object.hasOwn(S,s)?{token:s,hex:S[s],label:s}:null}function u(i,s){const c=i&&i.ownerDocument,d=c&&c.defaultView;if(!d||!L(d.getComputedStyle))return null;try{const f=d.getComputedStyle(i);return!f||!L(f.getPropertyValue)?null:U(String(f.getPropertyValue(`--lattice-variant-${s}-solid`)).trim())}catch{return null}}class o extends N{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const s=this.doc;this.swatches=r(this.props.swatches);const c=F(s,"div",{class:`${z.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=F(s,"span",{class:`${z.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),c.appendChild(this.preview),this.swatches.length){const f=F(s,"div",{class:`${z.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let h=0;h<this.swatches.length;h++)f.appendChild(this.buildSwatch(this.swatches[h],h));c.appendChild(f)}this.native=F(s,"input",{class:`${z.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),c.appendChild(this.native),this.hex=F(s,"input",{class:`${z.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),c.appendChild(this.hex),this.props.allowClear===!0&&c.appendChild(this.buildClear()),this.#e.push(W(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.hex,"input",()=>this.paint())),this.#e.push(W(this.hex,"change",()=>this.paint())),this.#e.push(W(this.hex,"keydown",f=>this.onKeyDown(f))),this.#e.push(W(c,"keydown",f=>this.onKeyDown(f)));const d=U(this.params.value,{alpha:this.alpha()});return this.hex.value=d===null?this.params.value==null?"":String(this.params.value):d,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),c}buildSwatch(s,c){const d=F(this.doc,"button",{class:`${z.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":s.label,"data-index":c,"data-variant":s.token}});return s.token||t(d,s.hex),this.#e.push(W(d,"mousedown",f=>{f&&L(f.preventDefault)&&f.preventDefault(),this.setColour(this.swatches[c].hex)})),this.buttons.push(d),d}buildClear(){const s=F(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(s,"mousedown",c=>{c&&L(c.preventDefault)&&c.preventDefault(),this.setColour(null)})),s}focusTarget(){return this.hex}attached(){super.attached();for(let s=0;s<this.swatches.length;s++){const c=this.swatches[s];if(!c.token)continue;const d=u(this.buttons[s]||this.element(),c.token);d&&(c.hex=d)}this.paint()}setColour(s){const c=s===null?null:U(s,{alpha:this.alpha()});this.hex&&(this.hex.value=c===null?"":c),this.paint()}current(){const s=this.hex?String(this.hex.value).trim():"";return s===""?null:U(s,{alpha:this.alpha()})}paint(){const s=this.current(),c=s===null?null:s.slice(0,7);t(this.preview,c),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",s===null?"true":"false"),this.native&&(this.native.value=c===null?"#000000":c);for(let d=0;d<this.buttons.length;d++){const f=s!==null&&this.swatches[d].hex.toLowerCase()===s.toLowerCase();this.buttons[d].setAttribute("aria-checked",f?"true":"false"),this.buttons[d].classList.toggle(`${z.editor}__colour-swatch--selected`,f),this.swatches[d].token||t(this.buttons[d],this.swatches[d].hex)}}onKeyDown(s){if(s.key==="Escape"){L(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){L(s.preventDefault)&&s.preventDefault(),this.commit();return}s.key==="Tab"&&this.commit()}readValue(){const s=this.hex?String(this.hex.value).trim():"";if(s==="")return null;const c=U(s,{alpha:this.alpha()});return c===null?s:c}checkValue(s){if(s==null||s==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const c=B(s);return c?!this.alpha()&&c.a<1?"This column does not accept transparency":!0:`"${String(s)}" is not a colour`}toClipboard(){const s=this.current();return s===null?"":s}fromClipboard(s){const c=String(s??"").trim();if(c==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const d=U(c,{alpha:this.alpha()});if(d===null)return{ok:!1,message:`"${c}" is not a colour`};const f=this.checkValue(d);return f!==!0?{ok:!1,message:f}:{ok:!0,value:d}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function r(i){const s=Array.isArray(i)&&i.length?i:i===!1?[]:k,c=[];for(const d of s){const f=y(d);f&&c.push(f)}return c}function t(i,s){const c=i&&i.style;if(c){if(s===null){L(c.removeProperty)&&c.removeProperty("--lat-swatch");return}L(c.setProperty)&&c.setProperty("--lat-swatch",s)}}const n=o}),ve("packages/dom/src/editors/treeselect.js",function(e,V){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const N=V("packages/dom/src/editors/select.js").SelectEditorBase,F=V("packages/dom/src/cell/icons.js").createIcon,W=V("packages/dom/src/editors/common.js"),_=W.CLS,U=W.el,B=W.on,H=W.clear,L=W.keyOf,k=W.rawOptions,S=W.lookupKey,y=V("packages/core/src/internal/util.js"),u=y.isFunction,o=y.isObject,r="\0";class t extends N{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 s=super.build();return s.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),s}initSelection(){this.rebuild(),this.selected=this.params.value??null;const s=this.nodeById(this.selected);if(s)for(let c=s.parent;c;c=c.parent)this.expanded.add(c.key)}rebuild(){const s=k(this.params,this.props),c=this.props.keys||{},d=c.value||S(this.params,"valueKey")||"id",f=c.label||S(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const h of s){if(!o(h)){this.addNode(null,String(h??""),h,null);continue}Array.isArray(h.path)&&h.path.length?this.addByPath(h,d,f):this.addByChildren(h,null,d,f)}if(this.props.defaultExpanded===!0)for(const h of this.nodes.keys())this.expanded.add(h)}addNode(s,c,d,f){const h=s?`${s.key}${r}${c}`:c;let g=this.nodes.get(h);return g?g.id===void 0&&d!==void 0&&(g.id=d):(g={id:d,label:c,key:h,parent:s,children:[],depth:s?s.depth+1:0,disabled:!1},this.nodes.set(h,g),(s?s.children:this.roots).push(g)),f&&(f.disabled===!0&&(g.disabled=!0),f.icon!==void 0&&(g.icon=f.icon),f.variant!==void 0&&(g.variant=f.variant)),g}addByPath(s,c,d){const f=s.path;let h=null;for(let g=0;g<f.length;g++){const w=g===f.length-1,p=String(f[g]),m=w&&s[d]!=null?String(s[d]):p,b=this.addNode(h,p,w?s[c]:void 0,w?s:null);w&&(b.label=m),h=b}}addByChildren(s,c,d,f){const h=s[d],g=s[f]!=null?String(s[f]):String(h??""),w=this.addNode(c,g,h,s),p=Array.isArray(s.children)?s.children:[];for(const m of p)o(m)?this.addByChildren(m,w,d,f):this.addNode(w,String(m??""),m,null)}nodeById(s){if(s==null)return;const c=L(s);for(const d of this.nodes.values())if(d.id!==void 0&&L(d.id)===c)return d}filterOptions(s){const c=String(s||"").trim().toLowerCase(),d=c!=="";this.matched=d?this.computeMatches(c):new Set;const f=[],h=g=>{for(const w of g)d&&!this.matched.has(w.key)||(f.push(w),w.children.length&&(d||this.expanded.has(w.key))&&h(w.children))};return h(this.roots),f}computeMatches(s){const c=new Set,d=f=>{let h=f.label.toLowerCase().includes(s);for(const g of f.children)d(g)&&(h=!0);return h&&c.add(f.key),h};for(const f of this.roots)d(f);return c}repaint(s){if(this.refreshOptions(),!s||!this.list)return;const c=this.visible.findIndex(d=>d.key===s);c>=0&&this.list.setActive(c)}isBranch(s){return!!s&&s.children.length>0}isSelectable(s){return!s||s.disabled||s.id===void 0||s.id===null?!1:!(this.leavesOnly&&this.isBranch(s))}setExpanded(s,c){this.isBranch(s)&&(c?this.expanded.add(s.key):this.expanded.delete(s.key),this.repaint(s.key))}choose(s){if(s){if(!this.isSelectable(s)){this.isBranch(s)&&this.setExpanded(s,!this.expanded.has(s.key));return}this.selected=s.id,this.input&&(this.input.value=""),this.query="",this.repaint(s.key),this.paintDisplay(),this.commit()}}isSelected(s){return this.selected!=null&&s&&s.id!==void 0&&L(s.id)===L(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(s){if(s==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const c=this.nodeById(s);return c&&this.isSelectable(c)?!0:c?`"${c.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(s)}" is not a valid option`}renderOption(s,c,d){H(c),c.setAttribute("role","treeitem"),c.setAttribute("aria-level",String(s.depth+1)),c.setAttribute("data-depth",String(s.depth));const f=U(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<s.depth;b++)f.appendChild(U(this.doc,"span",{class:"lat-tree__guide"}));c.appendChild(f);const h=this.isBranch(s),g=h&&(this.expanded.has(s.key)||this.query.trim()!==""),w=h?g?"chevronDown":"chevronRight":"blank",p=U(this.doc,"span",{class:h?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[F(this.doc,w,{className:_.icon})],attrs:{"data-icon":h?w:null,"aria-hidden":"true"}});h&&B(p,"mousedown",b=>{u(b.preventDefault)&&b.preventDefault(),u(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(s,!this.expanded.has(s.key))}),c.appendChild(p),s.icon&&c.appendChild(F(this.doc,s.icon,{className:_.icon})),c.appendChild(U(this.doc,"span",{class:`${_.option}__label`,text:s.label})),s.variant?c.setAttribute("data-variant",s.variant):c.removeAttribute("data-variant"),h?c.setAttribute("aria-expanded",g?"true":"false"):c.removeAttribute("aria-expanded");const m=this.isSelected(s);c.classList.toggle(_.optionSelected,m),c.classList.toggle(_.optionDisabled,!this.isSelectable(s)),c.classList.toggle("lat-tree__row--branch",h),c.setAttribute("aria-selected",m?"true":"false"),this.isSelectable(s)?c.removeAttribute("aria-disabled"):c.setAttribute("aria-disabled","true")}paintDisplay(){const s=this.display;if(!s)return;if(H(s),this.selected==null){s.removeAttribute("data-variant");return}const c=this.nodeById(this.selected);if(!c){s.appendChild(U(this.doc,"span",{text:String(this.selected)}));return}c.icon&&s.appendChild(F(this.doc,c.icon,{className:_.icon})),s.appendChild(U(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(c)})),c.variant?s.setAttribute("data-variant",c.variant):s.removeAttribute("data-variant")}pathLabel(s){const c=[];for(let d=s;d;d=d.parent)c.unshift(d.label);return c.join(String(this.props.pathSeparator??" / "))}onKeyDown(s){const c=this.list,d=c&&c.active>=0?this.visible[c.active]:null;switch(s.key){case"ArrowRight":{if(u(s.preventDefault)&&s.preventDefault(),!d)return;this.isBranch(d)&&!this.expanded.has(d.key)?this.setExpanded(d,!0):this.isBranch(d)&&c&&c.setActive(Math.min(this.visible.length-1,c.active+1));return}case"ArrowLeft":{if(u(s.preventDefault)&&s.preventDefault(),!d)return;this.isBranch(d)&&this.expanded.has(d.key)?this.setExpanded(d,!1):d.parent&&this.focusNode(d.parent.key);return}case"Home":u(s.preventDefault)&&s.preventDefault(),c&&this.visible.length&&c.setActive(0);return;case"End":u(s.preventDefault)&&s.preventDefault(),c&&this.visible.length&&c.setActive(this.visible.length-1);return;default:super.onKeyDown(s)}}focusNode(s){if(!this.list)return;const c=this.visible.findIndex(d=>d.key===s);c>=0&&this.list.setActive(c)}acceptHighlight(s){const c=this.list,d=c&&c.active>=0?this.visible[c.active]:null;if(!d){s&&s.commit&&this.commit();return}if(this.isSelectable(d)){this.choose(d);return}this.isBranch(d)?this.setExpanded(d,!this.expanded.has(d.key)):s&&s.commit&&this.commit()}moveHighlight(s){const c=this.list;if(!c)return;let d=c.active;for(let f=0;f<this.visible.length;f++){if(d+=s,d<0||d>=this.visible.length)return;if(!this.visible[d].disabled){c.setActive(d);return}}}}const n=t}),ve("packages/dom/src/editors/objectpicker.js",function(e,V){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const N=V("packages/dom/src/editors/select.js").SelectEditorBase,z=V("packages/dom/src/editors/common.js"),F=z.CLS,W=z.el,_=z.on,U=z.clear,B=z.keyOf,H=z.debounce,L=z.rawOptions,k=z.optionSource,S=z.lookupSearch,y=z.lookupKey,u=V("packages/core/src/internal/util.js"),o=u.isFunction,r=u.isObject,t=u.getPath,i=V("packages/dom/src/cell/icons.js").createIcon;class s extends N{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const w=super.build();if(w.classList.add("lat-objectpicker"),o(this.props.search)&&!(this.lookup&&this.lookup.search)){const p=Number(this.props.searchDebounce)||200;this.#n=H(m=>this.runRemoteSearch(String(m)),p)}return w}onQuery(w){super.onQuery(w),this.#n&&this.#n(w)}initSelection(){const w=L(this.params,this.props).map(p=>this.toOption(p));(w.length||!this.all.length)&&(this.all=w),this.selected=this.params.value??null}toOption(w){if(!r(w)){const a=w==null?"":String(w);return{id:w,label:a,secondary:"",avatar:"",initials:d(a),disabled:!1,raw:{}}}const p=this.props.valueKey||y(this.params,"valueKey")||"id",m=this.props.labelKey||y(this.params,"labelKey")||"label",b=c(w,this.props.template??m,""),v=c(w,this.props.secondary,""),l=c(w,this.props.avatar,"");return{id:w[p],label:b||String(w[p]??""),secondary:v,avatar:l,initials:d(b||String(w[p]??"")),disabled:w.disabled===!0,icon:w.icon,variant:w.variant,raw:w}}attached(){if(super.attached(),this.#t||this.all.length)return;const w=k(this.params,this.props);o(w)&&(this.#t=!0,Promise.resolve(w()).then(p=>{!this.element()||!Array.isArray(p)||(this.all=p.map(m=>this.toOption(m)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(w){const p=String(w||"").trim().toLowerCase();if(p==="")return this.all;const m=f(this.props.searchFields);return this.all.filter(b=>{if(!m)return b.label.toLowerCase().includes(p)||b.secondary.toLowerCase().includes(p);for(const v of m){const l=o(v)?v(b.raw):t(b.raw,v);if(l!=null&&String(l).toLowerCase().includes(p))return!0}return!1})}async runRemoteSearch(w){const p=S(this.params,this.props);if(!p)return;this.#e&&this.#e.abort();const m=new AbortController;this.#e=m;try{const b=await p(w,m.signal);if(m.signal.aborted||this.#e!==m)return;this.refreshOptions(Array.isArray(b)?b.map(v=>this.toOption(v)):[])}catch(b){if(!m.signal.aborted)throw b}finally{this.#e===m&&(this.#e=null)}}choose(w){!w||w.disabled||(this.selected=w.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(w){return this.selected!=null&&w!=null&&B(w.id)===B(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(w){if(w==null)return;const p=B(w);return this.all.find(m=>B(m.id)===p)}checkValue(w){return w==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(w)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(w)}" is not a valid option`}renderOption(w,p,m){U(p),p.appendChild(this.buildAvatar(w));const b=W(this.doc,"span",{class:"lat-object__text"});b.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:w.label})),w.secondary&&b.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:w.secondary})),p.appendChild(b),w.icon&&p.appendChild(i(this.doc,w.icon,{className:F.icon})),w.variant?p.setAttribute("data-variant",w.variant):p.removeAttribute("data-variant");const v=this.isSelected(w);p.classList.add("lat-object__row"),p.classList.toggle(F.optionSelected,v),p.classList.toggle(F.optionDisabled,w.disabled===!0),p.setAttribute("aria-selected",v?"true":"false"),w.disabled?p.setAttribute("aria-disabled","true"):p.removeAttribute("aria-disabled")}buildAvatar(w){const p=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!w.avatar)return p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:w.initials})),p.setAttribute("data-fallback","initials"),p;const m=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:w.avatar,alt:"",loading:"lazy",decoding:"async"}});return _(m,"error",()=>{m.parentNode===p&&(p.removeChild(m),p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:w.initials})),p.setAttribute("data-fallback","initials"))}),p.appendChild(m),p}paintDisplay(){const w=this.display;if(!w)return;if(U(w),this.selected==null){w.removeAttribute("data-variant");return}const p=this.optionById(this.selected);if(!p){w.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}w.appendChild(this.buildAvatar(p)),w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:p.label})),p.variant?w.setAttribute("data-variant",p.variant):w.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 c(g,w,p){if(w==null)return p;const m=o(w)?w(g):t(g,String(w));return m==null?p:String(m)}function d(g){const w=String(g||"").trim().split(/\s+/).filter(b=>b!=="");if(!w.length)return"";const p=[...w[0]][0]||"";if(w.length===1)return p.toUpperCase();const m=[...w[w.length-1]][0]||"";return(p+m).toUpperCase()}function f(g){if(g==null)return null;const p=(Array.isArray(g)?g:[g]).filter(m=>typeof m=="string"||o(m));return p.length?p:null}const h=s}),ve("packages/dom/src/editors/iconpicker.js",function(e,V){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.VirtualList,W=Z.el,_=Z.on,U=Z.clear,B=V("packages/dom/src/cell/icons.js"),H=B.createIcon,L=B.iconNames,S=V("packages/core/src/internal/util.js").isFunction;class y extends N{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const t=this.props;this.columns=Math.max(1,Math.floor(Number(t.columns)||8)),this.names=u(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const n=W(this.doc,"div",{class:["lat-iconpicker",`${z.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${z.editor}__display`}),this.input=W(this.doc,"input",{class:z.input,attrs:{type:"text",autocomplete:"off",placeholder:t.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new F({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(i,s,c)=>this.renderRow(i,s,c)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),n.appendChild(this.display),n.appendChild(this.input),t.allowClear===!0&&n.appendChild(this.buildClearButton()),n.appendChild(this.list.element()),this.off.push(_(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(_(this.input,"keydown",i=>this.onKeyDown(i))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),n}buildClearButton(){const t=W(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(_(t,"mousedown",n=>{S(n.preventDefault)&&n.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),t}focusTarget(){return this.input}onQuery(t){this.query=t,this.refreshIcons()}refreshIcons(){const t=this.query.trim().toLowerCase();this.matches=t===""?this.names.slice():this.names.filter(i=>i.toLowerCase().includes(t)),this.rows=[];for(let i=0;i<this.matches.length;i+=this.columns)this.rows.push(this.matches.slice(i,i+this.columns));const n=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=n>=0?n:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(t){return t<0?-1:Math.floor(t/this.columns)}moveCursor(t){if(!this.matches.length)return-1;const n=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(n)}setCursor(t){return this.cursor=t,this.list&&this.list.setActive(this.rowOf(t)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(t,n,i){n.setAttribute("role","row"),n.classList.add("lat-iconpicker__row");let s=n.__latIconCells;if(!s){s=[],U(n);for(let c=0;c<this.columns;c++){const d=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});_(d,"mousedown",f=>{S(f.preventDefault)&&f.preventDefault();const h=d.getAttribute("data-icon");h&&this.choose(h)}),n.appendChild(d),s.push(d)}n.__latIconCells=s}for(let c=0;c<s.length;c++){const d=s[c],f=t[c];if(f===void 0){d.setAttribute("aria-hidden","true"),d.removeAttribute("data-icon"),d.removeAttribute("title"),d.removeAttribute("aria-label"),d.classList.add("lat-iconpicker__cell--empty"),d.classList.remove("lat-iconpicker__cell--active"),d.classList.remove("lat-iconpicker__cell--selected"),d.__latIconName!==void 0&&(U(d),d.__latIconName=void 0);continue}const h=i*this.columns+c;d.removeAttribute("aria-hidden"),d.classList.remove("lat-iconpicker__cell--empty"),d.setAttribute("data-icon",f),d.setAttribute("title",f),d.setAttribute("aria-label",f),d.__latIconName!==f&&(U(d),d.appendChild(H(this.doc,f,{className:z.icon})),d.__latIconName=f);const g=this.selected===f;d.classList.toggle("lat-iconpicker__cell--active",h===this.cursor),d.classList.toggle("lat-iconpicker__cell--selected",g),d.setAttribute("aria-selected",g?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(U(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(H(this.doc,this.selected,{className:z.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const n=this.matches.indexOf(t);n>=0&&(this.cursor=n),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(t){return t==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(t))?!0:`"${String(t)}" is not a known icon name`}onKeyDown(t){const n=()=>{S(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":n(),this.moveCursor(1);return;case"ArrowLeft":n(),this.moveCursor(-1);return;case"ArrowDown":n(),this.moveCursor(this.columns);return;case"ArrowUp":n(),this.moveCursor(-this.columns);return;case"PageDown":n(),this.moveCursor(this.columns*5);return;case"PageUp":n(),this.moveCursor(-this.columns*5);return;case"Home":n(),this.setCursor(this.matches.length?0:-1);return;case"End":n(),this.setCursor(this.matches.length-1);return;case"Enter":{n();const i=this.cursorName();i&&this.choose(i);return}case"Escape":n(),this.cancel();return;case"Tab":{const i=this.cursorName();i&&(this.selected=i),this.commit();return}default:break}}destroy(){for(const t of this.off)t();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function u(r){const t=L();if(Array.isArray(r)&&r.length){const n=new Set(t);return r.map(i=>String(i)).filter(i=>n.has(i))}return t.filter(n=>n!=="blank")}const o=y}),ve("packages/dom/src/editors/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,U=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/temperature.js"),H=B.formatTemperature,L=B.parseTemperature,k=B.findScale;function S(o,r){return H(o,{...r,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends N{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const r=this.props;this.opts=this.buildOptions();const t=k(this.opts.scale),n=t?t.scale.symbol:"",i=`${this.id}-scale`,s=F(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?i:null}});s.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const c=typeof r.step=="number"?r.step:0;return c>0&&this.#e.push(W(s,"keydown",d=>{d.key==="ArrowUp"?(U(d.preventDefault)&&d.preventDefault(),this.nudge(c)):d.key==="ArrowDown"&&(U(d.preventDefault)&&d.preventDefault(),this.nudge(-c))})),this.hint=F(this.doc,"span",{class:`${z.editor}__suffix`,text:n,attrs:{id:i,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${z.editor}__unit`,children:[s,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&U(r.select)&&r.select()}nudge(r){const t=L(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:s}=this.props;typeof i=="number"&&n<i&&(n=i),typeof s=="number"&&n>s&&(n=s),this.input&&(this.input.value=S(n,this.opts))}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=L(r,this.opts);return t===null?Number.NaN:t}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r))return"Enter a temperature";const{min:t,max:n}=this.props;return typeof t=="number"&&r<t?`Must be ${t} or more`:typeof n=="number"&&r>n?`Must be ${n} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const u=y}),ve("packages/dom/src/editors/currency.js",function(e,V){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),N=Z.BaseEditor,z=Z.CLS,F=Z.el,W=Z.on,U=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/currency.js"),H=B.parseMoney,L=B.toMoney,k=B.normaliseCode,S=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(r){const t=L(r);return t?String(t.amount):""}class u extends N{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,n=t&&t.currencyConfig||{},i=L(this.params.value),s=k(this.props.code)||i&&i.code||k(n.code)||"USD";let c=this.props.codes||n.codes||S;return c=c.map(d=>k(d)).filter(Boolean),c.includes(s)||(c=[s,...c]),{code:s,codes:c,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const n=F(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:t.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});n.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const i=F(this.doc,"select",{class:`${z.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const s of this.opts.codes){const c=F(this.doc,"option",{text:s,attrs:{value:s}});s===this.opts.code&&(c.selected=!0),i.appendChild(c)}return this.picker=i,F(this.doc,"div",{class:`${z.editor}__unit`,children:[n,i]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&U(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const n=this.picker?this.picker.value:this.opts.code,i=H(t,{...this.opts,code:n});return i===null?Number.NaN:i}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const n=t.amount,{min:i,max:s}=this.props;return typeof i=="number"&&n<i?`Must be ${i} or more`:typeof s=="number"&&n>s?`Must be ${s} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const o=u}),ve("packages/dom/src/editors/index.js",function(e,V){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return pe}});const N=V("packages/dom/src/editors/text.js").TextEditor,F=V("packages/dom/src/editors/textarea.js").TextareaEditor,_=V("packages/dom/src/editors/number.js").NumberEditor,B=V("packages/dom/src/editors/date.js").DateEditor,L=V("packages/dom/src/editors/checkbox.js").CheckboxEditor,S=V("packages/dom/src/editors/select.js").SelectEditor,u=V("packages/dom/src/editors/multiselect.js").MultiSelectEditor,r=V("packages/dom/src/editors/time.js").TimeEditor,n=V("packages/dom/src/editors/datetime.js").DateTimeEditor,s=V("packages/dom/src/editors/duration.js").DurationEditor,d=V("packages/dom/src/editors/ipaddress.js").IpAddressEditor,h=V("packages/dom/src/editors/password.js").PasswordEditor,w=V("packages/dom/src/editors/code.js").CodeEditor,m=V("packages/dom/src/editors/unit.js").UnitEditor,v=V("packages/dom/src/editors/radix.js").RadixEditor,a=V("packages/dom/src/editors/segmented.js").SegmentedEditor,T=V("packages/dom/src/editors/rating.js").RatingEditor,M=V("packages/dom/src/editors/slider.js").SliderEditor,P=V("packages/dom/src/editors/colour.js").ColourEditor,K=V("packages/dom/src/editors/treeselect.js").TreeSelectEditor,D=V("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,E=V("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=V("packages/dom/src/editors/temperature.js").TemperatureEditor,Q=V("packages/dom/src/editors/currency.js").CurrencyEditor,J=V("packages/core/src/internal/util.js"),ne=J.isCtor,re=J.isFunction,oe=J.warnOnce,ie=V("packages/dom/src/editors/common.js");for(const he of Object.keys(ie))he!=="default"&&Object.defineProperty(e,he,{enumerable:!0,get:function(){return ie[he]}});const te=Object.freeze({text:N,textarea:F,number:_,date:B,checkbox:L,select:S,multiSelect:u,temperature:q,currency:Q,time:r,datetime:n,duration:s,ipaddress:d,password:h,code:w,unit:m,radix:v,slider:M,rating:T,segmented:a,treeSelect:K,objectPicker:D,iconPicker:E,colour:P}),ce=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function ue(he,ke){const Oe=he&&he.edit&&he.edit.editor,De=ke&&ke.editors||{},_e=!!(he&&he.lookup&&he.lookup.multiple);if(ne(Oe)||re(Oe))return Oe;if(typeof Oe=="string"){if(_e&&Oe==="select")return u;const $e=De[Oe]||te[Oe];if($e)return $e;oe(`editor:missing:${Oe}`,`unknown editor "${Oe}"; falling back to the data type default`)}const Se=he&&he.type||"text";if(Se==="lookup"||he&&he.lookup)return _e?u:S;const xe=ce[Se];return xe&&(De[xe]||te[xe])||null}function ae(he,ke){const Oe=ue(he.column||{},ke);if(!Oe)return null;const De=new Oe;return De.init(he),re(De.cancelBeforeStart)&&De.cancelBeforeStart()===!0?(re(De.destroy)&&De.destroy(),null):De}const pe=te}),ve("packages/dom/src/ui/statusbar.js",function(e,V){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction;function L(g){let w=0,p=0,m=0,b=null,v=null;for(const l of g||[]){if(l==null||l==="")continue;w++;const a=typeof l=="number"?l:Number(l);Number.isFinite(a)&&(p++,m+=a,(b===null||a<b)&&(b=a),(v===null||a>v)&&(v=a))}return{count:w,numericCount:p,sum:p?m:null,min:b,max:v,avg:p?m/p:null}}class k{root=null;valueNode=null;init(w){this.ctx=w,this.doc=w.document,this.root=F(this.doc,"div",{class:`${N.statusBar}__panel`,attrs:{"data-align":w.align||"end"}}),w.label&&this.root.appendChild(F(this.doc,"span",{class:`${N.statusBar}__label`,text:w.label})),this.valueNode=F(this.doc,"span",{class:`${N.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(w,p){const m=this.ctx&&this.ctx.messages;return(m&&H(m.t)?m:U).t(w,p)}element(){return this.root}refresh(){const w=this.read();this.valueNode&&this.valueNode.textContent!==w&&(this.valueNode.textContent=w)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class S extends k{read(){const w=this.ctx.host||{},p=H(w.totalRowCount)?w.totalRowCount():0;if(p==null)return this.t("status.counting");const m=H(w.rowCount)?w.rowCount():p,b=this.ctx.noun,v=l=>b===void 0?this.t("count.rows",{count:l}):`${c(l,this.ctx.locale)}${b?` ${b}`:""}`;return m===p?this.t("status.total",{rows:v(p)}):this.t("status.shownOfTotal",{shown:c(m,this.ctx.locale),total:v(p)})}}class y extends k{read(){const w=this.ctx.host||{},p=H(w.selectedCount)?w.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class u extends k{read(){const w=this.ctx.host||{},p=H(w.rangeValues)?w.rangeValues():[],m=L(p);if(!m.count)return"";const b=this.ctx.stats||["count","sum","min","max","avg"],v=[];for(const l of b){if(l==="count"){v.push(this.t("status.count",{count:m.count}));continue}const a=m[l];a!==null&&v.push(`${this.t(`status.stat.${l}`)} ${f(a,this.ctx.locale)}`)}return v.join(" ")}}class o extends k{read(){const w=this.ctx.host||{},p=H(w.progress)?w.progress():null;if(!p)return"";const{loaded:m,estimated:b,done:v}=p;if(v)return"";if(!b)return this.t("status.loading",{count:m||0});const l=Math.min(100,Math.round((m||0)/b*100));return this.t("status.loadingOf",{loaded:m||0,total:b,percent:l})}}class r extends k{read(){const w=this.ctx.host||{},p=H(w.updateStats)?w.updateStats():null;return p?p.paused?p.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:p.pending})}):this.t("status.paused"):p.coalescedTotal?this.t("status.coalesced",{count:p.coalescedTotal}):"":""}}class t extends k{read(){const w=this.ctx.host||{},p=H(w.hiddenUnresolved)?w.hiddenUnresolved():0;return p?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:p})}):""}}const n=Object.freeze({rowCount:S,selectedCount:y,aggregation:u,progress:o,updates:r,comments:t});class i{panels=[];root=null;init(w){const p=w||{};this.doc=z(p),this.host=p.host||{},this.messages=p.messages||null,this.root=F(this.doc,"div",{class:N.statusBar,attrs:{role:"status","aria-live":"polite"}});const m=p.registry||{},b=Array.isArray(p.panels)&&p.panels.length?p.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const v of b){const l=typeof v=="string"?v:v.name,a=typeof v=="function"?v:m[l]||n[l];if(!a)continue;const O=new a;O.init({document:this.doc,host:this.host,locale:p.locale,messages:this.messages,...typeof v=="object"?v.props||{}:{}}),this.panels.push({name:String(l||"panel"),panel:O}),this.root.appendChild(O.element())}this.refresh()}element(){return this.root}addPanel(w,p,m){const b=new p;return b.init({document:this.doc,host:this.host,messages:this.messages,...m||{}}),this.panels.push({name:w,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(w){const p=this.panels.findIndex(v=>v.name===w);if(p<0)return!1;const[m]=this.panels.splice(p,1),b=m.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),H(m.panel.destroy)&&m.panel.destroy(),!0}refresh(){for(const w of this.panels)w.panel.refresh()}destroy(){for(const w of this.panels)H(w.panel.destroy)&&w.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const s=new Map;function c(g,w){const p=w||"";let m=s.get(p);return m||(m=new Intl.NumberFormat(w||void 0,{maximumFractionDigits:0}),s.set(p,m)),m.format(Number(g)||0)}const d=new Map;function f(g,w){const p=w||"";let m=d.get(p);return m||(m=new Intl.NumberFormat(w||void 0,{maximumFractionDigits:3}),d.set(p,m)),m.format(Number(g)||0)}const h=i}),ve("packages/dom/src/ui/contextmenu.js",function(e,V){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/renderer/direction.js").isRtlElement,S=V("packages/dom/src/cell/icons.js").renderIconInto;function y(n,i){const s=[];for(const c of n||[]){const d=B(c)?c(i):c;if(d==null||d===!1)continue;if(d==="separator"){s.push({separator:!0});continue}if(typeof d=="string"){s.push({name:d});continue}const f=d,h=f.subMenu||f.children;h?s.push({...f,subMenu:y(h,i)}):s.push(f)}return s.filter((c,d,f)=>c.separator?d===0||d===f.length-1?!1:!f[d-1].separator:!0)}class u{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(i){const s=i||{};this.doc=z(s),this.host=s.host||this.doc.body,this.ctx=s.ctx||{},this.onClose=s.onClose||null,this.parent=s.parent||null}place(i){const s=this.host,c=B(s.getBoundingClientRect)?s.getBoundingClientRect():{left:0,top:0},d=B(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},f=this.doc.defaultView||{innerWidth:0,innerHeight:0},h=f.innerWidth||0,g=f.innerHeight||0;let w=i.x||0,p=i.y||0;const m=L(s);if(i.anchor&&B(i.anchor.getBoundingClientRect)){const l=i.anchor.getBoundingClientRect();i.placement==="below"?(w=m?l.right-d.width:l.left,p=l.bottom):(w=m?l.left-d.width:l.right,p=l.top)}else m&&(w-=d.width);const b={left:Math.max(0,c.left||0),top:Math.max(0,c.top||0),right:Math.min(h||1/0,(c.left||0)+(c.width||1/0)),bottom:Math.min(g||1/0,(c.top||0)+(c.height||1/0))};w+d.width>b.right&&(w-=d.width),w<b.left&&(w=b.left),p+d.height>b.bottom&&(p-=d.height),p<b.top&&(p=b.top);const v=b.bottom-p;d.height>v&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(v))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(w-c.left+(s.scrollLeft||0))}px`,this.root.style.top=`${Math.round(p-c.top+(s.scrollTop||0))}px`}show(i){return this.hide(),i.ctx&&(this.ctx={...this.ctx||{},...i.ctx}),this.items=y(i.items,this.ctx),this.returnFocus=i.returnFocus||null,this.anchor=i.anchor&&B(i.anchor.setAttribute)&&i.anchor.getAttribute&&i.anchor.getAttribute("aria-haspopup")?i.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=F(this.doc,"div",{class:N.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((s,c)=>{if(s.separator){this.root.appendChild(F(this.doc,"div",{class:N.menuSeparator,attrs:{role:"separator"}}));return}const d=F(this.doc,"div",{class:[N.menuItem,s.cssClass||""],attrs:{role:s.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":s.disabled?"true":null,"aria-checked":s.checked===void 0?null:String(s.checked===!0),"aria-haspopup":s.subMenu?"true":null,"aria-expanded":s.subMenu?"false":null,"data-index":c}});if(s.icon!=null&&s.icon!==""){const h=F(this.doc,"span",{class:N.icon});S(h,s.icon,`menu:${s.name||c}`),d.appendChild(h)}d.appendChild(F(this.doc,"span",{class:`${N.menuItem}__label`,text:s.name||""})),s.shortcut&&d.appendChild(F(this.doc,"span",{class:`${N.menuItem}__shortcut`,text:s.shortcut})),s.subMenu&&d.appendChild(F(this.doc,"span",{class:`${N.menuItem}__arrow`,text:"›"}));const f=this.itemNodes.length;this.off.push(W(d,"click",()=>this.invoke(f))),this.off.push(W(d,"mouseenter",()=>{this.focus(f),s.subMenu?this.openSubMenu(f):this.closeChild()})),this.itemNodes.push(d),this.root.appendChild(d)}),this.host.appendChild(this.root),this.place(i),this.open=!0,this.off.push(W(this.root,"keydown",s=>this.onKeyDown(s))),B(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=s=>{this.root&&!r(this.root,s.target)&&!(this.child&&this.child.root&&r(this.child.root,s.target))&&this.hide()},!0)),B(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let i=0;i<this.itemNodes.length;i++)if(!this.itemAt(i).disabled)return i;return-1}itemAt(i){const s=this.itemNodes[i];return s?this.items[Number(s.getAttribute("data-index"))]||{}:{}}focus(i){if(i<0||i>=this.itemNodes.length)return;const s=this.itemNodes[this.focused];s&&s.classList.remove(`${N.menuItem}--focused`),this.focused=i;const c=this.itemNodes[i];c.classList.add(`${N.menuItem}--focused`),B(c.focus)&&c.focus(),B(c.scrollIntoView)&&c.scrollIntoView({block:"nearest",inline:"nearest"})}move(i){const s=this.itemNodes.length;if(!s)return;let c=this.focused;for(let d=0;d<s;d++)if(c=(c+i+s)%s,!this.itemAt(c).disabled){this.focus(c);return}}invoke(i){const s=this.itemAt(i);if(!(!s||s.disabled)){if(s.subMenu){this.openSubMenu(i);return}B(s.action)&&s.action({...this.ctx,item:s}),this.hideRoot()}}openSubMenu(i){const s=this.itemAt(i);s.subMenu&&(this.closeChild(),this.child=new u({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:s.subMenu,anchor:this.itemNodes[i]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(i){switch(i.key){case"ArrowDown":o(i),this.move(1);break;case"ArrowUp":o(i),this.move(-1);break;case"Home":o(i),this.focus(this.firstEnabled());break;case"End":o(i),this.focus(this.itemNodes.length-1);break;case"ArrowRight":o(i),this.openSubMenu(this.focused);break;case"ArrowLeft":o(i),this.parent&&(this.hide(),B(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":o(i),this.invoke(this.focused);break;case"Escape":o(i),this.hideRoot();break;default:i.key&&i.key.length===1&&this.jumpTo(i.key);break}}jumpTo(i){const s=i.toLowerCase(),c=this.itemNodes.length;for(let d=1;d<=c;d++){const f=(this.focused+d+c)%c,h=this.itemAt(f);if(!h.disabled&&(h.name||"").toLowerCase().startsWith(s)){this.focus(f);return}}}hideRoot(){let i=this;for(;i.parent;)i=i.parent;i.hide()}hide(){this.closeChild();for(const i of this.off)i();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&&B(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&B(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,B(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function o(n){B(n.preventDefault)&&n.preventDefault(),B(n.stopPropagation)&&n.stopPropagation()}function r(n,i){let s=i;for(;s;){if(s===n)return!0;s=s.parentNode}return!1}const t=u}),ve("packages/dom/src/viewpicker.js",function(e,V){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),N=Z.documentFor,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction,k=V("packages/dom/src/cell/icons.js").createIcon,S=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 y{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(t,n){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(t,n)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||U;const n=t||{};this.doc=N(n),this.host=n.host||{},this.props=n.props||{},this.root=z(this.doc,"div",{class:S.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const t=this.root;if(!t)return;for(const d of this.off)d();this.off.length=0,W(t),this.diffs=new Map;const n=this.views(),i=n.filter(d=>d.builtin),s=n.filter(d=>!d.builtin);i.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),i.length)),t.appendChild(this.buildList(i))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),s.length)),s.length?t.appendChild(this.buildList(s)):t.appendChild(z(this.doc,"p",{class:S.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const c=this.buildFoot();c&&t.appendChild(c)}buildList(t){const n=z(this.doc,"div",{class:S.list,attrs:{role:"list"}});for(const i of t)n.appendChild(this.buildItem(i));return n}views(){const t=H(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((n,i)=>String(n.name||"").localeCompare(String(i.name||"")))}activeId(){return H(this.host.activeId)?this.host.activeId():null}buildHead(t,n){return z(this.doc,"div",{class:S.head,children:[z(this.doc,"span",{class:S.title,text:String(t)}),z(this.doc,"span",{class:S.count,text:String(n)})]})}buildItem(t){const n=String(t.id),i=this.activeId()===n,s=H(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,c=z(this.doc,"div",{class:[S.item,i?S.itemActive:"",this.editing===n?S.itemEditing:""],attrs:{role:"listitem","data-view":n,"data-shared":t.shared?"true":"false"}});if(this.editing===n)return c.appendChild(this.buildRenameRow(t)),c;const d=z(this.doc,"button",{class:S.apply,attrs:{type:"button","aria-current":i?"true":null,title:[i?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[z(this.doc,"span",{class:S.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});H(this.host.apply)?this.off.push(F(d,"click",()=>this.applyView(n))):d.setAttribute("disabled",""),t.description&&d.appendChild(z(this.doc,"span",{class:S.description,text:String(t.description)}));const f=this.buildDiff(n,i);return f&&d.appendChild(f),c.appendChild(d),t.builtin||c.appendChild(this.confirming===n?this.buildConfirm(t):this.buildActions(t,s)),c}buildBadges(t){const n=z(this.doc,"span",{class:S.badges});return t.isDefault&&n.appendChild(z(this.doc,"span",{class:[S.badge,S.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),n}buildDiff(t,n){if(this.props.showDiff!==!0||!H(this.host.diff))return null;const i=this.diffOf(t);if(!i)return null;if(!i.changed)return z(this.doc,"span",{class:[S.diff,S.diffClean],text:this.t(n?"views.applied":"views.matchesGrid")});const s=u(i);return s.length?z(this.doc,"span",{class:S.diff,text:s.join(" · ")}):null}diffOf(t){if(!H(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let n=null;try{n=this.host.diff(t)}catch{n=null}return this.diffs.set(t,n),n}buildActions(t,n){const i=String(t.id),s=z(this.doc,"span",{class:S.actions});if(n&&H(this.host.rename)&&s.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=i,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&H(this.host.clearDefault)?s.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(i),this.refresh()},"pin")):!t.isDefault&&H(this.host.setDefault)&&s.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(i),this.refresh()},"pin")),H(this.host.export)&&s.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(i),"share")),n&&H(this.host.remove)){const c=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=i,this.refresh()},"trash");c.classList.add(S.actionDanger),s.appendChild(c)}return s}buildConfirm(t){const n=String(t.id),i=z(this.doc,"span",{class:S.confirm});i.appendChild(z(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const s=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(n),this.refresh()});return s.classList.add(S.actionDanger),i.appendChild(s),i.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),i}buildRenameRow(t){const n=String(t.id),i=z(this.doc,"span",{class:S.confirm}),s=z(this.doc,"input",{class:S.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});s.value=String(t.name||""),this.input=s;const c=()=>{const f=String(s.value||"").trim();this.editing=null,f&&f!==t.name&&this.host.rename(n,f),this.refresh()},d=()=>{this.editing=null,this.refresh()};return this.off.push(F(s,"keydown",f=>{f.key==="Enter"?c():f.key==="Escape"&&d()})),i.appendChild(s),i.appendChild(this.buildAction("Save","Save the new name",c)),i.appendChild(this.buildAction("Cancel","Leave the name alone",d)),i}buildFoot(){if(this.props.allowSave===!1||!H(this.host.saveAs))return null;const t=z(this.doc,"div",{class:S.foot}),n=z(this.doc,"input",{class:S.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});n.value=this.draft,this.editing===null&&(this.input=n);const i=()=>{const c=String(n.value||"").trim();if(!c){H(n.focus)&&n.focus();return}this.draft="",this.host.saveAs(c),this.refresh()};this.off.push(F(n,"input",()=>{this.draft=String(n.value||"")})),this.off.push(F(n,"keydown",c=>{c.key==="Enter"&&i()}));const s=z(this.doc,"button",{class:S.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(F(s,"click",i)),t.appendChild(n),t.appendChild(s),t}buildAction(t,n,i,s){const c=z(this.doc,"button",{class:S.action,text:s?null:t,attrs:{type:"button",title:n,"aria-label":n,"data-action":t}});return s&&c.appendChild(k(this.doc,s,{className:S.actionIcon})),this.off.push(F(c,"click",i)),c}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&H(t.focus)&&t.focus(),t&&H(t.select)&&t.select()}destroy(){for(const t of this.off)t();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function u(r,t=3){if(!r||!r.changed)return[];const n=r.counts||{},i=[],s=(c,d,f)=>{c&&i.push((c===1?d:f).replace("%",String(c)))};if(s(n.columnsHidden,"hides % column","hides % columns"),s(n.columnsShown,"shows % column","shows % columns"),s(n.columnsMoved,"moves % column","moves % columns"),s(n.columnsPinned,"repins % column","repins % columns"),s(n.columnsResized,"resizes % column","resizes % columns"),r.filters&&r.filters.changed){const c=n.filterColumns||0;i.push(c?`changes ${c} filter${c===1?"":"s"}`:"changes the filter")}return r.quick&&r.quick.changed&&i.push("changes the search"),r.sort&&r.sort.changed&&i.push("changes the sort"),r.group&&r.group.changed&&i.push("changes the grouping"),r.pivot&&r.pivot.changed&&i.push("changes the pivot"),s(n.columnsTotalled,"changes % total","changes % totals"),r.pagination&&r.pagination.changed&&i.push("changes the page size"),i.length<=t?i:[...i.slice(0,t),`and ${i.length-t} more`]}const o=y}),ve("packages/dom/src/ui/panelbase.js",function(e,V){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return _}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.el,W=V("packages/core/src/i18n/index.js").defaultMessages;class _{root=null;off=[];init(B){this.ctx=B,this.doc=B.document,this.host=B.host||{},this.props=B.props||{},this.root=z(this.doc,"div",{class:`${N.panel}__body`}),this.refresh()}t(B,H){const L=this.host||{};if(typeof L.t=="function")return L.t(B,H);const k=this.ctx||{};if(k.messages&&typeof k.messages.t=="function")return k.messages.t(B,H);const S=k.grid;return(S&&S.messages?S.messages:W).t(B,H)}element(){return this.root}refresh(){}destroy(){for(const B of this.off)B();this.off.length=0,this.root=null}}}),ve("packages/dom/src/formattingpanel.js",function(e,V){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,k=V("packages/core/src/formatting/rules.js"),S=k.compileRules,y=k.summariseColumn,u=k.needsDistribution,o=k.DISTRIBUTION_LABELS,r="*",t=8,n=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}]),i=Object.freeze([{op:"topPercent",label:o.topPercent,values:1},{op:"bottomPercent",label:o.bottomPercent,values:1},{op:"topN",label:o.topN,values:1},{op:"bottomN",label:o.bottomN,values:1},{op:"aboveMean",label:o.aboveMean,values:0},{op:"belowMean",label:o.belowMean,values:0},{op:"aboveMedian",label:o.aboveMedian,values:0},{op:"belowMedian",label:o.belowMedian,values:0},{op:"zAbove",label:o.zAbove,values:1},{op:"zBelow",label:o.zBelow,values:1},{op:"outlier",label:o.outlier,values:0}]),s=Object.freeze([...n,...i]),c=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"}]),d=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"]}]),f=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 h(b){const v=s.find(l=>l.op===b);return v?v.values:1}function g(b){if(!b)return"";if(b.scale){const{min:O,max:T,from:A}=b.scale;if(Number.isFinite(O)&&Number.isFinite(T))return`Colour scale, ${O} to ${T}`;const M=f.find(C=>C.from===A);return M?`Colour scale ${M.label}`:"Colour scale"}const v=b.when||{},l=s.find(O=>O.op===v.op),a=l?l.label:v.op;return!l||l.values===0?`Value ${a}`:l.values===2?`Value ${a} ${v.value} and ${v.value2}`:`Value ${a} ${v.value}`}class w extends L{scope=r;mode="condition";refresh(){const v=this.root;if(v){for(const l of this.off)l();this.off.length=0,_(v),v.appendChild(this.#o()),v.appendChild(this.#i()),v.appendChild(this.#s())}}#e(){const v=B(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:r,title:"All columns"},...v]}#t(){return B(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(v){if(!B(this.host.columnSamples))return[];const l=this.host.columnSamples(v);return Array.isArray(l)?l:[...l||[]]}#r(v,l,a){const O=u(v)?y(l):null;return S(v,O)({value:a})}#o(){const v=F(this.doc,"div",{class:`${N.panel}__row`});v.appendChild(F(this.doc,"label",{class:`${N.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const l=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const a of this.#e()){const O=F(this.doc,"option",{text:a.title,attrs:{value:a.id}});a.id===this.scope&&O.setAttribute("selected","selected"),l.appendChild(O)}return l.value=this.scope,this.off.push(W(l,"change",()=>{this.scope=l.value||r,this.refresh()})),v.appendChild(l),v}#i(){const v=F(this.doc,"ul",{class:`${N.panel}__list`}),l=this.#t();if(!l.length)return v.appendChild(F(this.doc,"li",{class:`${N.panel}__empty`,text:this.t("formatting.noRules")})),v;l.forEach((T,A)=>{const M=F(this.doc,"li",{class:`${N.panel}__item`,attrs:{"data-rule":T.id}}),C=F(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${g(T)}`}});C.checked=T.enabled!==!1,this.off.push(W(C,"change",()=>{this.#c("updateRule",this.scope,T.id,{enabled:C.checked})})),M.appendChild(C);const P=F(this.doc,"span",{class:`${N.panel}__swatch`}),x=T.style||{};if(x.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(x.background));else if(T.scale&&T.scale.colours&&P.style&&P.style.setProperty){const j=T.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${j[0]}, ${j[j.length-1]})`)}M.appendChild(P),M.appendChild(F(this.doc,"span",{class:`${N.panel}__text`,text:g(T)}));const K=F(this.doc,"button",{class:`${N.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...A===0?{disabled:"disabled"}:{}}});this.off.push(W(K,"click",()=>this.#c("moveRule",this.scope,T.id,A-1))),M.appendChild(K);const I=F(this.doc,"button",{class:`${N.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...A===l.length-1?{disabled:"disabled"}:{}}});this.off.push(W(I,"click",()=>this.#c("moveRule",this.scope,T.id,A+1))),M.appendChild(I);const D=F(this.doc,"button",{class:`${N.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${g(T)}`}});this.off.push(W(D,"click",()=>this.#c("removeRule",this.scope,T.id))),M.appendChild(D),v.appendChild(M)});const a=this.#a(l);a&&v.appendChild(a);const O=F(this.doc,"button",{class:`${N.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(O,"click",()=>this.#c("clearRules",this.scope))),v.appendChild(O),v}#a(v){const l=this.#n(this.scope);if(!l.length)return null;const a=v.filter(T=>T.enabled!==!1);if(!a.length)return null;const O=F(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const T of l.slice(0,t)){const A=this.#r(a,l,T),M=F(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(T)});A&&M.style&&M.style.setProperty&&(A.background&&M.style.setProperty("background",String(A.background)),A.color&&M.style.setProperty("color",String(A.color))),O.appendChild(M)}return O}#s(){const v=F(this.doc,"div",{class:`${N.panel}__form`}),l=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return l.appendChild(F(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),l.appendChild(F(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),l.value=this.mode,this.off.push(W(l,"change",()=>{this.mode=l.value==="scale"?"scale":"condition",this.refresh()})),v.appendChild(l),this.mode==="scale"?v.appendChild(this.#u()):v.appendChild(this.#l()),v}#l(){const v=F(this.doc,"div",{class:`${N.panel}__form`}),l=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),a=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const D of n)a.appendChild(F(this.doc,"option",{text:D.label,attrs:{value:D.op}}));l.appendChild(a);const O=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const D of i)O.appendChild(F(this.doc,"option",{text:D.label,attrs:{value:D.op}}));l.appendChild(O),l.value="gt",v.appendChild(l);const T=F(this.doc,"input",{class:`${N.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),A=F(this.doc,"input",{class:`${N.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});v.appendChild(T),v.appendChild(A);const M=()=>{const D=h(l.value);T.style.setProperty("display",D>=1?"":"none"),A.style.setProperty("display",D>=2?"":"none"),K()};this.off.push(W(l,"change",M));const C=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const D of c)C.appendChild(F(this.doc,"option",{text:D.name,attrs:{value:D.name}}));C.value=c[0].name,v.appendChild(C);const P=F(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(P);const x=()=>{const D=c.find($=>$.name===C.value)||c[0],j=h(l.value),E={op:l.value};return j>=1&&(E.value=T.value),j>=2&&(E.value2=A.value),{when:E,style:{background:D.background,color:D.color}}},K=()=>{_(P);const D=this.#n(this.scope);if(D.length)for(const j of D.slice(0,t)){const E=this.#r([x()],D,j),$=F(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(j)});E&&$.style&&$.style.setProperty&&(E.background&&$.style.setProperty("background",String(E.background)),E.color&&$.style.setProperty("color",String(E.color))),P.appendChild($)}};this.off.push(W(T,"input",K)),this.off.push(W(A,"input",K)),this.off.push(W(C,"change",K)),M();const I=F(this.doc,"button",{class:`${N.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(I,"click",()=>{this.#c("addRule",this.scope,x()),T.value="",A.value=""})),v.appendChild(I),v}#u(){const v=F(this.doc,"div",{class:`${N.panel}__form`}),l=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of d)l.appendChild(F(this.doc,"option",{text:C.name,attrs:{value:C.name}}));l.value=d[0].name,v.appendChild(l);const a=F(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of f)a.appendChild(F(this.doc,"option",{text:C.label,attrs:{value:C.from}}));a.value=f[0].from,v.appendChild(a);const O=F(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(O);const T=()=>{const C=d.find(P=>P.name===l.value)||d[0];return{scale:{from:a.value,colours:[...C.colours]}}},A=()=>{_(O);const C=this.#n(this.scope);if(C.length)for(const P of C.slice(0,t)){const x=this.#r([T()],C,P),K=F(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(P)});x&&x.background&&K.style&&K.style.setProperty&&K.style.setProperty("background",String(x.background)),O.appendChild(K)}};this.off.push(W(l,"change",A)),this.off.push(W(a,"change",A)),A();const M=F(this.doc,"button",{class:`${N.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(M,"click",()=>{this.#c("addRule",this.scope,T())})),v.appendChild(M),v}#c(v,...l){B(this.host[v])&&this.host[v](...l),this.refresh()}}function p(b={}){const v=new w;return v.init({document:z(b),host:b.host||{}}),v}const m=w}),ve("packages/dom/src/statisticspanel.js",function(e,V){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return u}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/internal/util.js").isFunction,H=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,L=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"}]),k=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),S=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 y(o){if(o==null||!Number.isFinite(o))return"—";if(Number.isInteger(o))return String(o);const r=Math.abs(o);return r!==0&&(r<.001||r>=1e7)?o.toExponential(2):String(Number(o.toPrecision(4)))}class u extends H{column=null;#e(){return U(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const r=this.root;if(!r)return;for(const s of this.off)s();this.off.length=0,W(r);const t=this.#e();if(!t.length){r.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(s=>s.id===this.column)||(this.column=t[0].id),r.appendChild(this.#t(t));const n=U(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!n||!n.present){r.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("stats.noValues")}));return}if(r.appendChild(z(this.doc,"p",{class:`${N.panel}__count`,text:this.t("stats.filtered",{count:n.rows})})),Array.isArray(n.topValues)){r.appendChild(this.#o(n,k)),r.appendChild(this.#i(n.topValues));return}r.appendChild(this.#o(n));for(const s of S){const c=this.#n(s);c&&r.appendChild(c)}const i=this.#r();i&&r.appendChild(i),n.histogram&&n.histogram.length>1&&r.appendChild(this.#a(n.histogram))}#t(r){const t=z(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const n of r){const i=z(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===this.column?!0:null}});t.appendChild(i)}return t.value=this.column,this.off.push(F(t,"change",()=>{this.column=t.value,this.refresh()})),z(this.doc,"label",{class:`${N.panel}__field`,children:[z(this.doc,"span",{class:`${N.panel}__label`,text:this.t("stats.column")}),t]})}#n(r){const t=this.host.reduceColumn;if(!U(t)||!this.column)return null;const n=[];for(const c of r.kernels){const d=t(this.column,c);d==null||Number.isNaN(d)||n.push([c,d])}if(!n.length)return null;const i=this.doc.createElement("div");i.appendChild(z(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t(r.label)}));const s=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const[c,d]of n)s.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(`total.${c}`)})),s.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,text:typeof d=="number"?y(d):String(d)}));return i.appendChild(s),i}#r(){const r=this.host.columnCapability;if(!U(r)||!this.column)return null;const t=r(this.column);if(!t)return null;const n=this.doc.createElement("div");n.appendChild(z(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.section.capability")}));const i=z(this.doc,"dl",{class:`${N.panel}__stats`}),s=[["stats.cp",t.cp,null],["stats.cpk",t.cpk,t.interval],["stats.pp",t.pp,null],["stats.ppk",t.ppk,t.intervalPp],["stats.outOfSpec",t.outOfSpec,null]];for(const[c,d,f]of s){if(d==null)continue;i.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(c)}));const h=[z(this.doc,"span",{text:y(d)})];f&&Number.isFinite(f.lower)&&h.push(z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${y(f.lower)} – ${y(f.upper)}`,attrs:{title:`${Math.round(f.confidence*100)}%`}})),i.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,children:h}))}return n.appendChild(i),n}#o(r,t=L){const n=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const i of t){const s=r[i.key];n.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(i.label)})),n.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,text:i.kind==="count"?String(s??0):y(s)}))}return n}#i(r){const t=this.doc.createElement("div");t.appendChild(z(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.topValues")}));const n=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const i of r)n.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:String(i.value)})),n.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,children:[z(this.doc,"span",{text:String(i.count)}),z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${Math.round(i.share*100)}%`})]}));return t.appendChild(n),t}#a(r){const t=r.reduce((i,s)=>Math.max(i,s.count),0)||1,n=z(this.doc,"div",{class:`${N.panel}__histogram`});n.appendChild(z(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.distribution")}));for(const i of r){const s=z(this.doc,"div",{class:`${N.panel}__bar`,style:{width:`${i.count?Math.max(2,i.count/t*100):0}%`}});n.appendChild(z(this.doc,"div",{class:`${N.panel}__bin`,attrs:{title:this.t("stats.bin",{count:i.count,from:y(i.from),to:y(i.to)})},children:[s]}))}return n}}}),ve("packages/dom/src/regressionpanel.js",function(e,V){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.el,F=Z.clear,_=V("packages/core/src/internal/util.js").isFunction,B=V("packages/dom/src/ui/panelbase.js").ToolPanelBase;function H(S,y=4){const u=Number(S);return Number.isFinite(u)?u.toFixed(y):u===1/0?"∞":"—"}class L extends B{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const u=this.ctx&&this.ctx.grid,o=u&&_(u.get)?u.get("regression"):null;return o&&Array.isArray(o.predictors)&&o.response?o:null}refresh(){const y=this.root;if(!y)return;F(y);const u=this.#e();if(!u){y.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.noModel")}));return}const o=_(this.host.regressionModel)?this.host.regressionModel(u):null;if(!o){y.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild(z(this.doc,"p",{class:`${N.panel}__count`,text:this.t("regression.observations",{count:o.n})})),y.appendChild(this.#t(o)),y.appendChild(this.#n(o));const r=this.#r(o,u);r&&y.appendChild(r),y.appendChild(this.#o(o))}#t(y){const u=z(this.doc,"dl",{class:`${N.panel}__stats`}),o=(r,t)=>{u.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-label`,text:r})),u.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,text:t}))};return o(this.t("regression.r2"),H(y.r2,4)),o(this.t("regression.adjR2"),H(y.adjR2,4)),u}#n(y){const u=z(this.doc,"div",{class:`${N.panel}__section`});u.appendChild(z(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.coefficients")}));const o=z(this.doc,"table",{class:`${N.panel}__coef-table`}),r=z(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])r.appendChild(z(this.doc,"th",{text:this.t(t)}));o.appendChild(r);for(const t of y.coefficients){const n=z(this.doc,"tr");n.appendChild(z(this.doc,"td",{text:t.name})),n.appendChild(z(this.doc,"td",{text:`${H(t.estimate)} ± ${H(t.stdError)}`})),n.appendChild(z(this.doc,"td",{text:H(t.stdError)})),n.appendChild(z(this.doc,"td",{text:H(t.t,3)})),n.appendChild(z(this.doc,"td",{text:H(t.p,4)})),o.appendChild(n)}return u.appendChild(o),u}#r(y,u){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const o=z(this.doc,"div",{class:`${N.panel}__section`});o.appendChild(z(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.vif")}));const r=z(this.doc,"dl",{class:`${N.panel}__stats`});return y.vif.forEach((t,n)=>{r.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-label`,text:u.predictors[n]})),r.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,text:H(t,3)}))}),o.appendChild(r),o}#o(y){const u=y.heteroscedasticity,o=z(this.doc,"div",{class:`${N.panel}__section`});return o.appendChild(z(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.heteroscedasticity")})),u?(o.appendChild(z(this.doc,"p",{class:`${N.panel}__flag`,attrs:{"data-heteroscedastic":u.heteroscedastic?"true":"false"},text:this.t(u.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:H(u.statistic,3),p:H(u.p,4)})})),o):(o.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.cannotFit")})),o)}}const k=L}),ve("packages/dom/src/comparepanel.js",function(e,V){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return S}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/internal/util.js").isFunction,H=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,L=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 k(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const u=Math.abs(y);return u!==0&&(u<.001||u>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class S extends H{first=null;second=null;#e(){return U(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const u=this.root;if(!u)return;for(const n of this.off)n();this.off.length=0,W(u);const o=this.#e();if(o.length<2){u.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("compare.needTwo")}));return}o.some(n=>n.id===this.first)||(this.first=o[0].id),(!o.some(n=>n.id===this.second)||this.second===this.first)&&(this.second=(o.find(n=>n.id!==this.first)||o[0]).id),u.appendChild(this.#t("compare.first",o,this.first,n=>{this.first=n,this.second===n&&(this.second=(o.find(i=>i.id!==n)||o[0]).id),this.refresh()})),u.appendChild(this.#t("compare.second",o,this.second,n=>{this.second=n,this.first===n&&(this.first=(o.find(i=>i.id!==n)||o[0]).id),this.refresh()}));const r=U(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!r||!r.n){u.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("compare.noPairs")}));return}u.appendChild(z(this.doc,"p",{class:`${N.panel}__count`,text:this.t("compare.pairs",{count:r.n})}));const t=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const n of L){const i=r[n.key];i!=null&&(t.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(n.label)})),t.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,text:k(i)})))}u.appendChild(t)}#t(u,o,r,t){const n=z(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const i of o)n.appendChild(z(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(F(n,"change",()=>t(n.value))),z(this.doc,"label",{class:`${N.panel}__field`,children:[z(this.doc,"span",{class:`${N.panel}__label`,text:this.t(u)}),n]})}}}),ve("packages/dom/src/insightspanel.js",function(e,V){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return S}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/internal/util.js").isFunction,H=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,L=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 k(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const u=Math.abs(y);return u!==0&&(u<.001||u>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class S extends H{column=null;by=null;#e(){return U(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const u=this.root;if(!u)return;for(const s of this.off)s();this.off.length=0,W(u);const o=this.#e();if(!o.length){u.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.empty")}));return}const r=this.#t();r&&u.appendChild(r);const t=this.#n();t&&u.appendChild(t),u.appendChild(this.#o(o));const n=this.#a();n&&u.appendChild(n);const i=this.#u();i&&u.appendChild(i)}#t(){if(!U(this.host.subsetVsPopulation))return null;const u=this.host.subsetVsPopulation();if(!u)return null;const o=this.#c("insights.subset");return u.filtered?(o.appendChild(z(this.doc,"p",{class:`${N.panel}__count`,text:this.t("stats.filtered",{count:u.subsetN})})),o.appendChild(this.#r(u.ranked)),o):(o.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.noFilter")})),o)}#n(){const u=this.props&&this.props.other;if(!u||!U(this.host.datasetVsDataset))return null;let o;try{o=this.host.datasetVsDataset(u)}catch{return null}if(!o||!o.ranked)return null;const r=this.#c("insights.dataset");return r.appendChild(this.#r(o.ranked)),r}#r(u){const o=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const r of u||[]){const t=z(this.doc,"dt",{class:`${N.panel}__stat-name`});t.appendChild(z(this.doc,"span",{text:String(r.name??r.column)})),t.appendChild(z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:String(r.measure||"")}));const n=z(this.doc,"dd",{class:`${N.panel}__stat-value`});n.appendChild(z(this.doc,"span",{text:k(r.magnitude)})),r.reliable===!1&&n.appendChild(z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:this.t("insights.smallSample")})),o.appendChild(t),o.appendChild(n)}return o}#o(u){const o=this.#c("insights.groups");u.some(t=>t.id===this.column)||(this.column=u[0].id),(!u.some(t=>t.id===this.by)||this.by===this.column)&&(this.by=(u.find(t=>t.id!==this.column)||u[0]).id),o.appendChild(this.#d("stats.column",u,this.column,t=>{this.column=t,this.by===t&&(this.by=(u.find(n=>n.id!==t)||u[0]).id),this.refresh()})),o.appendChild(this.#d("insights.by",u,this.by,t=>{this.by=t,this.column===t&&(this.column=(u.find(n=>n.id!==t)||u[0]).id),this.refresh()}));const r=U(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return r?(o.appendChild(this.#i(r)),o):(o.appendChild(z(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.needGroups")})),o)}#i(u){const o=z(this.doc,"dl",{class:`${N.panel}__stats`});Array.isArray(u.groups)&&u.groups.length===2&&this.#l(o,"insights.groups",`${u.groups[0]} · ${u.groups[1]}`),this.#l(o,"insights.test",String(u.method||u.test||""));const r=u.effectSize||{};this.#l(o,"insights.effect",`${r.name||""} ${k(r.value)}`.trim());const t=u.interval;let n="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const s=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";n=`${k(t.lower)} – ${k(t.upper)}${s}`}const i=this.#l(o,"insights.interval",n);return t&&t.method&&i.appendChild(z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(u.pValue)&&this.#l(o,"insights.pValue",k(u.pValue)),o}#a(){if(!U(this.host.anomalies))return null;let u;try{u=this.host.anomalies()}catch{return null}if(!u)return null;const o=this.#c("insights.anomalies");o.appendChild(z(this.doc,"p",{class:`${N.panel}__count`,text:this.t("insights.anomalyCount",{count:u.flagged||0,n:u.n||0})}));const r=z(this.doc,"dl",{class:`${N.panel}__stats`});this.#l(r,"insights.anomalyMethod",String(u.method||""));const t=this.#s(u);t!==null&&this.#l(r,"insights.anomalyThreshold",k(t)),o.appendChild(r);const n=(u.rows||[]).map(i=>({name:i.rowKey!=null?String(i.rowKey):`#${i.index}`,measure:(i.why||[]).map(s=>s.name||s.column).join(", "),magnitude:i.score}));return o.appendChild(this.#r(n)),o}#s(u){if(u.method==="mahalanobis")return Number.isFinite(u.cutoff)?u.cutoff:null;if(u.method==="iqr")return Number.isFinite(u.k)?u.k:null;const o=Array.isArray(u.columns)?u.columns[0]:null;return o&&Number.isFinite(o.threshold)?o.threshold:null}#l(u,o,r){u.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(o)}));const t=z(this.doc,"dd",{class:`${N.panel}__stat-value`});return t.appendChild(z(this.doc,"span",{text:r})),u.appendChild(t),t}#u(){if(!U(this.host.columnCapability)||!this.column)return null;const u=this.host.columnCapability(this.column);if(!u)return null;const o=this.#c("stats.section.capability"),r=z(this.doc,"dl",{class:`${N.panel}__stats`});for(const t of L){const n=u[t.field];if(n==null)continue;r.appendChild(z(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(t.key)}));const i=[z(this.doc,"span",{text:k(n)})],s=t.interval?u[t.interval]:null;s&&Number.isFinite(s.lower)&&i.push(z(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${k(s.lower)} – ${k(s.upper)}`,attrs:{title:`${Math.round(s.confidence*100)}%`}})),r.appendChild(z(this.doc,"dd",{class:`${N.panel}__stat-value`,children:i}))}return o.appendChild(r),o}#c(u){const o=this.doc.createElement("div");return o.appendChild(z(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t(u)})),o}#d(u,o,r,t){const n=z(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const i of o)n.appendChild(z(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(F(n,"change",()=>t(n.value))),z(this.doc,"label",{class:`${N.panel}__field`,children:[z(this.doc,"span",{class:`${N.panel}__label`,text:this.t(u)}),n]})}}}),ve("packages/dom/src/ui/toolpanel.js",function(e,V){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.cssEscape,F=Z.documentFor,W=Z.el,_=Z.on,U=Z.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,L=V("packages/core/src/internal/util.js"),k=L.isFunction,S=L.nextFrame,y=V("packages/dom/src/cell/icons.js"),u=y.createIcon,o=y.updateIcon,r=y.icon,n=V("packages/dom/src/viewpicker.js").ViewPicker,s=V("packages/dom/src/formattingpanel.js").FormattingPanel,d=V("packages/dom/src/statisticspanel.js").StatisticsPanel,h=V("packages/dom/src/regressionpanel.js").RegressionPanel,w=V("packages/dom/src/comparepanel.js").ComparePanel,m=V("packages/dom/src/insightspanel.js").InsightsPanel,v=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,a=V("packages/core/src/compute/total.js").TOTAL_LABELS;class O extends v{dragging=null;refresh(){const j=this.root;if(!j)return;for(const Q of this.off)Q();this.off.length=0,U(j);const E=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(_(E,"input",()=>{this.query=E.value,this.paintList()})),j.appendChild(E),j.appendChild(this.buildZone("group","Row groups")),j.appendChild(this.buildZone("values","Grouped row calculation")),j.appendChild(this.buildZone("pivot","Pivot"));const $=W(this.doc,"div",{class:`${N.panel}__heading`});$.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),X=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(_(q,"click",()=>{const Q=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.showColumns)&&this.host.showColumns(Q),this.refresh()})),this.off.push(_(X,"click",()=>{const Q=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.hideColumns)&&this.host.hideColumns(Q),this.refresh()})),$.appendChild(q),$.appendChild(X),j.appendChild($),this.list=W(this.doc,"div",{class:`${N.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),j.appendChild(this.list),this.paintList()}columns(){const j=this.host;return k(j.columns)?j.columns()||[]:j.columns&&k(j.columns.all)?j.columns.all():[]}paintList(){const j=this.list;if(!j)return;U(j);const E=String(this.query||"").trim().toLowerCase();for(const $ of this.columns()){const q=String($.title||$.id||"");if(E&&!q.toLowerCase().includes(E))continue;const X=W(this.doc,"div",{class:`${N.panel}__column`,attrs:{"data-col":$.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});X.appendChild(W(this.doc,"span",{class:`${N.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Q=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});Q.checked=!($.layout&&$.layout.hidden),$.layout&&$.layout.lockVisible&&Q.setAttribute("disabled",""),this.off.push(_(Q,"change",()=>this.setVisible($.id,Q.checked))),X.appendChild(Q),X.appendChild(W(this.doc,"span",{text:q})),X.setAttribute("tabindex","0"),X.setAttribute("role","listitem"),this.off.push(_(X,"keydown",J=>this.onRowKey(J,$))),this.off.push(_(X,"dragstart",()=>{this.dragging=$.id})),this.off.push(_(X,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(_(X,"dragover",J=>{if(!this.dragging||this.dragging===$.id)return;k(J.preventDefault)&&J.preventDefault();const ne=I(J,X);X.setAttribute("data-drop",ne?"before":"after")})),this.off.push(_(X,"dragleave",()=>X.removeAttribute("data-drop"))),this.off.push(_(X,"drop",J=>{k(J.preventDefault)&&J.preventDefault();const ne=this.dragging;this.dragging=null,this.clearDropMark(),!(!ne||ne===$.id)&&this.moveColumn(ne,$.id,I(J,X))})),j.appendChild(X)}}onRowKey(j,E){const $=j&&j.key,q=O.zoneKeys[String($).toLowerCase()];if(q&&!j.ctrlKey&&!j.metaKey&&!j.altKey){k(j.preventDefault)&&j.preventDefault(),this.toggleZone(q,E);return}if($!=="ArrowUp"&&$!=="ArrowDown")return;const X=$==="ArrowUp",Q=this.columns().map(te=>te.id),J=Q.indexOf(E.id);if(J<0)return;if(k(j.preventDefault)&&j.preventDefault(),!j.shiftKey){const te=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ce=te.findIndex(ae=>ae.getAttribute("data-col")===E.id),ue=te[ce+(X?-1:1)];ue&&k(ue.focus)&&ue.focus();return}const ne=E.layout&&(E.layout.movable===!1||E.layout.lockPosition),re=String(E.title||E.id||"");if(ne){this.announce(this.t("a11y.panel.cannotMove",{column:re}),{repeat:!0});return}const oe=Q[J+(X?-1:1)];if(!oe){this.announce(this.t(X?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:re}),{repeat:!0});return}this.moveColumn(E.id,oe,X),this.announce(this.t("a11y.panel.moved",{column:re,at:X?J:J+2,of:Q.length}),{repeat:!0});const ie=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${z(E.id)}"]`):null;ie&&k(ie.focus)&&ie.focus()}toggleZone(j,E){const $=this.titleOf(E.id),q=this.t(O.zoneLabel[j]||"panel.zone.group");if(this.zoneColumns(j).includes(E.id)){this.dropFromZone(j,E.id),this.announce(this.t("a11y.panel.removedFrom",{column:$,list:q}),{repeat:!0}),this.restoreFocus(E.id);return}if(this.addToZone(j,E.id)){this.announce(this.t("a11y.panel.addedTo",{column:$,list:q}),{repeat:!0}),this.restoreFocus(E.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:$,list:q}),{repeat:!0})}restoreFocus(j){const E=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${z(j)}"]`):null;E&&k(E.focus)&&E.focus()}announce(j,E){const $=this.host||{};k($.announce)&&$.announce(j,E)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const j of this.list.querySelectorAll("[data-drop]"))j.removeAttribute("data-drop")}moveColumn(j,E,$){const q=this.host||{};k(q.moveColumn)&&(q.moveColumn(j,E,$),this.refresh())}buildZone(j,E){const $=W(this.doc,"div",{class:`${N.panel}__zone`,attrs:{"data-zone":j,role:"group","aria-label":E}});$.appendChild(W(this.doc,"div",{class:`${N.panel}__zoneTitle`,text:E}));const q=this.zoneColumns(j);let X=O.zoneAbout[j]||"";j==="values"&&q.length&&!this.zoneColumns("group").length&&(X+=" Add a row group to see them."),X&&$.appendChild(W(this.doc,"div",{class:`${N.panel}__zoneAbout`,text:X}));const Q=W(this.doc,"div",{class:`${N.panel}__zoneBody`});q.length||Q.appendChild(W(this.doc,"span",{class:`${N.panel}__zoneHint`,text:this.t(O.zoneHint[j]||"panel.zoneHint.any")})),j==="values"&&Q.classList.add(`${N.panel}__zoneBody--rows`);for(const J of q){const ne=W(this.doc,"span",{class:[N.chip,j==="values"?`${N.chip}--row`:""]});if(ne.appendChild(W(this.doc,"span",{class:`${N.chip}__label`,text:this.titleOf(J)})),j==="values"&&k(this.host.setValueAggregation)){const oe=k(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ie=W(this.doc,"select",{class:`${N.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const te of O.aggregations)ie.appendChild(W(this.doc,"option",{text:this.t(`total.${te.name}`),attrs:{value:te.name,selected:te.name===oe?"":null}}));ie.value=oe,this.off.push(_(ie,"change",()=>{this.host.setValueAggregation(J,ie.value),this.refresh()})),ne.appendChild(ie)}const re=W(this.doc,"button",{class:N.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(_(re,"click",()=>this.dropFromZone(j,J))),ne.appendChild(re),Q.appendChild(ne)}return this.off.push(_($,"dragover",J=>{k(J.preventDefault)&&J.preventDefault(),$.setAttribute("data-over","true")})),this.off.push(_($,"dragleave",()=>$.removeAttribute("data-over"))),this.off.push(_($,"drop",J=>{k(J.preventDefault)&&J.preventDefault(),$.removeAttribute("data-over"),this.dragging&&this.addToZone(j,this.dragging)})),$.appendChild(Q),$}static aggregations=Object.freeze(Object.keys(a).map(j=>({name:j})));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(j){const E=O.zoneApi[j],$=this.host;return E&&k($[E.read])?$[E.read]()||[]:[]}titleOf(j){const E=this.columns().find($=>$.id===j);return String(E&&(E.title||E.id)||j)}addToZone(j,E){const $=O.zoneApi[j],q=this.columns().find(Q=>Q.id===E);if(!$||!q||q[$.permission]===!1||!k(this.host[$.write]))return!1;const X=this.zoneColumns(j);return X.includes(E)?!1:(this.host[$.write]([...X,E]),this.refresh(),!0)}dropFromZone(j,E){const $=O.zoneApi[j];return!$||!k(this.host[$.write])?!1:(this.host[$.write](this.zoneColumns(j).filter(q=>q!==E)),this.refresh(),!0)}setVisible(j,E){const $=this.host;E&&k($.showColumns)?$.showColumns([j]):!E&&k($.hideColumns)&&$.hideColumns([j])}}class T extends v{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 j=this.root;if(!j)return;for(const ne of this.off)ne();this.off.length=0,U(j);const E=this.host,$=(k(E.columns)?E.columns():[]).filter(ne=>!(ne.filter&&ne.filter.enabled===!1));if(!k(E.filterFor))return;const q=$.filter(ne=>this.isFiltered(ne.id));j.appendChild(this.buildSearch()),j.appendChild(this.buildSummary(q.length,$.length));const X=this.query.trim().toLowerCase(),Q=X?$.filter(ne=>String(ne.title||ne.id).toLowerCase().includes(X)):$;if(!Q.length){j.appendChild(W(this.doc,"p",{class:`${N.panel}__empty`,text:X?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${N.panel}__filters`});for(const ne of Q)J.appendChild(this.buildSection(ne));j.appendChild(J)}isFiltered(j){const E=this.host;return k(E.isFiltered)?E.isFiltered(j)===!0:!1}buildSearch(){const j=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return j.value=this.query,this.off.push(_(j,"input",()=>{this.query=j.value||"",this.refresh();const E=this.root&&this.root.querySelector?this.root.querySelector(`.${N.panel}__search`):null;E&&k(E.focus)&&E.focus()})),j}buildSummary(j,E){const $=W(this.doc,"div",{class:`${N.panel}__filterSummary`});if($.appendChild(W(this.doc,"span",{class:`${N.panel}__filterCount`,text:j?this.t("panel.filterSummaryActive",{active:j,total:E}):this.t("panel.filterSummaryNone",{total:E}),attrs:{"data-active":j?"true":"false"}})),!j)return $;const q=W(this.doc,"button",{class:`${N.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(_(q,"click",()=>{k(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),$.appendChild(q),$}buildSection(j){const E=j.id,$=String(j.title||E),q=this.isFiltered(E),X=this.open.has(E),Q=W(this.doc,"section",{class:`${N.panel}__filter`,attrs:{"data-col":E,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${N.panel}__filterTitle`,attrs:{type:"button","aria-expanded":X?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:$})},children:[u(this.doc,X?"chevronDown":"chevronRight",{className:`${N.panel}__twisty`}),W(this.doc,"span",{class:`${N.panel}__filterName`,text:$})]});q&&J.appendChild(W(this.doc,"span",{class:`${N.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ne=W(this.doc,"div",{class:`${N.panel}__filterBody`,style:{display:X?"":"none"}}),re=()=>{if(ne.firstChild)return;const oe=this.host.filterFor(E);oe&&k(oe.element)&&ne.appendChild(oe.element())};if(this.off.push(_(J,"click",()=>{const oe=this.open.has(E);oe?this.open.delete(E):this.open.add(E),J.setAttribute("aria-expanded",oe?"false":"true"),ne.style.display=oe?"none":"";const ie=J.firstElementChild;ie&&o(ie,oe?"chevronRight":"chevronDown"),oe||re()})),Q.appendChild(J),q){const oe=W(this.doc,"button",{class:`${N.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:$}),title:this.t("panel.clearFilter")},children:[u(this.doc,"close",{className:N.icon})]});this.off.push(_(oe,"click",ie=>{k(ie.stopPropagation)&&ie.stopPropagation(),k(this.host.clearFilter)&&this.host.clearFilter(E),this.refresh()})),Q.appendChild(oe)}return Q.appendChild(ne),X&&re(),Q}}class A extends v{refresh(){const j=this.root;if(!j)return;if(this.box){const X=k(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==X&&(this.box.value=X),this.paintCount();return}for(const X of this.off)X();this.off.length=0,U(j);const E=k(this.host.quickFilter)?this.host.quickFilter():"",$=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});$.value=E||"",this.off.push(_($,"input",()=>{k(this.host.setQuickFilter)&&this.host.setQuickFilter($.value),this.paintCount()})),j.appendChild($),this.box=$;const q=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(_(q,"click",()=>{$.value="",k(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),k($.focus)&&$.focus()})),j.appendChild(q),this.count=W(this.doc,"p",{class:`${N.panel}__count`}),j.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){S(()=>{this.box&&k(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const j=k(this.host.rowCount)?this.host.rowCount():null,E=k(this.host.totalRowCount)?this.host.totalRowCount():null;if(j===null||E===null){this.count.textContent="";return}this.count.textContent=j===E?this.t("count.rows",{count:E}):this.t("panel.rowsOf",{shown:j,total:E})}}const M=Object.freeze({columns:O,filters:T,views:n,quick:A,formatting:s,statistics:d,regression:h,compare:w,insights:m}),C=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"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class x{panels=[];actions=[];root=null;openPanel=null;off=[];t(j,E){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(j,E)}init(j){const E=j||{};this.doc=F(E),this.host=E.host||{},this.messages=E.messages||E.grid&&E.grid.messages||H,this.icons=E.icons===void 0?E.side==="left":!!E.icons,this.side=E.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[N.panel,`${N.panel}--${this.side}`,this.icons?`${N.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${N.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${N.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=W(this.doc,"div",{class:`${N.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const X of Array.isArray(E.actions)?E.actions:[])this.registerAction(X);const $=E.registry||{},q=Array.isArray(E.panels)&&E.panels.length?E.panels:["columns","filters"];for(const X of q){const Q=typeof X=="string"?X:X.name,J=typeof X=="function"?X:$[Q]||M[Q];J&&this.registerPanel(String(Q),J,typeof X=="object"?X:{})}E.openPanel&&this.show(E.openPanel)}registerPanel(j,E,$){const q=new E;q.init({document:this.doc,host:this.host,props:$&&$.props||{}});const X=$&&$.title||j,Q=$&&$.icon||j,J=W(this.doc,"button",{class:`${N.panel}__tab`,text:this.icons?null:X,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":j,title:this.icons?X:null,"aria-label":this.icons?X:null}});return this.icons&&J.appendChild(u(this.doc,Q,{className:`${N.panel}__icon`})),this.off.push(_(J,"click",()=>this.toggle(j))),this.tabs.appendChild(J),this.panels.push({name:j,title:X,panel:q}),q}registerAction(j){if(!j||!j.name)return null;if(j.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${N.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const E=W(this.doc,"button",{class:`${N.panel}__action`,text:this.icons?null:k(j.title)?String(j.title()):j.title,attrs:{type:"button","data-action":j.name,title:k(j.title)?null:j.title,"aria-label":k(j.title)?null:j.title}});if(this.icons){const X=(k(j.icon)?j.icon():j.icon)||(r(j.name)?j.name:"blank");E.appendChild(u(this.doc,X,{className:`${N.panel}__icon`})),E.setAttribute("data-icon",X)}const $=_(E,"click",()=>{k(j.enabled)&&!j.enabled()||(k(j.run)&&j.run(),this.paintActions())});return this.off.push($),this.actionGroup.appendChild(E),this.actions.push({...j,button:E,offClick:$}),this.paintActions(),E}removeAction(j){const E=this.actions.findIndex(q=>q.name===j);if(E<0)return!1;const $=this.actions[E];return k($.offClick)&&$.offClick(),$.button&&$.button.parentNode&&$.button.parentNode.removeChild($.button),this.actions.splice(E,1),!0}paintActions(){for(const j of this.actions){if(!j.button)continue;const E=k(j.enabled)?!!j.enabled():!0;if(j.button.disabled=!E,j.button.setAttribute("aria-disabled",E?"false":"true"),k(j.active)&&j.button.setAttribute("aria-pressed",j.active()?"true":"false"),k(j.title)){const $=String(j.title());j.button.setAttribute("title",$),j.button.setAttribute("aria-label",$),!this.icons&&j.button.textContent!==$&&(j.button.textContent=$)}if(this.icons&&k(j.icon)){const $=String(j.icon());j.button.getAttribute("data-icon")!==$&&(U(j.button),j.button.appendChild(u(this.doc,$,{className:`${N.panel}__icon`})),j.button.setAttribute("data-icon",$))}}}show(j){const E=this.panels.find($=>$.name===j);return E?(U(this.body),k(E.panel.refresh)&&E.panel.refresh(),this.body.appendChild(E.panel.element()),this.openPanel=j,this.paintTabs(),k(E.panel.focus)&&E.panel.focus(),!0):!1}hide(){U(this.body),this.openPanel=null,this.paintTabs()}toggle(j){this.openPanel===j?this.hide():this.show(j)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let j=0;j<this.tabs.childNodes.length;j++){const E=this.tabs.childNodes[j];E&&E.setAttribute&&E.setAttribute("aria-selected",E.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const j=this.panels.find(E=>E.name===this.openPanel);j&&k(j.panel.refresh)&&!this.#e(j.panel)&&j.panel.refresh(),this.paintActions()}#e(j){const E=this.doc&&this.doc.activeElement;if(!E||E===this.doc.body)return!1;const $=k(j.element)?j.element():null;return!!($&&k($.contains)&&$.contains(E))}destroy(){for(const j of this.off)j();this.off.length=0;for(const j of this.panels)k(j.panel.destroy)&&j.panel.destroy();this.panels=[],this.root=null}}const K=x;function I(D,j){if(!j.getBoundingClientRect||typeof D.clientY!="number")return!0;const E=j.getBoundingClientRect();return D.clientY<E.top+E.height/2}}),ve("packages/dom/src/ui/groupbyzone.js",function(e,V){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return S}});const N=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=V("packages/dom/src/editors/common.js"),F=z.CLS,W=z.el,_=z.on,U=z.clear,B=z.cssEscape,L=V("packages/core/src/internal/util.js").isFunction,k="text/x-lattice-col";class S extends N{dragging=null;#e=[];init(u){this.ctx=u,this.doc=u.document,this.host=u.host||{},this.props=u.props||{},this.root=W(this.doc,"div",{class:F.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const u=this.host;return L(u.columns)?u.columns()||[]:u.columns&&L(u.columns.all)?u.columns.all():[]}groups(){return L(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(u){L(this.host.setGroupBy)&&this.host.setGroupBy(u)}titleOf(u){const o=this.columns().find(r=>r.id===u);return String(o&&(o.title||o.id)||u)}canGroup(u){const o=this.columns().find(r=>r.id===u);return!!o&&o.allowGroup!==!1&&!o.generated}announce(u,o){L(this.host.announce)&&this.host.announce(u,o)}refresh(){const u=this.root;if(!u)return;for(const t of this.off)t();this.off.length=0,U(u),u.appendChild(W(this.doc,"span",{class:F.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const o=this.groups(),r=W(this.doc,"div",{class:F.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});o.length||r.appendChild(W(this.doc,"span",{class:F.groupZoneHint,text:this.t("groupZone.hint")})),o.forEach((t,n)=>r.appendChild(this.#t(t,n,o.length))),u.appendChild(r),this.chips=r,u.appendChild(this.#i(o)),this.off.push(_(u,"dragover",t=>{this.dragging==null&&!this.#s(t)||(L(t.preventDefault)&&t.preventDefault(),u.setAttribute("data-over","true"))})),this.off.push(_(u,"dragleave",()=>u.removeAttribute("data-over"))),this.off.push(_(u,"drop",t=>{L(t.preventDefault)&&t.preventDefault(),u.removeAttribute("data-over");const n=this.#s(t)||this.dragging;n!=null&&this.#o(n,this.groups().length)})),this.#a()}#t(u,o,r){const t=this.titleOf(u),n=W(this.doc,"div",{class:[F.chip,F.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":u,"aria-label":this.t("groupZone.chip",{column:t,at:o+1,of:r})}});n.appendChild(W(this.doc,"span",{class:F.groupZoneChipText,text:t}));const i=W(this.doc,"button",{class:F.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(_(i,"click",()=>this.#r(u))),n.appendChild(i),this.off.push(_(n,"dragstart",s=>{this.dragging=u,s.dataTransfer&&L(s.dataTransfer.setData)&&s.dataTransfer.setData(k,u)})),this.off.push(_(n,"dragend",()=>{this.dragging=null})),this.off.push(_(n,"dragover",s=>{const c=this.#s(s)||this.dragging;c==null||c===u||L(s.preventDefault)&&s.preventDefault()})),this.off.push(_(n,"drop",s=>{const c=this.#s(s)||this.dragging;c!=null&&(L(s.preventDefault)&&s.preventDefault(),L(s.stopPropagation)&&s.stopPropagation(),this.#o(c,o))})),this.off.push(_(n,"keydown",s=>this.#n(s,u,o))),n}#n(u,o,r){const t=u&&u.key,n=this.groups();if(t==="Delete"||t==="Backspace"){L(u.preventDefault)&&u.preventDefault(),this.#r(o,n,r);return}const i=t==="ArrowLeft"||t==="ArrowUp",s=t==="ArrowRight"||t==="ArrowDown",c=t==="Home",d=t==="End";if(!i&&!s&&!c&&!d)return;if(L(u.preventDefault)&&u.preventDefault(),u.shiftKey&&(i||s)){const g=r+(i?-1:1);if(g<0||g>=n.length){this.announce(this.t(i?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(o)}),{repeat:!0});return}const w=n.slice();w.splice(r,1),w.splice(g,0,o),this.setGroups(w),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(o),at:g+1,of:w.length}),{repeat:!0}),this.#l(o);return}let f=r+(i?-1:s?1:0);c&&(f=0),d&&(f=n.length-1);const h=n[f];h&&this.#l(h)}#r(u,o=this.groups(),r=o.indexOf(u)){const t=this.titleOf(u);this.setGroups(o.filter(i=>i!==u)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const n=this.groups();n.length?this.#l(n[Math.min(r,n.length-1)]):this.#u()}#o(u,o){if(!this.canGroup(u)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0});return}const r=this.groups(),t=r.indexOf(u),n=r.slice();t>=0&&(n.splice(t,1),t<o&&(o-=1)),n.splice(Math.max(0,Math.min(o,n.length)),0,u),this.setGroups(n);const i=n.indexOf(u);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(u),at:i+1,of:n.length}:{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0}),this.#l(u)}#i(u){const o=new Set(u),r=W(this.doc,"label",{class:F.groupZoneAdd}),t=W(this.doc,"select",{class:F.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const n of this.columns())o.has(n.id)||!this.canGroup(n.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(n.id),attrs:{value:n.id}}));return this.off.push(_(t,"change",()=>{const n=t.value;n&&this.#o(n,this.groups().length)})),this.adderSelect=t,r.appendChild(t),r}#a(){for(const o of this.#e)o();this.#e.length=0;const u=this.props&&this.props.header;if(!(!u||!L(u.querySelectorAll)))for(const o of u.querySelectorAll("[data-col]")){const r=L(o.getAttribute)?o.getAttribute("data-col"):null;!r||!this.canGroup(r)||(L(o.setAttribute)&&o.setAttribute("draggable","true"),this.#e.push(_(o,"dragstart",t=>{this.dragging=r,t.dataTransfer&&L(t.dataTransfer.setData)&&t.dataTransfer.setData(k,r)})),this.#e.push(_(o,"dragend",()=>{this.dragging=null})))}}#s(u){const o=u&&u.dataTransfer;if(o&&L(o.getData)){const r=o.getData(k);if(r)return r}return null}#l(u){const o=this.chips&&L(this.chips.querySelector)?this.chips.querySelector(`[data-col="${B(u)}"]`):null;o&&L(o.focus)&&o.focus()}#u(){this.adderSelect&&L(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const u of this.#e)u();this.#e.length=0,super.destroy()}}}),ve("packages/dom/src/ui/tooltip.js",function(e,V){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction;class H{root=null;init(y){this.doc=y.document,this.root=F(this.doc,"div",{class:`${N.tooltip}__text`}),this.update(y.content)}update(y){if(!this.root)return;const u=y==null?"":String(y);this.root.textContent!==u&&(this.root.textContent=u)}element(){return this.root}destroy(){this.root=null}}class L{root=null;component=null;timer=null;target=null;off=[];constructor(y){const u=y||{};this.doc=z(u),this.host=u.host||this.doc.body,this.delay=u.delay??400,this.hideDelay=u.hideDelay??0,this.components={text:H,...u.components||{}}}show(y){this.cancelTimer();const u=y.delay??this.delay;if(!u){this.showNow(y);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(y)},u)}showNow(y){const u=y.component||"text",o=typeof u=="function"?u:this.components[u]||H;return this.root||(this.root=F(this.doc,"div",{class:N.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==o?(this.component&&B(this.component.destroy)&&this.component.destroy(),_(this.root),this.component=new o,this.componentCtor=o,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):B(this.component.update)&&this.component.update(y.content),this.target=y.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!B(this.target.getBoundingClientRect))return;const y=this.target.getBoundingClientRect(),u=this.doc.defaultView||{};this.root.style.left=`${y.left+(u.scrollX||0)}px`,this.root.style.top=`${y.bottom+(u.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(y,u,o){const r=()=>this.show({target:y,content:u(),...o||{}}),t=()=>this.hide(),n=[W(y,"mouseenter",r),W(y,"mouseleave",t),W(y,"focus",r),W(y,"blur",t)],i=()=>{for(const s of n)s()};return this.off.push(i),i}destroy(){this.hide();for(const y of this.off)y();this.off.length=0,this.component&&B(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const k=L}),ve("packages/dom/src/ui/pagination.js",function(e,V){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/i18n/index.js").defaultMessages,L=V("packages/core/src/internal/util.js").isFunction;function k(u){const o=Math.max(1,Number(u.pageSize)||100),r=u.total==null?null:Math.max(0,Number(u.total)),t=r==null?null:Math.max(1,Math.ceil(r/o)),n=Math.max(0,t==null?Number(u.page)||0:Math.min(Number(u.page)||0,t-1)),i=r===0?0:n*o+1,s=r==null?(n+1)*o:Math.min(r,(n+1)*o);return{page:n,pageSize:o,pageCount:t,from:i,to:s,first:n===0,last:t==null?u.hasMore!==!0:n>=t-1,total:r}}class S{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(o){const r=o||{};this.doc=z(r),this.host=r.host||{},this.pageSize=Number(r.pageSize)||100;const t=Array.isArray(r.pageSizes)&&r.pageSizes.length?[...r.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((n,i)=>n-i),this.page=Number(r.page)||0,this.total=r.total===void 0?null:r.total,this.locale=r.locale,this.messages=r.messages||null,this.onChange=r.onChange||null,this.root=F(this.doc,"nav",{class:N.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(o,r){const t=this.messages;return(t&&typeof t.t=="function"?t:B).t(o,r)}element(){return this.root}model(){return k({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(o){o.total!==void 0&&(this.total=o.total),o.counting!==void 0&&(this.counting=o.counting===!0),o.hasMore!==void 0&&(this.hasMore=o.hasMore===!0),o.page!==void 0&&(this.page=Number(o.page)||0),this.paint()}goTo(o){const r=this.page;this.page=o;const t=this.model();return this.page=t.page,this.paint(),this.page!==r&&L(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 o=this.model();return o.pageCount==null?this.page:this.goTo(o.pageCount-1)}setPageSize(o){const r=this.page*this.pageSize;this.pageSize=Math.max(1,Number(o)||1),this.page=Math.floor(r/this.pageSize),this.paint(),L(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const o=this.root;if(!o)return;for(const f of this.off)f();this.off.length=0,_(o);const r=this.model(),t=F(this.doc,"select",{class:`${N.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const f of this.pageSizes)t.appendChild(F(this.doc,"option",{text:String(f),attrs:{value:f}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),o.appendChild(t);const n=r.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:r.from,to:r.to}):this.t("pagination.summary",{from:r.from,to:r.to,total:r.total});o.appendChild(F(this.doc,"span",{class:`${N.pagination}__summary`,text:n}));const i=(f,h,g,w)=>{const p=F(this.doc,"button",{class:`${N.pagination}__button`,text:f,attrs:{type:"button","aria-label":w,disabled:g?"":null}});return g||this.off.push(W(p,"click",h)),p};o.appendChild(i("«",()=>this.goTo(0),r.first,this.t("pagination.first"))),o.appendChild(i("‹",()=>this.previous(),r.first,this.t("pagination.previous")));const s=F(this.doc,"span",{class:`${N.pagination}__page`});s.appendChild(F(this.doc,"span",{text:`${this.t("pagination.page")} `}));const c=F(this.doc,"input",{class:`${N.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":r.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:r.pageCount}),size:String(Math.max(2,String(r.pageCount??r.page+1).length))}});c.value=String(r.page+1);const d=()=>{const f=parseInt(String(c.value).trim(),10);if(!Number.isFinite(f)){c.value=String(this.model().page+1);return}this.goTo(f-1)};this.off.push(W(c,"keydown",f=>{f.key==="Enter"?(d(),f.preventDefault?.()):f.key==="Escape"?(c.value=String(this.model().page+1),c.blur?.()):f.stopPropagation?.()})),this.off.push(W(c,"blur",()=>d())),this.off.push(W(c,"focus",()=>c.select?.())),s.appendChild(c),r.pageCount!=null&&s.appendChild(F(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:r.pageCount})}`})),o.appendChild(s),o.appendChild(i("›",()=>this.next(),r.last,this.t("pagination.next"))),o.appendChild(i("»",()=>this.last(),r.last||r.pageCount==null,this.t("pagination.last")))}destroy(){for(const o of this.off)o();this.off.length=0,this.root=null}}const y=S}),ve("packages/dom/src/ui/overlay.js",function(e,V){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),N=Z.CLS,z=Z.documentFor,F=Z.el,W=Z.clear,U=V("packages/core/src/internal/util.js").isFunction,H=V("packages/core/src/i18n/index.js").defaultMessages;function L(r,t){const n=r&&r.grid&&r.grid.messages;return(n&&U(n.t)?n:H).t(t)}class k{root=null;init(t){this.doc=t.document,this.root=F(this.doc,"div",{class:`${N.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[F(this.doc,"span",{class:`${N.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),F(this.doc,"span",{class:`${N.overlay}__message`,text:t.message||L(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class S{root=null;init(t){this.doc=t.document,this.root=F(this.doc,"div",{class:`${N.overlay}__empty`,attrs:{role:"status"},children:[F(this.doc,"span",{class:`${N.overlay}__message`,text:t.message||L(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:k,empty:S});class u{root=null;slot=null;component=null;current=null;init(t){const n=t||{};this.doc=z(n),this.components={...y,...n.components||{}},this.root=F(this.doc,"div",{class:N.overlay,attrs:{"data-open":"false"}}),this.slot=F(this.doc,"div",{class:`${N.overlay}__slot`}),this.root.appendChild(this.slot),n.host&&n.host.appendChild(this.root)}element(){return this.root}show(t,n){const i=typeof t=="function"?t:this.components[t];return i?(this.hide(),this.component=new i,this.component.init({document:this.doc,message:n&&n.message,...n&&n.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof t=="string"?t:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&U(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&W(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(t,n){this.components[t]=n}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const o=u}),ve("packages/dom/src/ui/index.js",function(e,V){"use strict";const Z=V("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Z.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Z.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Z.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Z.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Z.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Z.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Z.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Z.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Z.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Z.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Z.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Z.formatNumber}});const N=V("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return N.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return N.resolveMenuItems}});const z=V("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return z.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return z.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return z.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return z.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return z.toolPanels}});const F=V("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return F.GroupByZone}});const W=V("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return W.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return W.TextTooltip}});const _=V("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return _.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return _.pageModel}});const U=V("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return U.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return U.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return U.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return U.overlays}})}),ve("packages/dom/src/ui/celltooltip.js",function(e,V){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Z=V("packages/dom/src/editors/common.js"),N=Z.documentFor,z=Z.el,F=Z.on,W=Z.clear,_=V("packages/core/src/internal/util.js"),U=_.isFunction,B=_.warnOnce,L=V("packages/dom/src/cell/sanitise.js").sanitiseHtml,S=V("packages/dom/src/detailhost.js").insideDetail,u=V("packages/dom/src/renderer/renderer.js").displayIndexOf,o=V("packages/dom/src/renderer/viewport.js"),r=o.CLASS,t=o.NAMESPACE,n={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"},i=400,s=140,c=6;let d=0;class f{#e;#t;#n;#r;#o=null;#i=null;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(w){const p=w||{};this.#e=p.grid,this.#t=p.host,this.#n=p.viewport,this.#r=N(p),d+=1,this.#a=`lat-cell-tooltip-${d}`}mount(){const w=this.#n&&this.#n.root;if(!w||!U(w.addEventListener))return;const p=this.#e.on("cell:mouseover",v=>this.#b(v));U(p)&&this.#f.push(p);const m=this.#e.on("cell:mouseout",()=>this.#j());U(m)&&this.#f.push(m),this.#f.push(F(w,"focusin",v=>this.#y(v))),this.#f.push(F(w,"focusout",()=>this.#j())),this.#f.push(F(this.#r,"keydown",v=>this.#w(v),!0));const b=this.#r.defaultView;b&&U(b.addEventListener)&&this.#f.push(F(b,"scroll",()=>this.hide(),!0))}#p(){const w=U(this.#e.get)?this.#e.get("tooltip"):null,p=w&&typeof w=="object"?w:{},m=Number.isFinite(p.delay)&&p.delay>=0?Number(p.delay):i,b=p.maxWidth;return{delay:m,hideDelay:s,maxWidth:typeof b=="number"&&Number.isFinite(b)?`${b}px`:typeof b=="string"&&b?b:null}}#g(w){const p=w&&w.cell?w.cell.tooltip:null;return!p||typeof p!="object"||Array.isArray(p)||!U(p.render)&&!U(p.mount)?null:p}#v(w){if(!w||!U(w.closest))return null;const p=w.closest(`.${r.row}`);if(!p)return null;const m=u(p);if(m<0)return null;const b=this.#t.rowAt(m);if(!b)return null;const v=w.getAttribute("data-col");if(!v)return null;const l=this.#t.columns.get(v);return l?{row:b,key:b.key,index:m,colId:v,column:l,value:this.#t.cellValue?this.#t.cellValue(b,l):void 0,text:this.#t.cellText?this.#t.cellText(b,l):"",cell:w,grid:this.#e}:null}#b(w){const p=w&&w.target;if(!this.#g(w&&w.column)){this.#j();return}this.#S(p)}#y(w){const p=w&&w.target;if(!p||!U(p.closest)||S(p,this.#n.root))return;const m=p.closest(`.${r.cell}`);if(!m||m!==p){this.#j();return}const b=m.getAttribute("data-col"),v=b?this.#t.columns.get(b):null;if(!this.#g(v)){this.#j();return}this.#S(m)}#w(w){!w||w.key!=="Escape"||w.defaultPrevented||this.#s&&(U(w.preventDefault)&&w.preventDefault(),this.hide())}#S(w){if(this.#m||!w||(this.#N(),this.#s&&this.#l===w))return;this.#R();const{delay:p}=this.#p();if(!p){this.#E(w);return}this.#d=setTimeout(()=>{this.#d=null,this.#E(w)},p)}#j(){if(this.#R(),!this.#s||this.#h!==null)return;const{hideDelay:w}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},w)}#A(){if(this.#o)return this.#o;const w=this.#r,p=z(w,"div",{class:[t,n.tooltip],attrs:{id:this.#a,role:"tooltip","data-open":"false"}});this.#i=z(w,"div",{class:n.body}),p.appendChild(this.#i),this.#f.push(F(p,"mouseenter",()=>this.#N())),this.#f.push(F(p,"mouseleave",()=>this.#j()));const m=w.body;return m&&U(m.appendChild)&&m.appendChild(p),this.#o=p,p}#O(w,p){const m=this.#i;if(W(m),w==null||w==="")return!1;if(typeof w=="string")return m.textContent=w,!0;if(typeof w=="object"){if(typeof w.nodeType=="number")return m.appendChild(w),!0;const b=w;if(typeof b.html=="string")return m.innerHTML=L(b.html),!0;if(b.title!==void 0||b.rows!==void 0||b.note!==void 0)return this.#C(b),!0}return B(`tooltip-content:${p}`,`Column '${p}' 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}#C(w){const p=this.#r,m=this.#i,b=l=>l==null?"":String(l);w.title!==void 0&&w.title!==null&&w.title!==""&&m.appendChild(z(p,"div",{class:n.title,text:b(w.title)}));const v=Array.isArray(w.rows)?w.rows:[];if(v.length){const l=z(p,"div",{class:n.rows});for(const a of v){if(!a||typeof a!="object")continue;const O=z(p,"div",{class:n.row});O.appendChild(z(p,"span",{class:n.label,text:b(a.label)})),O.appendChild(z(p,"span",{class:n.value,text:b(a.value)})),l.appendChild(O)}m.appendChild(l)}w.note!==void 0&&w.note!==null&&w.note!==""&&m.appendChild(z(p,"div",{class:n.note,text:b(w.note)}))}#E(w){if(this.#m)return;const p=this.#v(w);if(!p){this.hide();return}const m=this.#g(p.column);if(!m){this.hide();return}this.hide();const b=this.#A();let v;if(U(m.render))try{v=m.render(p)}catch(O){B(`tooltip-render:${p.colId}`,`Column '${p.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const l=this.#O(v,p.colId);if(U(m.mount))try{m.mount(this.#i,p),this.#u=m}catch(O){B(`tooltip-mount:${p.colId}`,`Column '${p.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!l)return;const{maxWidth:a}=this.#p();a&&(b.style.maxWidth=a),this.#l=w,this.#s=!0,b.setAttribute("data-open","true"),this.#T(w),this.#x(w)}#T(w){if(!U(w.setAttribute))return;const p=U(w.getAttribute)?w.getAttribute("aria-describedby"):null;this.#c={cell:w,previous:p},w.setAttribute("aria-describedby",p?`${p} ${this.#a}`:this.#a)}#x(w){const p=this.#o;if(!p||!U(w.getBoundingClientRect))return;const m=this.#r.defaultView;if(!m)return;const b=w.getBoundingClientRect(),v=U(p.getBoundingClientRect)?p.getBoundingClientRect():{width:0,height:0},l=m.innerWidth||0,a=m.innerHeight||0,O=v.width||0,T=v.height||0;let A=b.bottom+c;const M=b.top-c-T;A+T>a-c&&M>=c&&(A=M),a&&(A=Math.max(c,Math.min(A,Math.max(c,a-T-c))));let C=b.left;l&&(C=Math.min(C,Math.max(c,l-O-c))),C=Math.max(c,C),p.style.left=`${Math.round(C)}px`,p.style.top=`${Math.round(A)}px`}hide(){if(this.#R(),this.#N(),!this.#s)return;if(this.#s=!1,this.#u&&U(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(p){B("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",p)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const w=this.#c;w&&U(w.cell.setAttribute)&&(w.previous?w.cell.setAttribute("aria-describedby",w.previous):U(w.cell.removeAttribute)&&w.cell.removeAttribute("aria-describedby")),this.#c=null,this.#l=null}#R(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#N(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const w of this.#f)w();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=f}),ve("packages/dom/src/platform.js",function(e,V){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Z}});function Z(){const N=globalThis.navigator,z=String(N&&(N.userAgentData?.platform||N.platform)||"");return/mac|iphone|ipad/i.test(z)}}),ve("packages/dom/src/columnmenu.js",function(e,V){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return b}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/dom/src/platform.js").macLike,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/dom/src/ui/contextmenu.js").ContextMenu,L=V("packages/core/src/compute/total.js"),k=L.aggregatesFor,S=L.totalLabel,y=10,u=150;function o(v,l){const a=(ne,re)=>(v&&v.messages?v.messages:U).t(ne,re),O=v.columns.get(l);if(!O)return[];const T=v.sort.get(),A=T.find(ne=>ne.col===l),M=O.layout&&O.layout.pin,C=v.state.get().group||[],P=C.includes(l);if(O.generated&&Array.isArray(O.groupedIds))return i(v,O,C);const x=!O.sort||O.sort.enabled!==!1,K=!O.filter||O.filter.enabled!==!1,I=[];x&&I.push({name:a("menu.sortAscending"),icon:"↑",disabled:A&&A.dir==="asc",action:()=>v.sort.set([{col:l,dir:"asc"}])},{name:a("menu.sortDescending"),icon:"↓",disabled:A&&A.dir==="desc",action:()=>v.sort.set([{col:l,dir:"desc"}])},{name:a("menu.clearSort"),disabled:!A,action:()=>v.sort.set(T.filter(ne=>ne.col!==l))},{separator:!0}),K&&I.push({name:a("menu.filterEllipsis"),action:()=>v.emit("column:filter:open",{colId:l})},{separator:!0}),I.push({name:a("menu.columnStatistics"),action:()=>v.emit("column:profile:open",{colId:l})},{separator:!0}),I.push({name:a("menu.pinColumn"),children:[{name:a("menu.pinStart"),disabled:M==="start",action:()=>v.columns.pin(l,"start")},{name:a("menu.pinEnd"),disabled:M==="end",action:()=>v.columns.pin(l,"end")},{name:a("menu.unpin"),disabled:!M,action:()=>v.columns.pin(l,null)}]});const D=!(O.layout&&(O.layout.movable===!1||O.layout.lockPosition)),j=!(O.layout&&O.layout.resizable===!1),E=ne=>{const re=v.columns.get(ne);return Number(re&&re.layout&&re.layout.width)||u},$=v.columns.visible().filter(ne=>!ne.generated).map(ne=>ne.id),q=$.indexOf(l);if(I.push({name:a("menu.sizeToFit"),action:()=>v.columns.autoSize(l)},{name:a("menu.sizeAllToFit"),action:()=>v.columns.fit()},{name:a("menu.width"),disabled:!j,children:[{name:a("menu.narrower"),disabled:!j,action:()=>v.columns.resize(l,Math.max(1,E(l)-y))},{name:a("menu.wider"),disabled:!j,action:()=>v.columns.resize(l,E(l)+y)},{name:a("menu.autosize"),disabled:!j,action:()=>v.columns.autoSize(l)}]},{separator:!0},{name:a("menu.moveColumn"),disabled:!D,children:[{name:a("menu.moveLeft"),disabled:!D||q<=0,action:()=>v.columns.move(l,Math.max(0,q-1))},{name:a("menu.moveRight"),disabled:!D||q<0||q>=$.length-1,action:()=>v.columns.move(l,Math.min($.length-1,q+1))},{name:a("menu.moveToStart"),disabled:!D||q<=0,action:()=>v.columns.move(l,0)},{name:a("menu.moveToEnd"),disabled:!D||q<0||q>=$.length-1,action:()=>v.columns.move(l,$.length-1)}]},{separator:!0}),O.allowGroup!==!1&&I.push({name:a(P?"menu.ungroup":"menu.groupBy"),action:()=>v.columns.group(P?C.filter(ne=>ne!==l):[...C,l])}),C.length&&I.push({name:a("menu.expandAll"),action:()=>v.rows.expandAll()},{name:a("menu.collapseAll"),action:()=>v.rows.collapseAll()}),N(v.columns.groupColumns)){const ne=O.groupPath||[],re=ne.length?ne[ne.length-1]:null,oe=[{name:a("columngroup.group"),disabled:$.length<2||q<0,action:()=>{const ie=$[q+1]??$[q-1];if(!ie)return;const te=(v.columns.get(ie)||{}).groupPath||[],ce=te.length?te[te.length-1]:null;ce?v.columns.groupColumns([l],{groupId:ce}):v.columns.groupColumns([l,ie],{title:a("columngroup.newGroup")})}}];re&&oe.push({name:a("columngroup.dissolve"),action:()=>v.columns.dissolveGroup(re)}),I.push({separator:!0},...oe)}const X=v.state&&N(v.state.get)?v.state.get().pivot:null,Q=X&&X.columns||[],J=Q.includes(l);if(O.allowPivot!==!1&&I.push({name:a(J?"menu.unpivot":"menu.pivotBy"),action:()=>v.columns.pivot(J?Q.filter(ne=>ne!==l):[...Q,l])}),O.allowTotal!==!1)if(N(v.get)&&v.get("aggregateChooser")===!0)I.push(r(v,O,a));else{const re=!!O.total;I.push({name:a(re?"menu.stopTotalling":"menu.totalColumn"),action:()=>v.columns.setTotal(l,re?null:"sum")})}return I.push({name:a("menu.hideColumn"),disabled:O.layout&&O.layout.lockVisible===!0,action:()=>v.columns.hide(l)}),I}function r(v,l,a){const O=l.id,T=typeof l.total=="string"?l.total:null,A=[{name:a("menu.aggregateNone"),checked:!l.total,action:()=>v.columns.setTotal(O,null)},{separator:!0},...k(l).map(M=>({name:S(M),checked:T===M,action:()=>v.columns.setTotal(O,M)})),{separator:!0},t(v,l,a,"group",a("menu.aggregateGroup")),t(v,l,a,"grand",a("menu.aggregateGrand"))];return{name:a("menu.aggregate"),children:A}}function t(v,l,a,O,T){const A=l.id,M=O==="grand"?l.grandTotal:l.groupTotal,C=typeof M=="string"?M:null,P=[{name:a("menu.aggregateSame"),checked:M==null,action:()=>v.columns.setTotal(A,null,{scope:O})},{separator:!0},...k(l).map(x=>({name:S(x),checked:C===x,action:()=>v.columns.setTotal(A,x,{scope:O})}))];return{name:T,children:P}}function n(v,l){const a=(C,P)=>(v&&v.messages?v.messages:U).t(C,P),O=v.columns.get(l);if(!O)return[];const T=v.redaction,A=!!(T&&T.has(l)),M=[];return T&&(M.push({name:a(A?"menu.stopRedacting":"menu.redactColumn"),action:()=>T.toggle(l)}),(T.list().length>1||T.active&&!A)&&M.push({name:a("menu.stopRedactingAll"),action:()=>T.clear()}),M.push({separator:!0})),M.push({name:a("menu.hideColumn"),disabled:O.layout&&O.layout.lockVisible===!0,action:()=>v.columns.hide(l)}),M}function i(v,l,a){const O=(P,x)=>(v&&v.messages?v.messages:U).t(P,x),T=a[0],A=v.sort.get(),M=T?A.find(P=>P.col===T):null,C=[];T&&C.push({name:O("menu.sortGroupsAscending"),icon:"↑",disabled:M&&M.dir==="asc",action:()=>v.sort.set([{col:T,dir:"asc"}])},{name:O("menu.sortGroupsDescending"),icon:"↓",disabled:M&&M.dir==="desc",action:()=>v.sort.set([{col:T,dir:"desc"}])},{separator:!0},{name:O("menu.filterGroups"),action:()=>v.emit("column:filter:open",{colId:l.id})},{separator:!0}),C.push({name:O("menu.expandAll"),action:()=>v.rows.expandAll()},{name:O("menu.collapseAll"),action:()=>v.rows.collapseAll()},{separator:!0});for(const P of a){const x=v.columns.get(P);C.push({name:`Remove "${x&&x.title||P}" from grouping`,action:()=>v.columns.group(a.filter(K=>K!==P))})}return C.push({name:O("menu.clearGrouping"),disabled:!a.length,action:()=>v.columns.group([])}),C}function s(){const v=globalThis.navigator&&globalThis.navigator.clipboard;return!!(v&&typeof v.readText=="function")}function c(v){return N(v.get)&&v.get("edit")===!1?!1:(v.columns&&N(v.columns.visible)?v.columns.visible():[]).some(a=>{const O=a&&a.edit;return O?O.enabled===void 0||N(O.enabled)?!0:O.enabled!==!1:!1})}function d(v,l){if(N(v.get)&&v.get("edit")===!1)return!1;const a=l&&l.edit;return a?a.enabled===void 0||N(a.enabled)?!0:a.enabled!==!1:!1}const f=new Set(["number","currency","percent","integer"]);function h(v){const l=N(v.get)?v.get("rangeChart"):void 0;return l?N(l)?{enabled:!0,handler:l}:l&&typeof l=="object"&&N(l.onChart)?{enabled:!0,handler:l.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function g(v){const l=v.selection&&N(v.selection.ranges)?v.selection.ranges():[];if(!Array.isArray(l)||!l.length)return null;const a=l[l.length-1],O=N(v.columns.visible)?v.columns.visible():[],T=new Set(O.filter(A=>A&&f.has(A.type)).map(A=>A.id));return(a.columns||[]).some(A=>T.has(A))?a:null}function w(v,l){const a=(Q,J)=>(v&&v.messages?v.messages:U).t(Q,J),{colId:O,row:T}=l,A=v.selection.keys().length,M=v.selection.cells().length,C=(v.state&&N(v.state.get)?v.state.get().group:null)||[],P=v.ranges||null,x=W()?"Cmd":"Ctrl",K=()=>M||A||0,I=Q=>v.columns&&N(v.columns.get)?v.columns.get(Q):null,D=N(v.selection.cells)?v.selection.cells():[],j=[...new Set(D.map(Q=>Q&&Q.colId).filter(Boolean))];!j.length&&O&&j.push(O);const E=j.length?j.some(Q=>d(v,I(Q))):c(v),$=O?d(v,I(O)):!1,q=h(v),X=q.enabled?g(v):null;return[{name:M>1?`Copy ${M} cells`:a("menu.copy"),shortcut:`${x}+C`,disabled:!K(),action:()=>P&&M?P.copy():v.export.clipboard({rows:A?"selected":"range"})},{name:a("menu.copyWithHeaders"),disabled:!K(),action:()=>v.export.clipboard({headers:!0,rows:A?"selected":"range"})},...O==null?[]:[{name:a("menu.paste"),shortcut:`${x}+V`,disabled:!P||!E||!s(),action:()=>P&&P.paste()},{separator:!0},{name:a("menu.clearCells",{count:M||1}),shortcut:"Delete",disabled:!P||!E||!M,action:()=>P&&P.clear()},{name:a("menu.fillDown"),shortcut:`${x}+D`,disabled:!P||!E||M<2,action:()=>P&&P.fillDown()}],...X&&q.handler?[{name:"Chart selection",action:()=>q.handler(v,X)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>v.export.csv({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to CSV`,disabled:!A,action:()=>v.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>v.export.excel({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to Excel`,disabled:!A,action:()=>v.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>v.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>v.export.print()},...v.importer&&N(v.importer.openFile)?[{name:a("menu.importCsv"),action:()=>v.importer.openFile()}]:[],{separator:!0},...C.length?[{name:a("menu.expandAll"),action:()=>v.rows.expandAll()},{name:a("menu.collapseAll"),action:()=>v.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!A,action:()=>v.selection.clear()},...N(v.get)&&v.get("rowDelete")===!0?[{name:a("menu.deleteRow",{count:A||1}),disabled:!A&&!T,action:()=>v.edit.deleteRows(A?void 0:T?T.key:void 0)}]:[],...O==null?[]:[{name:"Edit cell",disabled:!T||!O||!$,action:()=>T&&O&&v.edit.start(T.key,O)}]]}function p(v,l,a,O){if(v==null)return{items:l,spoke:!1,suppress:!1};if(v===!1)return{items:l,spoke:!0,suppress:!0};if(v===!0)return{items:l,spoke:!0,suppress:!1};if(Array.isArray(v))return{items:[...l,...v],spoke:!0,suppress:!1};if(N(v)){const T=v(a,l);return{items:Array.isArray(T)?T:l,spoke:!0,suppress:!1}}return z(`menu-layer:${O}`,`${O} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof v}. Ignoring it.`),{items:l,spoke:!1,suppress:!1}}function m(v,l,a){let O=Array.isArray(v)?v:[],T=!1;for(const A of l){if(!A)continue;const M=p(A.layer,O,a,A.where);O=M.items,M.spoke&&(T=M.suppress)}return T?null:O}class b{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#a=null;constructor(l){this.#n=l.grid,this.#e=l.cellMenu!==!1,this.#t=l.headerMenu!==!1,this.#i=N(l.items)?l.items:null,this.#a=N(l.headerItems)?l.headerItems:null,this.#r=new H({document:l.document,host:l.host,ctx:{grid:l.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",l=>{const a=String(l.colId),O=this.#c(a,o(this.#n,a));O.length&&this.#r.show({items:O,ctx:this.#u(a),anchor:l.element,placement:"below",returnFocus:l.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",l=>{const a=String(l.colId),O=this.#c(a,n(this.#n,a));O.length&&this.#r.show({items:O,ctx:this.#u(a),x:l.x,y:l.y,returnFocus:l.element})})),this.#o.push(this.#n.on("cell:contextmenu",l=>{const a=l.event;this.#e&&a&&N(a.preventDefault)&&a.preventDefault();const O=this.#s(l),T=w(this.#n,O),A=m(T,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#l(O.column),where:`column '${O.colId}' contextMenu`}],O);!A||!A.length||(!this.#e&&a&&N(a.preventDefault)&&a.preventDefault(),this.#r.show({items:A,ctx:O,x:a?a.clientX:void 0,y:a?a.clientY:void 0}))}))}#s(l){const a=this.#n.columns,O=l.column||(l.colId!=null&&a&&N(a.get)?a.get(l.colId):void 0),T=l.row,A=this.#n.rows,M=l.key!==void 0?l.key:T?T.key:void 0;return{key:M,colId:l.colId,value:l.value!==void 0||M===void 0||l.colId==null?l.value:A&&N(A.value)?A.value(M,l.colId):void 0,row:T,data:T?T.data:void 0,column:O,index:l.index!==void 0?l.index:l.rowIndex,grid:this.#n}}#l(l){if(!(!l||l.contextMenu===void 0||l.contextMenu===null))return l.contextMenu}#u(l){return{colId:l,column:this.#n.columns.get(l),grid:this.#n}}#c(l,a){return this.#a?m(a,[{layer:this.#a,where:"columnMenu"}],this.#u(l))||[]:a}destroy(){for(const l of this.#o)l();this.#o=[],this.#r.destroy()}}}),ve("packages/dom/src/shortcutshelp.js",function(e,V){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/renderer/keyboard.js"),_=W.groupedShortcuts,U=W.SHORTCUT_IDS,H=V("packages/dom/src/platform.js").macLike,L="lat-shortcuts",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class S{#e;#t;#n=null;#r=null;#o=[];constructor(u){this.#e=u.grid,this.#t=u.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(u,o){const r=this.#e;return(r&&r.messages?r.messages:F).t(u,o)}#a(u){const o=U[u.combo];if(!o)return u.meaning;const r=`shortcut.${o}`,t=this.#i(r);return t===r?u.meaning:t}mount(){const u=this.#t.viewport?.root;if(!u||!N(u.addEventListener))return;const o=r=>{if(this.open||r.key!=="?")return;const t=r.target,n=t&&t.tagName;n==="INPUT"||n==="TEXTAREA"||t&&t.isContentEditable||(r.preventDefault(),r.stopPropagation(),this.show())};u.addEventListener("keydown",o,!0),this.#o.push(()=>u.removeEventListener("keydown",o,!0))}show(){const u=this.#s();if(!u)return;const o=u.ownerDocument;this.#r=o&&o.activeElement,u.style.display="",N(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const u=this.#r;this.#r=null,u&&N(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:closed",{})}#s(){if(this.#n)return this.#n;const u=this.#t.viewport?.overlays,o=u?.ownerDocument;if(!u||!o?.createElement)return null;const r=o.createElement("div");r.className=L,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabindex","-1");const t=`${L}-title`;r.setAttribute("aria-labelledby",t);const n=o.createElement("div");n.className=`${L}__head`;const i=o.createElement("h2");i.className=`${L}__title`,i.id=t,i.textContent=this.#i("shortcuts.title");const s=o.createElement("button");s.className=`${L}__close`,s.type="button",s.setAttribute("aria-label",this.#i("shortcuts.close")),s.textContent="×",n.appendChild(i),n.appendChild(s),r.appendChild(n);const c=o.createElement("div");c.className=`${L}__body`;for(const f of _())f.items.length&&c.appendChild(this.#l(o,f));r.appendChild(c);const d=o.createElement("p");return d.className=`${L}__hint`,d.textContent=this.#i("shortcuts.hint"),r.appendChild(d),u.appendChild(r),this.#n=r,this.#u(r,s),r}#l(u,o){const r=u.createElement("section");r.className=`${L}__group`;const t=u.createElement("h3");t.className=`${L}__group-title`,t.textContent=this.#i(o.messageKey),r.appendChild(t);const n=u.createElement("dl");n.className=`${L}__list`;const i=H();for(const s of o.items){const c=u.createElement("dt");c.className=`${L}__keys`,s.alternatives.forEach((f,h)=>{if(h>0){const g=u.createElement("span");g.className=`${L}__or`,g.textContent=this.#i("shortcuts.or"),c.appendChild(g)}f.forEach((g,w)=>{w>0&&c.appendChild(u.createTextNode("+"));const p=u.createElement("kbd");p.textContent=i&&g==="Ctrl"?this.#i("shortcuts.key.cmd"):g,c.appendChild(p)})});const d=u.createElement("dd");d.className=`${L}__meaning`,d.textContent=this.#a(s),n.appendChild(c),n.appendChild(d)}return r.appendChild(n),r}#u(u,o){const r=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.hide();return}if(n.key!=="Tab")return;const i=[...u.querySelectorAll(k)];if(!i.length){n.preventDefault();return}const s=i[0],c=i[i.length-1],d=u.ownerDocument.activeElement;n.shiftKey&&(d===s||d===u)?(n.preventDefault(),c.focus()):!n.shiftKey&&d===c&&(n.preventDefault(),s.focus())},t=n=>{n.preventDefault?.(),this.hide()};u.addEventListener("keydown",r),o.addEventListener("click",t),this.#o.push(()=>{u.removeEventListener("keydown",r),o.removeEventListener("click",t)})}destroy(){for(const u of this.#o)u();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),ve("packages/dom/src/rowreorder.js",function(e,V){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return u}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/renderer.js").displayIndexOf,U="lat-rowdrag",B="lat-rowdrag-marker",H="lat-rowdrag-lifted",L=4,k=new Set;function S(o){if(!o)return null;const r=o===!0?{}:typeof o=="object"?o:null;return r?{send:r.send!==!1,receive:r.receive!==!1,mode:r.mode==="copy"?"copy":"move",group:typeof r.group=="string"?r.group:null}:null}function y(o){return o===!0?{column:null}:!o||typeof o!="object"?null:{column:typeof o.column=="string"?o.column:null}}class u{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=y(r.grid.get("rowReorder")),this.#o=S(r.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(r){if(!this.#o||!this.#o.receive)return!1;const t=r&&r.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(r,t){const n=this.#e;return(n&&n.messages?n.messages:F).t(r,t)}#c(r,t){const n=this.#t&&this.#t.announce;N(n)&&n.call(this.#t,r,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const r=this.#e.columns.visible().filter(t=>!t.generated);return r.length?r[0].id:null}paint(){if(!this.draggable)return;const r=this.#d(),t=this.#t.viewport?.root;if(!r||!t)return;const n=t.querySelectorAll(`.lat-cell[data-col="${r}"]`);for(const i of n){if(i.querySelector(`.${U}`))continue;const s=i.parentNode;if(s&&N(s.getAttribute)&&s.getAttribute("data-pinned"))continue;const c=this.#n.createElement("span");c.className=U,c.setAttribute("data-role","row-drag"),c.setAttribute("aria-hidden","true"),c.setAttribute("title",this.#u("a11y.reorder.grab")),c.textContent="⠿",i.insertBefore(c,i.firstChild||null)}}mount(){if(!this.active)return;k.add(this);const r=this.#t.viewport?.root;if(!r||!N(r.addEventListener))return;const t=d=>this.#h(d),n=d=>this.#f(d),i=()=>this.#m(),s=d=>this.#A(d);r.addEventListener("pointerdown",t),r.addEventListener("keydown",s);const c=this.#n.defaultView||this.#n;c.addEventListener?.("pointermove",n),c.addEventListener?.("pointerup",i),this.#l.push(()=>{r.removeEventListener("pointerdown",t),r.removeEventListener("keydown",s),c.removeEventListener?.("pointermove",n),c.removeEventListener?.("pointerup",i)})}#h(r){const t=r.target;if(!t||!N(t.closest)||!t.closest('[data-role="row-drag"]'))return;const n=t.closest(".lat-row"),i=n?_(n):-1;if(i<0)return;const s=this.#e.rows.get(i);if(!s)return;const c=this.#C();if(c&&!(this.#o&&this.#o.send)){this.#c(this.#u(c),{repeat:!0});return}r.preventDefault?.(),this.#i={key:s.key,from:i,at:i,x:r.clientX,y:r.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(r){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(r.clientX-t.x)+Math.abs(r.clientY-t.y)<L)return;t.armed=!0,this.#T(t),t.over=this,this.#e.emit("rowDrag:started",this.#p(t,this,t.from,t.key),"user")}this.#s&&this.#x(r.clientX,r.clientY);const n=this.#j(r.clientX,r.clientY);if(t.target=n,n!==this){this.#M(),n&&n.accepts(this)?(n.showDropTarget(r.clientX,r.clientY),t.hit=n.hitAt(r.clientX,r.clientY)):t.hit=null,this.#v(t,n),this.#b(t,n,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const i=this.#E(r.clientX,r.clientY);if(this.#v(t,n),i<0){this.#b(t,this,null,null);return}t.at=i,this.#N(i);const s=this.#e.rows.get(i);this.#b(t,this,i,s?s.key:null)}#m(){const r=this.#i;this.#i=null,this.#M(),this.#R();for(const i of k)i.hideDropTarget();if(!r||(this.#y(r),!r.armed))return;const t=r.target;if(this.#e.emit("rowDrag:ended",this.#g(r),"user"),t&&t!==this){this.#S(r,t);return}if(r.at===r.from)return;const n=this.#C();if(n){this.#c(this.#u(n),{repeat:!0});return}this.#O(r.key,r.at)}#p(r,t,n,i){const s=this.#e.rows.byKey(r.key);return{key:r.key,data:s?s.data:null,over:t?t.grid:null,at:n,overKey:i}}#g(r){const t=r.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(r,t,null,null),dropped:!1};const n=r.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(r,t,n.at,n.overKey),dropped:!0}}if(t===this){const n=this.#e.rows.get(r.at);return{...this.#p(r,this,r.at,n?n.key:null),dropped:r.at!==r.from&&this.#C()===null}}return{...this.#p(r,null,null,null),dropped:!1}}#v(r,t){if(r.over===t)return;const n=r.over;r.over=t,n&&(this.#y(r),this.#e.emit("rowDrag:left",this.#p(r,n,null,null),"user"))}#b(r,t,n,i){r.pending={over:t,at:n,overKey:i},r.frame===null&&(r.frame=this.#w(()=>{r.frame=null;const s=r.pending;r.pending=null,!(!s||this.#i!==r)&&this.#e.emit("rowDrag:moved",this.#p(r,s.over,s.at,s.overKey),"user")}))}#y(r){r.pending=null,r.frame!==null&&(r.frame(),r.frame=null)}#w(r){const t=this.#n.defaultView||globalThis;if(N(t.requestAnimationFrame)){const i=t.requestAnimationFrame(r);return()=>{N(t.cancelAnimationFrame)&&t.cancelAnimationFrame(i)}}const n=setTimeout(r,16);return()=>clearTimeout(n)}#S(r,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const n=this.#e.rows.byKey(r.key);if(!n)return;const i=this.#o.mode,s=r.key,c=r.hit||{at:t.grid.rows.count(),overKey:null};let d=null;const f=t.receive(n.data,c.at,{overKey:c.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(s),onCancel:g=>{d=g}}),h=g=>{if(g!==!0){const w=g===!1?"a11y.transfer.refused":d==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(w),{repeat:!0});return}i==="move"?(this.#e.rows.apply({remove:[s]}),this.#e.emit("row:sent",{key:s,data:n.data,mode:i})):this.#e.emit("row:copied",{key:s,data:n.data,mode:i}),this.#c(this.#u(i==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};f&&N(f.then)?f.then(h):h(f)}receive(r,t,n={}){const i=this.#e,s=r&&typeof r=="object"?{...r}:r,c=n.overKey??null,d=n.source||null,f=N(n.onCancel)?n.onCancel:null,h=()=>{const b=i.rows.totalCount(),v=i.rows.apply({add:[s],at:Math.max(0,t||0)}),l=i.rows.totalCount()>b;return l&&i.emit("row:received",{data:s,at:t,overKey:c,rejected:v?.rejected||[]}),l},g=()=>{if(c!==null){const b=i.rows.get(t);if(!b||b.key!==c)return!1}return!N(n.revalidate)||n.revalidate()},w=N(i.rendererHost)?i.rendererHost():null;if(!w||!N(w.gateBefore))return h();const p=f?i.on("rowReceive:cancelled",b=>f(b.reason)):null,m=w.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:s,at:t,overKey:c,source:d,origin:"user"},h,g);return p&&(m&&N(m.then)?m.then(p,p):p()),m}hitAt(r,t){const n=this.#E(r,t);if(n<0)return{at:this.#e.rows.count(),overKey:null};const i=this.#e.rows.get(n);return{at:n,overKey:i?i.key:null}}showDropTarget(r,t){const n=this.root;n&&N(n.setAttribute)&&n.setAttribute("data-drop-target","")}hideDropTarget(){const r=this.root;r&&N(r.removeAttribute)&&r.removeAttribute("data-drop-target")}#j(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&N(n.closest)?n.closest(".lattice"):null;if(!i)return null;for(const s of k)if(s.root===i)return s;return null}#A(r){if(!r.altKey||!r.shiftKey)return;const t=r.key==="ArrowUp"?-1:r.key==="ArrowDown"?1:0;if(!t)return;const n=this.#n.activeElement,i=n&&N(n.closest)?n.closest(".lat-row"):null,s=i?_(i):-1;if(s<0)return;r.preventDefault?.(),r.stopPropagation?.();const c=this.#C();if(c){this.#c(this.#u(c),{repeat:!0});return}const d=this.#e.rows.get(s);d&&this.#O(d.key,s+t)}#O(r,t){const n=this.#e.rows.count(),i=Math.max(0,Math.min(n-1,t)),s=this.#e.rows.move(r,i);if(!s.moved){s.reason&&s.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${s.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:s.to+1,total:n}),{repeat:!0})}#C(){const r=this.#e;if(r.sort.get().length)return"a11y.reorder.sorted";if((r.state.get().group||[]).length)return"a11y.reorder.grouped";const t=r.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#E(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&N(n.closest)?n.closest(".lat-row"):null;return!i||N(i.getAttribute)&&i.getAttribute("data-pinned")?-1:_(i)}#T(r){const t=this.root,n=t&&N(t.querySelector)?t.querySelector(`.lat-row[data-index="${r.from}"]`):null;n&&N(n.classList?.add)&&n.classList.add(H);const i=this.#n.body;if(!i||!N(i.appendChild))return;const s=this.#d(),c=s&&N(this.#e.rows?.text)&&this.#e.rows.text(r.key,s)||this.#u("a11y.reorder.grab"),d=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,f=(g,w)=>d&&d.getPropertyValue(g).trim()||w,h=this.#n.createElement("div");h.textContent=String(c),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:${f("--lattice-space","4px")} calc(${f("--lattice-space","4px")} * 2)`,`border-radius:${f("--lattice-radius-sm",f("--lattice-radius","4px"))}`,`border:${f("--lattice-border-width","1px")} solid ${f("--lattice-border-strong","#0003")}`,`background:${f("--lattice-background","#fff")}`,`color:${f("--lattice-foreground","#000")}`,`box-shadow:${f("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${f("--lattice-font-size","13px")} ${f("--lattice-font-family","system-ui, sans-serif")}`].join(";"),i.appendChild(h),this.#s=h}#x(r,t){this.#s&&(this.#s.style.transform=`translate(${Math.round(r)+14}px, ${Math.round(t)+16}px)`)}#R(){this.#s&&(this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null);const r=this.root,t=r&&N(r.querySelectorAll)?r.querySelectorAll(`.${H}`):[];for(const n of t)n.classList.remove(H)}#N(r){const t=this.#t.viewport?.overlays;if(!t)return;this.#a||(this.#a=this.#n.createElement("div"),this.#a.className=B,t.appendChild(this.#a));const n=this.#t.viewport.root,i=n.querySelector(`.lat-row[data-index="${r}"]`)||n.querySelectorAll(".lat-row")[0];if(!i||!N(i.getBoundingClientRect))return;const s=i.getBoundingClientRect(),c=n.getBoundingClientRect(),d=this.#i&&r>this.#i.from;this.#a.style.display="",this.#a.style.top=`${Math.round((d?s.bottom:s.top)-c.top)}px`}#M(){this.#a&&(this.#a.style.display="none")}destroy(){k.delete(this);for(const r of this.#l)r();this.#l=[],this.#i&&this.#y(this.#i),this.#i=null,this.#R(),this.#a&&this.#a.parentNode&&this.#a.parentNode.removeChild(this.#a),this.#a=null}}}),ve("packages/dom/src/alignedgrids.js",function(e,V){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z=["column:resized","column:moved","column:visible","column:pinned"];function F(U){return(U||[]).map(B=>({id:B.id,width:B.width,flex:B.flex,hidden:B.hidden,pin:B.pin===void 0?null:B.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(B){if(!B||this.#e.has(B))return;this.#e.add(B);const H=[];for(const k of z)H.push(B.on(k,()=>this.#r(B)));H.push(B.on("scroll",k=>this.#i(B,k))),H.push(B.on("destroy",()=>this.remove(B))),this.#t.set(B,H);const[L]=this.#e;L!==B&&this.#o(B,F(L.columns.state()))}remove(B){const H=this.#t.get(B);if(H)for(const L of H)L();this.#t.delete(B),this.#e.delete(B)}get size(){return this.#e.size}destroy(){for(const B of[...this.#e])this.remove(B)}#r(B){if(this.#n)return;const H=F(B.columns.state());this.#n=!0;try{for(const L of this.#e)L!==B&&this.#o(L,H)}finally{this.#n=!1}}#o(B,H){if(!B.columns||!N(B.columns.apply))return;const L=new Map((B.columns.state()||[]).map(S=>[S.id,S])),k=[];for(const S of H){const y=L.get(S.id);y&&(k.push({...y,...S}),L.delete(S.id))}for(const S of L.values())k.push(S);B.columns.apply(k)}#i(B,H){if(this.#n)return;const L=H&&typeof H.left=="number"?H.left:null;if(L!==null){this.#n=!0;try{for(const k of this.#e)k!==B&&k.scroll?.to?.({left:L})}finally{this.#n=!1}}}}function _(U){const B=new W;for(const H of U||[])B.add(H);return B}}),ve("packages/dom/src/columntagbar.js",function(e,V){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return U}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function _(H){if(!H)return null;const L=H===!0?{}:typeof H=="object"?H:null;return L?{multiple:L.multiple===!0,label:typeof L.label=="string"?L.label:null}:null}class U{#e;#t;#n;#r=null;#o=null;#i=null;#a="\0";#s=[];constructor(L){this.#e=L.grid,this.#t=L.renderer,this.#n=L.document,this.#r=_(L.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#l(L,k){const S=this.#e;return(S&&S.messages?S.messages:F).t(L,k)}mount(){if(!this.active)return;const L=this.#t.viewport,k=L?.root;if(!k||!N(k.insertBefore))return;const S=this.#n.createElement("div");S.className=W,S.setAttribute("role","toolbar"),S.setAttribute("aria-label",this.#l("tags.label"));const y=this.#n.createElement("label");y.className=`${W}__label`,y.textContent=this.#r.label||this.#l("tags.label");const u=this.#n.createElement("select");u.className=`${W}__select`,this.#r.multiple&&u.setAttribute("multiple","");const o=`${W}-select-${Math.abs(B(String(k.className)))}`;u.id=o,y.setAttribute("for",o),S.appendChild(y),S.appendChild(u),k.insertBefore(S,L.header||k.firstChild),this.#o=S,this.#i=u;const r=()=>{const n=this.#r.multiple?[...u.selectedOptions||[]].map(i=>i.value).filter(Boolean):u.value?[u.value]:[];this.#e.columns.showTagged(n),this.#u(n)};u.addEventListener("change",r),this.#s.push(()=>u.removeEventListener("change",r));const t=this.#e.on("model:changed",()=>this.refresh());this.#s.push(t),this.refresh()}#u(L){const k=this.#t&&this.#t.announce;if(!N(k))return;const S=L.length?L.join(", "):this.#l("tags.all");k.call(this.#t,this.#l("tags.showing",{tag:S}))}refresh(){if(!this.#i||!this.#o)return;const L=this.#e.columns.tags();if(this.#o.style.display=L.length?"":"none",!L.length)return;const k=L.join("\0");if(k===this.#a)return;this.#a=k;const S=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const y=this.#n.createElement("option");y.value="",y.textContent=this.#l("tags.all"),this.#i.appendChild(y)}for(const y of L){const u=this.#n.createElement("option");u.value=y,u.textContent=y,S.includes(y)&&(u.selected=!0),this.#i.appendChild(u)}this.#r.multiple||(this.#i.value=S.length?S[0]:"")}destroy(){for(const L of this.#s)L();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function B(H){let L=0;for(let k=0;k<H.length;k++)L=L*31+H.charCodeAt(k)|0;return L}}),ve("packages/dom/src/anomalychip.js",function(e,V){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function _(L){if(!L)return null;const k=L===!0?{}:typeof L=="object"?L:null;return k?{column:typeof k.column=="string"?k.column:null,label:typeof k.label=="string"?k.label:null}:null}function U(L){return L?typeof L=="string"?{kind:L}:typeof L=="object"?L:null:null}function B(L,k){return L?Array.isArray(L.conditions)?L.conditions.some(S=>B(S,k)):L.col===k&&L.op==="eq"&&L.value===!0:!1}class H{#e;#t;#n;#r=null;#o=null;#i=null;#a=[];#s=!1;#l=!1;#u=null;#c=0;#d=null;constructor(k){this.#e=k.grid,this.#t=k.renderer,this.#n=k.document,this.#r=_(k.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(k,S){const y=this.#e;return(y&&y.messages?y.messages:F).t(k,S)}#f(){const k=this.#r&&this.#r.column;let S=null;for(const y of this.#e.columns.all()){const u=U(y.shadow);if(!u||u.kind!=="anomalyFlag")continue;const o=u.of||y.field||y.id;if(k){if(y.id===k||o===k)return this.#d=y.id,y}else S||(S=y,this.#d=y.id)}return k?null:S}#m(){if(!this.#d||!N(this.#e.rows&&this.#e.rows.forEach))return 0;let k=0;try{this.#e.rows.forEach(S=>{!S||S.group||S.key==null||this.#e.rows.value(S.key,this.#d)===!0&&k++})}catch{return 0}return k}mount(){if(!this.active)return;const k=this.#t.viewport,S=k&&k.root;if(!S||!N(S.insertBefore))return;const y=this.#n.createElement("div");y.className=W,y.setAttribute("role","status");const u=this.#n.createElement("button");u.className=`${W}__button`,u.setAttribute("type","button"),u.setAttribute("aria-pressed","false"),y.appendChild(u),S.insertBefore(y,k.header||S.firstChild),this.#o=y,this.#i=u;const o=()=>this.toggle();u.addEventListener("click",o),this.#a.push(()=>u.removeEventListener("click",o));for(const r of["filter:changed","rows:changed","model:changed"])this.#a.push(this.#e.on(r,()=>{this.#l||this.refresh()}));this.refresh()}toggle(){this.#s?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const k={col:this.#d,op:"eq",value:!0},S=this.#u?{op:"and",conditions:[this.#u,k]}:k;this.#s=!0,this.#l=!0;try{this.#e.filters.set(S)}finally{this.#l=!1}this.refresh()}#g(){this.#s=!1,this.#l=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#l=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#s&&!B(this.#e.filters.get(),this.#d)&&(this.#s=!1,this.#u=null),this.#s){this.#v(this.#c,!0);return}const S=this.#m();if(this.#c=S,!S){this.#o.style.display="none";return}this.#v(S,!1)}#v(k,S){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",S?"true":"false"),this.#i.setAttribute("aria-pressed",S?"true":"false");const y=this.#r&&this.#r.label,u=S?this.#h("anomaly.chipActive",{count:k}):y||this.#h("anomaly.chip",{count:k});this.#i.textContent=u}destroy(){for(const k of this.#a)k();this.#a=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),ve("packages/dom/src/rowform.js",function(e,V){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return r}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,U=V("packages/dom/src/editors/index.js").createEditor,H=V("packages/dom/src/renderer/renderer.js").displayIndexOf,L="lat-rowform",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function S(t){if(!t)return null;const n=t===!0?{}:typeof t=="object"?t:null;if(!n)return null;const i=N(n.load)?n.load:null,s=Array.isArray(n.fields)&&n.fields.length?n.fields:null;return{timeout:o(n.timeout),container:n.container??null,mode:n.container?"inline":n.mode==="dialog"?"dialog":"drawer",load:i,fields:s,title:n.title??null,width:typeof n.width=="string"?n.width:null,trigger:n.trigger===!1?"none":"dblclick"}}function y(t,n){const i=N(t)?t():t;return i?typeof i=="string"?n&&N(n.querySelector)?n.querySelector(i):null:i&&N(i.appendChild)?i:null:null}const u=2e3;function o(t){return t===!1||t===0?0:typeof t!="number"||!Number.isFinite(t)||t<=0?u:t}class r{#e;#t;#n;#r;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=n.registry||null,this.#o=S(n.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(n,i){const s=this.#e;return(s&&s.messages?s.messages:W).t(n,i)}mount(){if(!this.active)return;const n=this.#t.viewport?.root;if(!n||!N(n.addEventListener)||this.#o.trigger==="none")return;const i=s=>{const c=s.target;if(!c||!N(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const d=c.closest(".lat-row"),f=d?H(d):-1;if(f<0)return;const h=this.#e.rows.get(f);!h||h.group||h.detail||(s.preventDefault?.(),s.stopPropagation?.(),this.openRow(h.key))};n.addEventListener("dblclick",i,!0),this.#m.push(()=>n.removeEventListener("dblclick",i,!0))}openRow(n){const i=this.#e.rows.byKey(n);if(!i)return!1;const s=this.#g();if(!s)return!1;this.#l=i,this.#c=this.#n.activeElement,s.style.display="",this.#E(s),this.#b(i);const c=this.#o.load;if(!c)this.#C(i.data);else{this.#j();const d=++this.#d;this.#y(d,n),Promise.resolve().then(()=>c({row:i,data:i.data,key:n,grid:this.#e})).then(f=>{d!==this.#d||!this.open||(this.#S(),this.#C(f||i.data))}).catch(f=>{d!==this.#d||!this.open||(this.#S(),this.#A(f,n))})}return N(s.focus)&&s.focus(),this.#e.emit("form:opened",{key:n,row:i}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#L(),this.#i.style.display="none";const n=this.#l?this.#l.key:null;this.#l=null;const i=this.#c;this.#c=null,i&&N(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:n})}save(){if(!this.#l||!this.#u.length)return!1;const n=this.#l.key,i={},s={},c=[],d=[];for(const f of this.#u){const h=N(f.editor.commit)?f.editor.commit():{ok:!0,value:void 0};if(!h.ok)return this.#R(f,h.message),!1;i[f.field]=h.value;const g=f.initial;Object.is(g,h.value)||(s[f.field]=h.value,f.colId?c.push({key:n,colId:f.colId,value:h.value}):d.push(f.field))}return c.length&&this.#e.edit.setCells(c),this.#e.emit("form:saved",{key:n,values:i,changed:s,unmapped:d}),this.close(),!0}#g(){if(this.#i)return this.#i;const n=this.#t.viewport?.overlays,i=this.#n||n?.ownerDocument;if(!i?.createElement)return null;const s=y(this.#o.container,i),c=s||n;if(!c)return null;this.#o.container&&!s&&z("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!s;const d=i.createElement("div"),f=this.#f?"lattice ":"";d.className=`${f}${L} ${L}--${this.#f?"inline":this.#o.mode}`,d.setAttribute("role",this.#f?"region":"dialog"),this.#f||d.setAttribute("aria-modal","true"),d.setAttribute("tabindex","-1"),this.#o.width&&d.style.setProperty("--lattice-rowform-width",this.#o.width);const h=`${L}-title`;d.setAttribute("aria-labelledby",h);const g=i.createElement("div");g.className=`${L}__head`;const w=i.createElement("h2");w.className=`${L}__title`,w.id=h,g.appendChild(w);const p=i.createElement("div");p.className=`${L}__body`;const m=i.createElement("div");m.className=`${L}__foot`;const b=i.createElement("button");b.className=`${L}__cancel`,b.type="button",b.textContent=this.#p("form.cancel");const v=i.createElement("button");return v.className=`${L}__save`,v.type="button",v.textContent=this.#p("form.save"),m.appendChild(b),m.appendChild(v),d.appendChild(g),d.appendChild(p),d.appendChild(m),c.appendChild(d),this.#i=d,this.#a=p,this.#s=v,this.#v(d,v,b),d}#v(n,i,s){const c=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.close();return}if(h.key!=="Tab"||this.#f)return;const g=[...n.querySelectorAll(k)];if(!g.length){h.preventDefault();return}const w=g[0],p=g[g.length-1],m=n.ownerDocument.activeElement;h.shiftKey&&(m===w||m===n)?(h.preventDefault(),p.focus()):!h.shiftKey&&m===p&&(h.preventDefault(),w.focus())},d=h=>{h.preventDefault?.(),this.save()},f=h=>{h.preventDefault?.(),this.close()};n.addEventListener("keydown",c),i.addEventListener("click",d),s.addEventListener("click",f),this.#m.push(()=>{n.removeEventListener("keydown",c),i.removeEventListener("click",d),s.removeEventListener("click",f)})}#b(n){const i=this.#i.querySelector(`.${L}__title`);if(!i)return;const s=this.#o.title;N(s)?i.textContent=String(s({row:n,data:n.data})??""):typeof s=="string"?i.textContent=s:i.textContent=this.#p("form.title")}#y(n,i){this.#S();const s=this.#o.timeout;if(!s)return;const c=this.#n.defaultView||globalThis;N(c.setTimeout)&&(this.#h=c.setTimeout(()=>{this.#h=null,!(n!==this.#d||!this.open)&&(this.#d+=1,this.#A(new Error(`Loading the record timed out after ${s}ms`),i,"form.loadTimeout"))},s))}#w(n){this.#s&&(this.#s.disabled=!n,n?this.#s.removeAttribute("aria-disabled"):this.#s.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const n=this.#n.defaultView||globalThis;N(n.clearTimeout)&&n.clearTimeout(this.#h),this.#h=null}#j(){this.#L(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const n=this.#n.createElement("p");n.className=`${L}__note`,n.setAttribute("role","status"),n.textContent=this.#p("form.loading"),this.#a.appendChild(n)}#A(n,i,s="form.loadFailed"){this.#L(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const c=this.#n.createElement("p");c.className=`${L}__note ${L}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#p(s);const d=this.#n.createElement("button");d.className=`${L}__retry`,d.type="button",d.textContent=this.#p("form.retry"),d.addEventListener("click",()=>this.openRow(i)),this.#a.appendChild(c),this.#a.appendChild(d),this.#e.emit("form:error",{key:i,error:n,timedOut:s==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(n=>typeof n=="string"?{field:n}:n):this.#e.columns.all().filter(n=>!n.generated&&n.field).map(n=>({field:n.field,label:n.title,colId:n.id}))}#C(n){this.#L(),this.#w(!0),this.#a.replaceChildren&&this.#a.replaceChildren();const i=n&&typeof n=="object"?n:{};for(const s of this.#O()){const c=s.field;if(!c)continue;const d=s.colId?this.#e.columns.get(s.colId):this.#U(c),f=this.#_(s,d,c),h=Object.hasOwn(i,c)?i[c]:null,g=this.#n.createElement("div");g.className=`${L}__field`;const w=this.#n.createElement("label");w.className=`${L}__label`,w.textContent=String(s.label??(d&&d.title)??c);const p=this.#n.createElement("div");p.className=`${L}__control`,g.appendChild(w),g.appendChild(p),this.#a.appendChild(g);const m={field:c,colId:d?d.id:null,editor:null,initial:h,opener:null,wrap:g},b=U({grid:this.#e,column:f,colId:d?d.id:c,row:this.#l,data:i,value:h,text:h==null?"":String(h),locale:this.#e.get("locale"),props:s.props||d&&d.edit&&d.edit.props,lookup:s.lookup||d&&d.lookup,document:this.#n,cell:p,overlay:this.#T(),stop:()=>this.#N(m)},this.#r);if(b){m.editor=b;try{N(b.value)&&(m.initial=b.value())}catch{}if(this.#u.push(m),b.popup===!0)this.#x(p,m);else{const v=N(b.element)?b.element():null;v&&p.appendChild(v)}}}}#E(n){if(!this.#f)return;const i=this.#t.viewport?.root;if(!(!i||!N(i.getAttribute)))for(const s of["data-theme","data-density","dir"]){const c=i.getAttribute(s);c?n.setAttribute(s,c):N(n.removeAttribute)&&n.removeAttribute(s)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#x(n,i){const s=this.#n.createElement("button");s.className=`${L}__opener`,s.type="button",i.opener=s,this.#M(i);const c=()=>{N(i.editor.attached)&&i.editor.attached()};s.addEventListener("click",c),this.#m.push(()=>s.removeEventListener("click",c)),n.appendChild(s)}#R(n,i){const s=n.wrap;s&&N(s.scrollIntoView)&&s.scrollIntoView({block:"nearest"});const c=n.opener||(N(n.editor.focusTarget)?n.editor.focusTarget():null);c&&N(c.focus)&&c.focus();const d=this.#t&&this.#t.announce;N(d)&&i&&d.call(this.#t,String(i))}#N(n){if(!n.opener||!n.editor)return;const i=N(n.editor.popupHandle)?n.editor.popupHandle():null;i&&N(i.hide)&&i.hide(),this.#M(n),N(n.opener.focus)&&n.opener.focus()}#M(n){if(!n.opener)return;let i="";try{const c=n.colId?this.#e.columns.get(n.colId):null,d=c&&c.dataType&&c.dataType.format;N(d)&&(i=d({value:N(n.editor.value)?n.editor.value():null,column:c,row:this.#l,data:this.#l?this.#l.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&N(n.editor.toClipboard)&&(i=n.editor.toClipboard())}catch{i=""}const s=i===""||i==null;n.opener.textContent=s?this.#p("form.choose"):String(i),n.opener.classList.toggle(`${L}__opener--empty`,s)}#_(n,i,s){const c=n.editor||n.type||n.lookup||n.props;if(i&&!c)return i;const d={...i&&i.edit?i.edit:{}};return n.editor&&(d.editor=n.editor),n.props&&(d.props=n.props),{...i||{id:s,field:s},type:n.type||i&&i.type||"text",lookup:n.lookup||i&&i.lookup||void 0,edit:d}}#U(n){for(const i of this.#e.columns.all())if(!i.generated&&i.field===n)return i;return null}#L(){for(const n of this.#u)N(n.editor.destroy)&&n.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#L();for(const n of this.#m)n();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null,this.#l=null}}}),ve("packages/dom/src/toolpanelmount.js",function(e,V){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return p}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,F=V("packages/dom/src/ui/toolpanel.js"),W=F.ToolPanel,_=F.toolPanels,U=F.toolPanelTitles,B=F.toolPanelIcons,L=V("packages/dom/src/filters/index.js").createFilter,k=V("packages/dom/src/editors/common.js"),S=k.CLS,y=k.documentFor,u=k.scannableRows,o=V("packages/dom/src/filtermenu.js"),r=o.mergeColumnFilter,t=o.branchFor,n=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 i(m){const{grid:b,container:v}=m||{};if(!b)throw new Error("[lattice] mountPanel needs a grid");if(!v||!v.appendChild)throw new Error("[lattice] mountPanel needs a container element");const l=N(m.panel)?m.panel:_[String(m.panel)];if(!l)throw new Error(`[lattice] unknown panel "${m.panel}"; known panels are ${Object.keys(_).join(", ")}`);const a=v.ownerDocument||y(v),O=w(b,a,m.announce),T=new l;T.init({document:a,host:O,grid:b,props:m.props||{}});const A=T.element();v.appendChild(A);const M=[];for(const C of n)N(b.on)&&M.push(b.on(C,()=>T.refresh()));return{element:A,refresh(){T.refresh()},destroy(){for(const C of M)C();M.length=0,N(T.destroy)&&T.destroy(),A&&A.parentNode&&A.parentNode.removeChild(A)}}}const s=260,c=30,d=`${S.panel}-dock`;function f(m,b,v){if(!m||!N(m.set))return;const l=t(v.filters.get(),b)||null,a=N(m.get)&&(!N(m.active)||m.active())&&m.get()||null;JSON.stringify(a)!==JSON.stringify(l)&&(l?m.set(l):N(m.clear)?m.clear():m.set(null))}function h(m,b){if(m==="insights"){const a=b&&N(b.get)?b.get("insights"):null;return{other:(a&&typeof a=="object"?a:{}).compareWith||null}}if(m!=="views")return{};const v=b&&N(b.get)?b.get("views"):null,l=v&&typeof v=="object"?v:{};return{allowSave:l.allowSave!==!1,showDiff:l.showDiff===!0,builtinTitle:l.builtinTitle,savedTitle:l.savedTitle}}function g(m){const b=m.pagination&&N(m.pagination.get)?m.pagination.get():null;return b&&Number.isFinite(b.total)?b.total:m.rows.count()}function w(m,b,v){const l=new Map;return{announce(a,O){N(v)&&v(a,O)},t(a,O){return m.messages.t(a,O)},grid:m,document:b,columns:()=>m.columns.all(),showColumns:a=>m.columns.show(a),hideColumns:a=>m.columns.hide(a),groupBy:()=>m.state.get().group||[],setGroupBy:a=>m.columns.group(a),pivotBy:()=>(m.state.get().pivot||{}).columns||[],setPivotBy:a=>m.columns.pivot(a),valueColumns:()=>m.columns.all().filter(a=>a.total).map(a=>a.id),setValueColumns:a=>m.columns.totals(a),valueAggregation(a){const O=m.columns.get(a);return!O||!O.total?"sum":typeof O.total=="string"?O.total:"custom"},setValueAggregation(a,O){m.columns.setTotal(a,O)},quickFilter:()=>m.state.get().quick||"",setQuickFilter:a=>m.filters.quick(a),rowCount:()=>g(m),totalRowCount:()=>N(m.rows.totalCount)?m.rows.totalCount():m.rows.count(),formattableColumns:()=>m.columns.visible().filter(a=>!a.generated).map(a=>({id:a.id,title:String(a.title??a.id)})),formattingRules:a=>m.formatting.list(a),columnSamples:a=>{let O=a;if(!O||O==="*"){const M=m.columns.visible().find(C=>!C.generated);O=M?M.id:null}if(!O)return[];const T=[],A=new Set;for(const M of u(m)){const C=m.rows.value(M.key,O);if(C==null||C==="")continue;const P=typeof C=="object"?T.length:C;if(!A.has(P)&&(A.add(P),T.push(C),T.length>=24))break}return T},profilableColumns:()=>m.columns.visible().filter(a=>!a.generated).map(a=>({id:a.id,title:String(a.title??a.id)})),columnProfile:a=>m.statistics.profile(a),reduceColumn:(a,O)=>m.statistics.reduce(a,O),columnCapability:a=>m.statistics.capability(a),regressionModel:a=>N(m.statistics.regressionModel)?m.statistics.regressionModel(a):null,insightsColumns:()=>m.columns.visible().filter(a=>!a.generated).map(a=>({id:a.id,title:String(a.title??a.id),type:a.type})),subsetVsPopulation:()=>m.statistics.subsetVsPopulation(),datasetVsDataset:a=>m.statistics.datasetVsDataset(a),compareGroups:(a,O)=>m.statistics.compareGroups(a,O),anomalies:a=>m.statistics.anomalies(a||{}),compareColumns:(a,O)=>{if(!a||!O||a===O)return null;const T=m.statistics.regression(a,O);return{n:T?T.n:0,pearson:m.statistics.correlation(a,O),spearman:m.statistics.spearman(a,O),kendall:m.statistics.kendall(a,O),covariance:m.statistics.covariance(a,O),slope:T?T.slope:null,intercept:T?T.intercept:null,r2:T?T.r2:null,stdError:T?T.stdError:null,weighted:m.statistics.weightedAverage(a,O)}},addRule:(a,O)=>m.formatting.add(a,O),removeRule:(a,O)=>m.formatting.remove(a,O),updateRule:(a,O,T)=>m.formatting.update(a,O,T),moveRule:(a,O,T)=>m.formatting.move(a,O,T),clearRules:a=>m.formatting.clear(a),views:()=>m.views.list(),activeId:()=>m.views.activeId,apply:a=>{m.views.apply(a)},saveAs:a=>m.views.save(a),rename:(a,O)=>m.views.rename(a,O),setDefault:a=>m.views.setDefault(a),clearDefault:()=>m.views.setDefault(null),remove:a=>m.views.remove(a),export:a=>m.views.export(a),diff:a=>m.views.diff(a),moveColumn(a,O,T){const A=m.columns.all().map(x=>x.id),M=A.indexOf(a),C=A.indexOf(O);if(M<0||C<0)return;let P=T?C:C+1;M<P&&(P-=1),P!==M&&m.columns.move(a,P)},isFiltered(a){return t(m.filters.get(),a)!==null},clearFilter(a){m.filters.set(r(m.filters.get(),a,null));const O=l.get(a);O&&N(O.clear)?O.clear():O&&N(O.set)&&O.set(null)},clearAllFilters(){m.filters.set(null);for(const a of l.values())N(a.clear)?a.clear():N(a.set)&&a.set(null)},filterFor(a){if(l.has(a))return f(l.get(a),a,m),l.get(a);const O=m.columns.get(a);if(!O)return null;const T=L({grid:m,column:O,colId:a,type:O.type,locale:m.get("locale"),props:{...O.filter&&O.filter.props,values:O.filter&&O.filter.props&&O.filter.props.values||(O.lookup?void 0:()=>m.columns.distinct(a))},lookup:O.lookup,document:b,value:A=>m.rows.value(A.row&&A.row.key,a),rows:O.lookup?void 0:()=>u(m),changed:()=>{const M=(N(T.active)?T.active():!0)&&N(T.get)?T.get():null;m.filters.set(r(m.filters.get(),a,M||null))}});return T&&(f(T,a,m),l.set(a,T)),T},destroyFilters(){for(const a of l.values())N(a.destroy)&&a.destroy();l.clear()}}}class p{#e;#t;#n;#r;#o;#i=null;#a=[];#s="right";#l=null;#u=!1;#c=!1;constructor(b){this.#e=b.grid,this.#t=b.document,this.#n=b.root,this.#o=w(b.grid,b.document,b.announce);const l=(b.panels||["columns","filters"]).map(a=>_[a]?{name:a,title:U[a]?b.grid.messages.t(U[a]):a,icon:B[a]||a,Ctor:_[a],props:h(a,b.grid)}:(z(`toolpanel:${a}`,`unknown tool panel "${a}"`),null)).filter(Boolean);this.#s=b.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:b.document,host:this.#o,grid:b.grid,panels:l,actions:b.actions,icons:b.icons,side:this.#s,openPanel:b.openPanel})}mount(){const b=this.#t.createElement("div");b.className=`${d} ${d}--${this.#s}`,b.appendChild(this.#r.element()),this.#n.appendChild(b),this.#i=b;const v=this.#r.show.bind(this.#r),l=this.#r.hide.bind(this.#r);this.#r.show=a=>{const O=v(a);return this.#f(),O},this.#r.hide=()=>{l(),this.#f()};for(const a of[...n,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#a.push(this.#e.on(a,()=>this.#r.refresh()));this.#a.push(this.#e.on("presentation:started",a=>{this.#u=!0;const O=a&&a.options&&Array.isArray(a.options.chrome)?a.options.chrome:[];this.#c=O.includes("toolPanel")})),this.#a.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#a.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#a.push(this.#e.on("column:profile:open",a=>{const O=a&&a.colId,T=this.#r.panels.find(A=>A.name==="statistics");T&&O!=null&&(T.panel.column=String(O)),this.open("statistics")})),this.#f()}open(b){this.#r.show(b),this.#f()}close(){this.#r.hide(),this.#f()}toggle(b){this.#r.toggle(b),this.#f()}addAction(b){if(!(!b||!b.name)&&!this.#r.actions.some(v=>v.name===b.name)){if(this.#r.registerAction(b),this.#l&&!b.annotation){const v=this.#r.actions.find(l=>l.name===b.name);v&&this.#h(v.button)}else!this.#l&&b.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(b){this.#r.removeAction(b)&&this.#f()}presentOnly(){return this.#l?!0:this.#r.actions.some(b=>b.annotation&&b.button)?(this.#d(),!0):!1}#d(){const b=this.#r;this.#l={hidden:[],reopen:b.openPanel||null},this.#l.reopen&&b.hide(),this.#h(b.body);for(const v of[...b.tabs?.children||[]])v!==b.actionGroup&&this.#h(v);for(const v of[...b.actionGroup?.children||[]]){const l=b.actions.find(a=>a.button===v);(!l||!l.annotation)&&this.#h(v)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const b=this.#l;if(!b)return!1;this.#l=null;for(const v of b.hidden)v.el&&v.el.style&&(v.el.style.display=v.display);return b.reopen&&this.#r.show(b.reopen),this.#f(),!0}#h(b){if(!b||!b.style||!this.#l)return;const v=b.style.display||"";v!=="none"&&(b.style.display="none",this.#l.hidden.push({el:b,display:v}))}#f(){if(!this.#i)return;const b=!!this.#r.openPanel;this.#i.setAttribute("data-open",b?"true":"false"),this.#i.style.width=b?`${s}px`:"";const v=`${b?s:this.#m()}px`;this.#n.style.paddingLeft=this.#s==="left"?v:"",this.#n.style.paddingRight=this.#s==="left"?"":v,this.#n.style.setProperty("--lattice-dock-left",this.#s==="left"?v:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#s==="left"?"0px":v)}#m(){const b=this.#r&&N(this.#r.element)?this.#r.element().querySelector?.(`.${S.panel}__tabs`):null,v=b&&(b.offsetWidth||b.getBoundingClientRect?.().width)||0;return v>0?Math.ceil(v):c}destroy(){for(const b of this.#a)b();this.#a=[],this.#l=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),ve("packages/dom/src/celledit.js",function(e,V){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return S}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,_=V("packages/dom/src/editors/common.js"),U=_.CLS,B=_.markInvalid,L=V("packages/dom/src/detailhost.js").insideDetail,k=`${U.editor}-host`;class S{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=-1;#u=[];#c=null;#d=!1;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",f=>this.open(f))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,n=this.#e.get("edit"),i=n&&typeof n=="object"&&n.start||"double",s=f=>{if(L(f.target,t))return;const h=y(f.target,b=>b.getAttribute&&b.getAttribute("data-col"));if(!h)return;const g=y(h,b=>b.getAttribute&&b.getAttribute("data-key"));if(!g)return;const w=this.#e.rows.byKey(g.getAttribute("data-key"));if(!w||w.group)return;const p=h.getAttribute("data-col"),m=this.#e.columns.get(p);!m||!m.edit||!m.edit.enabled||this.#e.edit.start(w.key,p)},c=i==="key"?null:i==="single"?"click":"dblclick";c&&(t.addEventListener(c,s),this.#u.push(()=>t.removeEventListener(c,s)));const d=f=>{!this.#i||!this.#s||this.#m(f.target)||this.commit()};this.#t.addEventListener("mousedown",d,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",d,!0))}get target(){return this.#s}open(t){this.close();const n=t.key||t.row&&t.row.key,i=t.colId;if(!n||!i)return;const s=this.#e.columns.get(i),c=this.#e.rows.byKey(n);if(!s||!c)return;const d=this.#b(n,i);if(this.#c=d,!d){z("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const f=this.#e.permissions,h=!!(f&&N(f.isSecret)&&f.isSecret(i)),g=W({grid:this.#e,column:s,colId:i,row:c,data:c.data,value:h?null:this.#e.rows.value(n,i),text:h?"":this.#e.rows.text(n,i),locale:this.#e.get("locale"),props:s.edit&&s.edit.props,lookup:s.lookup,document:this.#t,cell:d,overlay:this.#n.viewport.overlays,onCommit:m=>this.#f({value:m,key:n,colId:i}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:m=>{this.#d||this.#e.edit.stop(m)}},this.#r);if(!g){z(`celledit.noeditor:${i}`,`column "${i}" has no editor.`);return}this.#i=g,this.#a=d,this.#s={key:n,colId:i},this.#d=!1,this.#l=this.#v(d);const w=g.element();g.popup?(this.#n.viewport.overlays.appendChild(w),u(w,d,this.#n.viewport.root)):d.replaceChildren(w),d.classList.add(k),N(g.attached)&&g.attached(),o(w);const p=m=>this.#h(m);w.addEventListener("keydown",p),this.#u.push(()=>w.removeEventListener("keydown",p))}#h(t){const n=t.key;if(n!=="Enter"&&n!=="Tab"&&n!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),n==="Escape"){this.#e.edit.stop(!0);return}const i=n==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&i&&this.#e.edit.start(i.key,i.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#s)return!1;if(this.#d)return!0;if(N(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#s;if(N(this.#i.value)){const i=this.#i.value();if(N(this.#i.validate)){const s=this.#i.validate(i);if(s!==!0){if(B(this.#c,s),N(this.#i.focusTarget)){const c=this.#i.focusTarget();c&&N(c.focus)&&c.focus()}return!1}B(this.#c,null)}this.#f({value:i,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const n=N(this.#i.element)?this.#i.element():null;if(n&&N(n.contains)&&n.contains(t))return!0;const i=this.#c;return!!(i&&N(i.contains)&&i.contains(t))}#p(t){if(!this.#s||this.#l<0)return null;for(let n=this.#l+t;n>=0&&n<this.#e.rows.count();n+=t){const i=this.#e.rows.get(n);if(i&&!i.group)return{key:i.key,colId:this.#s.colId}}return null}#g(t){if(!this.#s)return null;const n=this.#e.columns.visible(),i=n.findIndex(s=>s.id===this.#s.colId);for(let s=i+t;s>=0&&s<n.length;s+=t){const c=n[s];if(c.edit&&c.edit.enabled)return{key:this.#s.key,colId:c.id}}return null}#v(t){const n=y(t,s=>s.getAttribute&&s.getAttribute("data-index"));if(!n)return-1;const i=Number(n.getAttribute("data-index"));return Number.isFinite(i)?i:-1}#b(t,n){const i=this.#n.viewport.root;if(!i||!i.querySelectorAll)return null;for(const s of i.querySelectorAll(`[data-col="${n}"]`)){const c=y(s,d=>d.getAttribute&&d.getAttribute("data-key"));if(c&&c.getAttribute("data-key")===t)return s}return null}close(){this.#c&&B(this.#c,null);const t=this.#y();if(this.#i&&N(this.#i.destroy)&&this.#i.destroy(),this.#a){if(this.#a.classList.remove(k),this.#o&&N(this.#o.releaseCell)){const n=this.#s?this.#e.columns.get(this.#s.colId):null;this.#o.releaseCell(this.#a,n)}this.#a.replaceChildren&&this.#a.replaceChildren(),t&&this.#w(this.#a),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#a=null,this.#s=null,this.#l=-1,this.#d=!1}#y(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&N(this.#i.element)?this.#i.element():null,i=s=>!!s&&N(s.contains)&&s.contains(t);return i(n)||i(this.#a)}#w(t){const i=N(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;i&&N(i.focus)&&i.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function y(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function u(r,t,n){if(!N(t.getBoundingClientRect))return;const i=t.getBoundingClientRect(),s=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(i.top-s.top)}px`,r.style.minWidth=`${Math.round(i.width)}px`,r.style.left=`${Math.round(i.left-s.left)}px`;const c=r.offsetWidth||Math.round(i.width),d=Math.round(i.left-s.left)+c-Math.round(s.width);d>0&&(r.style.left=`${Math.max(0,Math.round(i.left-s.left)-d)}px`)}function o(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;N(t.focus)&&t.focus(),N(t.select)&&t.select()}}),ve("packages/dom/src/editbar.js",function(e,V){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return H}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,B=`${V("packages/dom/src/editors/common.js").CLS.editor}-bar`;class H{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=!1;#c=null;#d=[];constructor(k){this.#e=k.grid,this.#t=k.document,this.#n=k.root}mount(){const k=this.#t,S=k.createElement("div");S.className=B;const y=k.createElement("span");y.className=`${B}__ref`,y.textContent="";const u=k.createElement("div");u.className=`${B}__slot`;const o=k.createElement("span");o.className=`${B}__readonly`,S.appendChild(y),S.appendChild(u),this.#n.insertBefore(S,this.#n.firstChild),this.#r=S,this.#o=y,this.#i=u,this.#s=o;for(const r of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(r,t=>this.#f(t)))}bind(k,S){const y=this.#e.columns.get(S),u=k?this.#e.rows.byKey(k):null;this.#l=u&&y&&!u.group?{key:k,colId:S}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#l){this.#o.textContent="";return}const{key:k,colId:S}=this.#l,y=this.#e.columns.get(S);if(!y)return;if(this.#o.textContent=y.title||S,!!!(y.edit&&y.edit.enabled)){this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s);return}const o=this.#e.rows.byKey(k);if(!o)return;const r=W({grid:this.#e,column:y,colId:S,row:o,data:o.data,value:this.#e.rows.value(k,S),text:this.#e.rows.text(k,S),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:c=>c?this.cancel():this.commit(!0)});if(!r){z(`editbar.noeditor:${S}`,`column "${S}" has no editor.`),this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s);return}this.#a=r;const t=r.element();r.popup?(this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s)):this.#i.appendChild(t),N(r.attached)&&r.attached();const n=c=>this.#m(c),i=()=>{this.#u=!0},s=[t,this.#i];for(const c of s)c.addEventListener("keydown",n),c.addEventListener("input",i),c.addEventListener("change",i);this.#c=()=>{for(const c of s)c.removeEventListener("keydown",n),c.removeEventListener("input",i),c.removeEventListener("change",i)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#a&&N(this.#a.destroy)&&this.#a.destroy(),this.#a=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(k){if(k&&k.colId&&(k.key||k.row&&k.row.key)){this.bind(k.key||k.row.key,k.colId);return}this.refresh()}#m(k){if(k.key==="Enter"){k.preventDefault(),this.commit();return}k.key==="Escape"&&(k.preventDefault(),this.cancel())}commit(k){if(!this.#l||!this.#u&&!k)return!1;const{key:S,colId:y}=this.#l;if(!this.#a||!N(this.#a.value))return!1;const u=this.#a.value();return this.#u=!1,this.#e.edit.start(S,y),this.#e.edit.stop(!1,{value:u,key:S,colId:y}),this.refresh(),!0}destroy(){this.#h();for(const k of this.#d)k();this.#d=[],this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#l=null}}}),ve("packages/dom/src/pastepreview.js",function(e,V){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,U=W.clear,B="lat-pastepreview",H='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class L{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(S,y){const u=this.#e;return(u&&u.messages?u.messages:F).t(S,y)}#d(S){const y=`paste.preview.reason.${S}`,u=this.#c(y);return u===y?S:u}#h(S){return S==null||S===""?"":String(S)}#f(S,y){const u=this.#e.columns&&N(this.#e.columns.get)?this.#e.columns.get(y):null;return`${u&&(u.title||u.headerName)||y} · ${S}`}show(S,y){const u=this.#b();if(!u)return!1;this.#s=y&&y.onConfirm,this.#l=y&&y.onCancel||null;const o=S&&S.changes||[],r=S&&S.rejected||[],t=o.filter(i=>i.changed);this.#m(t,r);const n=u.ownerDocument;return this.#a=n&&n.activeElement,u.style.display="",N(u.focus)&&u.focus(),this.#w(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:r.length}),{repeat:!0}),!0}#m(S,y){const u=this.#r.ownerDocument;U(this.#r);const o=_(u,"p",{class:`${B}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:S.length,changes:S.length,rejected:y.length})});if(this.#r.appendChild(o),!S.length&&!y.length){this.#r.appendChild(_(u,"p",{class:`${B}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!S.length;return}this.#o.disabled=!S.length,S.length&&(this.#r.appendChild(_(u,"h3",{class:`${B}__heading`,text:this.#c("paste.preview.changesHeading",{count:S.length})})),this.#r.appendChild(this.#p(u,S))),y.length&&(this.#r.appendChild(_(u,"h3",{class:`${B}__heading ${B}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(u,y)))}#p(S,y){const u=_(S,"tr",{children:[_(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),_(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),_(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),o=y.map(r=>_(S,"tr",{children:[_(S,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),_(S,"td",{class:`${B}__old`,text:this.#h(r.oldValue)}),_(S,"td",{class:`${B}__new`,text:this.#h(r.newValue)})]}));return _(S,"table",{class:`${B}__table`,children:[_(S,"thead",{children:[u]}),_(S,"tbody",{children:o})]})}#g(S,y){const u=_(S,"tr",{children:[_(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),_(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),o=y.map(r=>_(S,"tr",{children:[_(S,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),_(S,"td",{class:`${B}__reason`,text:this.#d(r.reason)})]}));return _(S,"table",{class:`${B}__table ${B}__table--rejected`,children:[_(S,"thead",{children:[u]}),_(S,"tbody",{children:o})]})}confirm(){const S=this.#s;this.#v(),N(S)&&S()}cancel(){const S=this.#l;this.#v(),this.#w(this.#c("a11y.paste.cancelled"),{repeat:!0}),N(S)&&S()}#v(){if(!this.#n)return;this.#n.style.display="none",this.#s=null,this.#l=null;const S=this.#a;this.#a=null,S&&N(S.focus)&&S.focus()}#b(){if(this.#n)return this.#n;const S=this.#t.viewport&&this.#t.viewport.overlays,y=S&&S.ownerDocument;if(!S||!y||!N(y.createElement))return null;const u=`${B}-title`,o=_(y,"h2",{class:`${B}__title`,attrs:{id:u},text:this.#c("paste.preview.title")}),r=_(y,"div",{class:`${B}__body`}),t=_(y,"button",{class:`${B}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),n=_(y,"button",{class:`${B}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),i=_(y,"div",{class:`${B}__foot`,children:[n,t]}),s=_(y,"div",{class:B,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":u},children:[_(y,"div",{class:`${B}__head`,children:[o]}),r,i]});return S.appendChild(s),this.#n=s,this.#r=r,this.#o=t,this.#i=n,this.#y(s,t,n),s}#y(S,y,u){const o=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.cancel();return}if(n.key!=="Tab")return;const i=[...S.querySelectorAll(H)].filter(f=>!f.disabled);if(!i.length){n.preventDefault();return}const s=i[0],c=i[i.length-1],d=S.ownerDocument.activeElement;n.shiftKey&&(d===s||d===S)?(n.preventDefault(),c.focus()):!n.shiftKey&&d===c&&(n.preventDefault(),s.focus())},r=n=>{n&&N(n.preventDefault)&&n.preventDefault(),this.confirm()},t=n=>{n&&N(n.preventDefault)&&n.preventDefault(),this.cancel()};S.addEventListener("keydown",o),y.addEventListener("click",r),u.addEventListener("click",t),this.#u.push(()=>{S.removeEventListener("keydown",o),y.removeEventListener("click",r),u.removeEventListener("click",t)})}#w(S,y){const u=this.#t&&this.#t.announce;N(u)&&u.call(this.#t,S,y)}destroy(){for(const S of this.#u)S();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.#a=null,this.#s=null,this.#l=null}}}),ve("packages/dom/src/rangeselect.js",function(e,V){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/model/selection.js"),_=W.extendSeries,U=W.resolveSelectionConfig,B=V("packages/dom/src/renderer/textentry.js"),H=B.isTextEntry,L=B.isFindBarControl,S=V("packages/dom/src/pastepreview.js").PastePreview,y=V("packages/dom/src/columnmenu.js"),u=y.chartableRange,o=y.rangeChartConfig,r="lat-cell--range",t="lat-cell--range-edge",n=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),i=3;class s{#e;#t;#n;#r=!1;#o=[];#i=null;#a=null;#s=null;#l=null;#u=null;constructor(f){this.#e=f.grid,this.#t=f.renderer,this.#n=f.document,this.#l=f.preview||null}mount(){const f=this.#t.viewport.root,h=m=>this.#c(m),g=m=>this.#d(m),w=()=>this.#h(),p=m=>this.#f(m);f.addEventListener("pointerdown",h),this.#n.addEventListener("pointermove",g),this.#n.addEventListener("pointerup",w),f.addEventListener("keydown",p),this.#o.push(()=>{f.removeEventListener("pointerdown",h),this.#n.removeEventListener("pointermove",g),this.#n.removeEventListener("pointerup",w),f.removeEventListener("keydown",p)});for(const m of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(m,()=>this.paint()));this.paint()}#c(f){if(f.button!==0)return;const h=f.target;if(!h||!N(h.closest))return;if(this.#r=!1,h.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:f.clientX,fromY:f.clientY,armed:!0};return}if(h.closest('[data-role="row-drag"]'))return;const g=this.#L(h);if(!g)return;if(f.shiftKey&&this.#e.selection.corner()){const p=this.#E(g);this.#e.selection.extendRange(p.rowIndex,p.colId),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!0};return}const w=this.#C(g);this.#u=w,this.#e.selection.startRange(w.rowIndex,w.colId,{additive:f.ctrlKey||f.metaKey}),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!1}}#d(f){const h=this.#i;if(!h)return;if(!h.armed){if(Math.abs(f.clientX-h.fromX)+Math.abs(f.clientY-h.fromY)<i)return;h.armed=!0}const g=this.#Y(f.clientX,f.clientY);if(!g)return;if(h.mode==="fill"){this.#s=g,this.paint();return}const w=this.#E(g);this.#e.selection.extendRange(w.rowIndex,w.colId)}#h(){const f=this.#i;if(this.#i=null,!!f){if(f.mode==="fill"&&this.#s){const h=this.#s;this.#s=null,this.fillTo(h.rowIndex)}this.#s=null,this.paint()}}#f(f){if(this.#N()||L(f.target)||H(f.target))return;const h=f.ctrlKey||f.metaKey,g=f.key;if(h&&(g==="c"||g==="C")){this.copy(),f.preventDefault();return}if(h&&(g==="v"||g==="V")){this.paste(),f.preventDefault();return}if(h&&(g==="d"||g==="D")){this.fillDown(),f.preventDefault();return}if(g==="Delete"||g==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),f.preventDefault();return}this.clear(),f.preventDefault();return}if(f.altKey&&g==="F1"){this.chartSelection()&&f.preventDefault();return}if(!f.shiftKey)return;const w={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[g];if(!w)return;if(h){const A=this.#U();if(!A)return;if(!this.#r){const K=this.#C(A);this.#u=K,this.#e.selection.startRange(K.rowIndex,K.colId,{additive:!0}),this.#r=!0}const M=this.#e.columns.visible().map(K=>K.id),C=M.indexOf(A.colId),P=this.#e.selection.corner()||{row:A.rowIndex,colId:A.colId},x=this.#E({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+w[0])),colId:M[Math.min(M.length-1,Math.max(0,(C<0?0:C)+w[1]))]});this.#e.selection.extendRange(x.rowIndex,x.colId),f.preventDefault();return}this.#r=!1;const p=this.#e.selection.corner(),m=this.#U(),b=p||m;if(!b)return;if(!p&&m){const A=this.#C(m);this.#u=A,this.#e.selection.startRange(A.rowIndex,A.colId)}const v=this.#e.columns.visible().map(A=>A.id),l=v.indexOf(b.colId??b.colId),a=v[Math.min(v.length-1,Math.max(0,l+w[1]))],O=Math.min(this.#e.rows.count()-1,Math.max(0,(p?p.row:m.rowIndex)+w[0])),T=this.#E({rowIndex:O,colId:a});this.#e.selection.extendRange(T.rowIndex,T.colId),f.preventDefault()}async copy(){const f=this.#e.export.rangeText();if(!f)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const h=globalThis.navigator&&globalThis.navigator.clipboard;if(!h||!N(h.writeText))return!1;try{return await h.writeText(f),this.#e.emit("clipboard:copy",{text:f,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:f,ok:!1,rows:"range"},"user"),!1}}async paste(){const f=globalThis.navigator&&globalThis.navigator.clipboard;if(!f||!N(f.readText))return 0;let h="";try{h=await f.readText()}catch{return 0}return this.pasteText(h)}pasteText(f){if(!f)return 0;const h=this.#e.selection.cells(),g=h.length?h[0]:this.#y();if(!g)return 0;const w=h.length>1?{rows:new Set(h.map(p=>p.key)).size,columns:new Set(h.map(p=>p.colId)).size}:void 0;if(this.#m()){const p=this.#e.edit.previewPaste(g,f,w);if(p.changes.length+p.rejected.length>1)return this.#p().show(p,{onConfirm:()=>this.#g(g,f,w)}),0}return this.#g(g,f,w)}#m(){const f=this.#e.edit;return!!(f&&f.pastePreview&&N(f.previewPaste))}#p(){return this.#l||(this.#l=new S({grid:this.#e,renderer:this.#t})),this.#l}#g(f,h,g){const w=this.#e.edit.pasteInto(f,h,g);return this.#b(w?this.#v("a11y.range.written",{count:w}):this.#v("a11y.range.refused"),{repeat:!0}),w}#v(f,h){const g=this.#e;return(g&&g.messages?g.messages:F).t(f,h)}#b(f,h){const g=this.#t&&this.#t.announce;N(g)&&g.call(this.#t,f,h)}#y(){const f=this.#U();if(!f)return null;const h=this.#e.rows.get(f.rowIndex);return h?{key:h.key,colId:f.colId}:null}clear(){const f=this.#e.selection.cells();return f.length?this.#e.edit.setCells(f.map(h=>({...h,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const f=this.#e.selection.cells();if(f.length<2)return 0;const h=[...new Set(f.map(p=>p.key))];if(h.length<2)return 0;const g=h[0],w=[];for(const{key:p,colId:m}of f)p!==g&&w.push({key:p,colId:m,value:this.#e.rows.value(g,m)});return this.#e.edit.setCells(w)}chartSelection(){const f=o(this.#e);if(!f.handler)return!1;const h=u(this.#e);return h?(f.handler(this.#e,h),!0):!1}fillTo(f){if(this.#e.selection.ranges().length>1)return 0;const h=this.#e.selection.cells();if(!h.length)return 0;const g=[...new Set(h.map(a=>a.key))],w=[...new Set(h.map(a=>a.colId))],p=this.#_(g[g.length-1]);if(p<0||f<=p)return 0;const m=[];for(let a=p+1;a<=f;a++){const O=this.#e.rows.get(a);if(!O)break;m.push(O)}if(!m.length)return 0;const b=[];for(const a of w){const O=g.map(A=>this.#e.rows.value(A,a)),T=this.#w(O,m,a);for(let A=0;A<m.length;A++)b.push({key:m[A].key,colId:a,value:T[A]})}const v=this.#e.edit.setCells(b),l=this.#e.selection.corner();return l&&this.#e.selection.extendRange(f,l.colId),v}#w(f,h,g){const w=this.#e.get("selection"),p=w&&typeof w=="object"?w.fill:void 0;if(N(p)){const m=this.#e.columns.get(g),b=h.map(l=>({row:l,column:m})),v=p({source:f,target:b,direction:"down"});if(Array.isArray(v)&&v.length===h.length)return v}return _(f,h.length)}paint(){const f=this.#t.viewport.root;if(!f||!f.querySelectorAll)return;const h=this.#e.selection,g=h.ranges().length>0,w=this.#s;for(const p of f.querySelectorAll("[data-col]")){const m=p.getAttribute("data-col"),b=p.parentNode,v=p.getAttribute?p.getAttribute("data-index"):null,l=v!==null&&v!==""?v:b&&b.getAttribute?b.getAttribute("data-index"):null;if(l===null||l==="")continue;const a=Number(l);if(!Number.isFinite(a)||a<0)continue;const O=g&&h.inRange(a,m),T=!!w&&this.#S(a,m,w);p.classList.toggle(r,O||T);const A=O||T?this.#j(a,m,h):null;p.classList.toggle(t,!!A&&A.any);for(const[M,C]of Object.entries(n))p.classList.toggle(C,!!A&&A[M])}this.#A()}#S(f,h,g){const w=this.#e.selection.cells();if(!w.length||!new Set(w.map(b=>b.colId)).has(h))return!1;const m=this.#_([...new Set(w.map(b=>b.key))].pop());return f>m&&f<=g.rowIndex}#j(f,h,g){const w=this.#e.columns.visible().map(l=>l.id),p=w.indexOf(h),m=p>0?w[p-1]:null,b=p>=0&&p<w.length-1?w[p+1]:null,v={top:!g.inRange(f-1,h),bottom:!g.inRange(f+1,h),left:!m||!g.inRange(f,m),right:!b||!g.inRange(f,b)};return v.any=v.top||v.bottom||v.left||v.right,v}#A(){const f=this.#e.selection.corner(),h=this.#t.viewport.overlays;if(!h)return;if(!f||this.#R()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#a&&(this.#a.style.display="none");return}const g=this.#D(f.row,f.colId);if(!g||!N(g.getBoundingClientRect)){this.#a&&(this.#a.style.display="none");return}this.#a||(this.#a=this.#n.createElement("div"),this.#a.className="lat-fill-handle",this.#a.setAttribute("data-role","fill-handle"),this.#a.setAttribute("title",this.#v("a11y.fillHandle")),h.appendChild(this.#a));const w=g.getBoundingClientRect(),p=this.#t.viewport.root.getBoundingClientRect();this.#a.style.display="";const b=this.#t.viewport.rtl===!0?w.left:w.right;this.#a.style.left=`${Math.round(b-p.left)-4}px`,this.#a.style.top=`${Math.round(w.bottom-p.top)-4}px`}#O(f){const h=this.#t;return!f||typeof h.spanAt!="function"?null:h.spanAt(f.rowIndex,f.colId)}#C(f){const h=this.#O(f);return h?{rowIndex:h.row,colId:h.columnId}:f}#E(f){const h=this.#O(f);if(!h)return f;const g=this.#u,w=!!g&&g.rowIndex>=h.row+h.rows,p=this.#x(),m=g?p.indexOf(g.colId):-1,b=m>=0&&m>=h.col+h.cols;return{rowIndex:w?h.row:h.row+h.rows-1,colId:b?h.columnId:h.endColumnId}}#T(){const f=this.#e.selection.corner();if(!f)return!1;const h=this.#O({rowIndex:f.row,colId:f.colId});return!!h&&(h.rows>1||h.cols>1)}#x(){const f=this.#e.columns;return f&&N(f.visible)?f.visible().map(h=>h.id):[]}#R(){return U(this.#e.get("selection")).fillHandle}#N(){const f=this.#t.viewport.root;return!!(f&&f.querySelector&&f.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const f=this.#e.selection.cells();return f.length?f[0]:null}#_(f){for(let h=0;h<this.#e.rows.count();h++){const g=this.#e.rows.get(h);if(g&&g.key===f)return h}return-1}#U(){const f=this.#t.viewport.root,h=f&&f.querySelector?f.querySelector('[data-col][tabindex="0"]'):null;return h?this.#L(h):null}#L(f){if(!f||!N(f.closest))return null;const h=f.closest("[data-col]");if(!h||!h.classList.contains("lat-cell"))return null;const g=h.closest("[data-index]");if(!g)return null;const w=Number(g.getAttribute("data-index"));return!Number.isFinite(w)||w<0?null:{rowIndex:w,colId:h.getAttribute("data-col")}}#Y(f,h){const g=this.#n.elementFromPoint?this.#n.elementFromPoint(f,h):null;return g?this.#L(g):null}#D(f,h){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return null;for(const w of g.querySelectorAll(`[data-col="${h}"]`)){const p=w.closest?w.closest("[data-index]"):null;if(p&&Number(p.getAttribute("data-index"))===f)return w}return null}destroy(){for(const f of this.#o)f();this.#o=[],this.#a&&N(this.#a.remove)&&this.#a.remove(),this.#a=null,this.#i=null,this.#s=null,this.#l&&N(this.#l.destroy)&&this.#l.destroy(),this.#l=null}}const c=s}),ve("packages/dom/src/importer.js",function(e,V){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return s}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/import/index.js"),_=W.parseDelimited,U=W.inferColumns,B=W.mapRecords,H=W.readXlsx,L=W.looksLikeXlsx,k=V("packages/dom/src/editors/common.js"),S=k.el,y=k.clear,u=k.on,r=V("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",n='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',i=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class s{#e;#t;#n;#r;#o=[];#i=null;#a=null;#s=null;#l=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.document;const f=d.settings&&typeof d.settings=="object"?d.settings:{};this.#r={file:f.file!==!1,drop:f.drop!==!1,paste:f.paste!==!1,mode:f.mode==="replace"?"replace":"append"},this.#u()}#u(){const d=this.#t&&this.#t.viewport?this.#t.viewport.root:null;d&&(this.#r.drop&&(this.#o.push(u(d,"dragover",f=>{f.dataTransfer&&[...f.dataTransfer.types||[]].includes("Files")&&(f.preventDefault(),d.classList.add("lat-import--dropzone"))})),this.#o.push(u(d,"dragleave",()=>d.classList.remove("lat-import--dropzone"))),this.#o.push(u(d,"drop",f=>{d.classList.remove("lat-import--dropzone");const h=f.dataTransfer&&f.dataTransfer.files&&f.dataTransfer.files[0];h&&(f.preventDefault(),this.#c(h))}))),this.#r.paste&&this.#o.push(u(d,"paste",f=>{if(r(f.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const h=f.clipboardData&&f.clipboardData.getData("text/plain");!h||!h.includes(`
|
|
54
|
-
`)||(f.preventDefault(),this.fromText(h))})))}openFile(){const d=S(this.#n,"input",{attrs:{type:"file",accept:i}});d.style.display="none",this.#o.push(u(d,"change",()=>{const f=d.files&&d.files[0];f&&this.#c(f),d.parentNode&&d.parentNode.removeChild(d)})),this.#n.body.appendChild(d),d.click()}#c(d){if(N(d.arrayBuffer)){d.arrayBuffer().then(h=>{const g=new Uint8Array(h);if(L(g)){this.fromXlsx(g,d.name);return}this.fromText(new TextDecoder().decode(g),d.name)});return}if(N(d.text)){d.text().then(h=>this.fromText(h,d.name));return}const f=new this.#n.defaultView.FileReader;f.onload=()=>this.fromText(String(f.result||""),d.name),f.readAsText(d)}async fromXlsx(d,f){const{header:h,rows:g}=await H(d);if(!h.length)return;const w=U(h,g,{columns:this.#e.columns.all()}),p=g.filter(m=>m.length!==h.length).length;this.#s={rows:g,columns:w,delimiter:null,name:f,warnings:p?[`${p} row(s) do not have ${h.length} columns`]:[]},this.#d()}fromText(d,f){const{header:h,rows:g,delimiter:w}=_(d);if(!h.length)return;const p=U(h,g,{columns:this.#e.columns.all()}),m=g.filter(b=>b.length!==h.length).length;this.#s={rows:g,columns:p,delimiter:w,name:f,warnings:m?[`${m} row(s) do not have ${h.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#l=this.#n.activeElement,this.#i.hidden=!1;const d=this.#i.querySelector(n);d&&N(d.focus)&&d.focus(),this.#h(this.#f("import.opened",{count:this.#s.rows.length}),{repeat:!0})}#h(d,f){const h=this.#t&&this.#t.announce;N(h)&&h.call(this.#t,d,f)}#f(d,f){return(this.#e&&this.#e.messages?this.#e.messages:F).t(d,f)}#m(){const d=this.#n,f=S(d,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),h=S(d,"div",{class:`${t}__panel`});h.appendChild(S(d,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#a=S(d,"div",{class:`${t}__body`}),h.appendChild(this.#a);const g=S(d,"div",{class:`${t}__footer`}),w=S(d,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=S(d,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(w,"click",()=>this.close())),this.#o.push(u(p,"click",()=>this.#g())),g.appendChild(w),g.appendChild(p),h.appendChild(g),f.appendChild(h),this.#o.push(u(f,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const v=[...f.querySelectorAll(n)].filter(O=>!O.hidden);if(!v.length)return;const l=v[0],a=v[v.length-1];b.shiftKey&&this.#n.activeElement===l?(b.preventDefault(),a.focus()):!b.shiftKey&&this.#n.activeElement===a&&(b.preventDefault(),l.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(f),this.#i=f}#p(){const d=this.#n,f=y(this.#a),{rows:h,columns:g,name:w,warnings:p}=this.#s;f.appendChild(S(d,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:h.length,name:w||this.#f("import.clipboard")})}));for(const O of p)f.appendChild(S(d,"p",{class:`${t}__warning`,text:O}));const m=this.#e.columns.all().map(O=>O.field||O.id).filter(Boolean),b=S(d,"table",{class:`${t}__map`}),v=S(d,"tr",{});for(const O of["import.colSource","import.colField","import.colType"])v.appendChild(S(d,"th",{text:this.#f(O)}));b.appendChild(v),g.forEach((O,T)=>{const A=S(d,"tr",{});A.appendChild(S(d,"td",{text:O.source}));const M=S(d,"select",{attrs:{"data-col":String(T),"aria-label":this.#f("import.mapLabel",{source:O.source})}});M.appendChild(S(d,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of m)M.appendChild(S(d,"option",{text:P,attrs:{value:P,selected:P===O.field?!0:null}}));O.field&&!m.includes(O.field)&&M.appendChild(S(d,"option",{text:O.field,attrs:{value:O.field,selected:!0}}));const C=S(d,"td",{});C.appendChild(M),A.appendChild(C),A.appendChild(S(d,"td",{class:`${t}__type`,text:O.type})),b.appendChild(A)}),f.appendChild(b);const l=S(d,"div",{class:`${t}__mode`}),a=S(d,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});a.appendChild(S(d,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),a.appendChild(S(d,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),l.appendChild(S(d,"label",{text:this.#f("import.modeLabel")})),l.appendChild(a),f.appendChild(l)}#g(){const{rows:d,columns:f}=this.#s;for(const m of this.#i.querySelectorAll("select[data-col]")){const b=Number(m.getAttribute("data-col"));f[b]&&m.value!==void 0&&m.value!==null&&(f[b].field=m.value)}const h=this.#i.querySelector("select[data-mode]"),g=h?h.value:void 0,w=g==="replace"||g==="append"?g:this.#r.mode,p=B(d,f);this.#e.import.apply(p,{mode:w}),this.close(),this.#h(this.#f("import.done",{count:p.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#s=null,this.#l&&N(this.#l.focus)&&this.#l.focus(),this.#l=null}destroy(){for(const d of this.#o)d();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null}}}),ve("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,U=W.on,B=W.clear,H=W.documentFor,L="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,o)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const o=u||{};if(this.doc=H(o),this.host=o.host||{},this.props=o.props||{},this.root=_(this.doc,"div",{class:["lattice-tokens",L],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 r=_(this.doc,"button",{class:`${L}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(U(r,"click",()=>this.toggle())),this.root.appendChild(r),this.toggleButton=r,this.menu=_(this.doc,"div",{class:`${L}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,o,r){const t=_(this.doc,"button",{class:`${L}__${u}`,attrs:{type:"button"},children:[_(this.doc,"span",{class:`${L}__glyph`,text:r,attrs:{"aria-hidden":"true"}}),_(this.doc,"span",{class:`${L}__label`,text:o})]});return this.off.push(U(t,"click",()=>{const n=this.host[u];N(n)&&n(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,o=N(u.canUndo)?u.canUndo():!1,r=N(u.canRedo)?u.canRedo():!1,t=N(u.peek)?u.peek("undo"):null,n=N(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",o,t),this.#t(this.redoButton,"redo",r,n),this.open&&this.#n()}#t(u,o,r,t){if(!u)return;u.disabled=!r;const n=o==="undo",i=this.t(n?"history.undo":"history.redo"),s=u.querySelector(`.${L}__label`);s&&(s.textContent=i);const c=t&&t.label?this.t("history.described",{action:i,label:t.label}):i;u.setAttribute("title",r?c:this.t(n?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",r?c:this.t(n?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;B(u);const o=N(this.host.list)?this.host.list():[];if(!o.length){u.appendChild(_(this.doc,"p",{class:`${L}__empty`,text:this.t("history.empty")}));return}o.forEach((r,t)=>{const n=_(this.doc,"button",{class:`${L}__item`,attrs:{type:"button",role:"menuitem","data-type":r.type,"data-undone":r.undone?"true":null},children:[_(this.doc,"span",{class:`${L}__kind`,text:r.type}),_(this.doc,"span",{class:`${L}__text`,text:r.label||r.type})]});this.off.push(U(n,"click",()=>{const i=t+1;for(let s=0;s<i;s++)N(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(n)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&N(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=k}),ve("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,_={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},U="lat-cell--changed",B="lat-cell--added-column";class H{#e;#t;#n=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){for(const y of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(y,()=>this.paint()));this.paint()}paint(){const y=this.#t.viewport.root;if(!y||!y.querySelectorAll)return;const u=this.#e.diff,o=u&&u.enabled;for(const r of y.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key"),n=o?u.statusOf(t):"unchanged";for(const s of Object.values(_))r.classList.remove(s);o&&_[n]&&r.classList.add(_[n]),r.setAttribute("data-diff",o?n:"");const i=o&&n==="changed";for(const s of r.querySelectorAll("[data-col]")){const c=s.getAttribute("data-col");if(s.classList.remove(U,B),s.removeAttribute("data-before"),!i)continue;const d=u.cellStatus(t,c);if(d==="changed"){s.classList.add(U);const f=this.#r(u,t,c);f===null?s.removeAttribute("title"):(s.setAttribute("data-before",f),s.setAttribute("title",this.#o("diff.before",{value:f})))}else d==="added-column"&&s.classList.add(B)}}}#r(y,u,o){const r=this.#e,t=r&&r.columns,n=t&&N(t.get)?t.get(o):null,i=r&&r.permissions;if(n&&i&&N(i.isSecret)&&i.isSecret(n))return null;const s=y.before(u,o);if(s==null)return this.#o("diff.empty");if(!n||!N(n.formatValue))return String(s);const c=N(y.beforeRow)?y.beforeRow(u):void 0,f={...(r.rows&&N(r.rows.byKey)?r.rows.byKey(u):null)||{},data:c===void 0?{}:c};try{const h=n.formatValue(s,f,f.data);return h==null?"":String(h)}catch(h){return z(`diff-before-format:${o}`,`the formatter for column "${o}" threw while formatting a previous value, so the diff hover shows the raw one.`,h),String(s)}}#o(y,u){const o=this.#e;return(o&&o.messages?o.messages:W).t(y,u)}destroy(){for(const u of this.#n)u();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const u of y.querySelectorAll("[data-key]")){for(const o of Object.values(_))u.classList.remove(o);u.removeAttribute("data-diff")}for(const u of y.querySelectorAll("[data-col]"))u.classList.remove(U,B),u.removeAttribute("data-before")}}}function L(S){return!!(S&&S.diff&&(N(S.diff)||typeof S.diff=="object"))}const k=H}),ve("packages/dom/src/highlightpaint.js",function(e,V){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z="lat-cell--highlight",F="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(B){this.#e=B.grid,this.#t=B.renderer,this.#i=B.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 B=()=>{this.#o=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):N(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const H=this.#s();if(H){H.sweep();for(const L of B.querySelectorAll("[data-key]")){const k=L.getAttribute("data-key");for(const S of L.querySelectorAll("[data-col]")){const y=H.active?H.colourFor(k,S.getAttribute("data-col")):null;y?(S.classList.add(z),S.style.setProperty(F,y)):S.classList.contains(z)&&(S.classList.remove(z),S.style.removeProperty(F))}}this.#a(H)}}#a(B){this.#r!==null&&N(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=B.nextExpiry;if(!Number.isFinite(H)||!N(this.#i.setTimeout))return;const L=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},L)}#s(){const B=this.#e.highlight;return B&&N(B.model)?B.model():null}destroy(){this.#r!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll))for(const H of B.querySelectorAll(`.${z}`))H.classList.remove(z),H.style.removeProperty(F)}}const _=W}),ve("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z="lat-cell--find",F="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(B){this.#e=B.grid,this.#t=B.renderer,this.#i=B.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 B=()=>{this.#r=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):N(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const H=this.#e.find;if(!H||!N(H.stateFor))return;const L=N(H.model)?H.model():null,k=!!L&&L.active;if(!k&&!this.#o)return;let S=!1;for(const y of B.querySelectorAll("[data-key]")){const u=y.getAttribute("data-key");for(const o of y.querySelectorAll("[data-col]")){const r=k?H.stateFor(u,o.getAttribute("data-col")):null;r?(S=!0,o.classList.add(z),o.classList.toggle(F,r==="current")):o.classList.contains(z)&&o.classList.remove(z,F)}}this.#o=S}destroy(){for(const H of this.#n)H();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll)){for(const H of B.querySelectorAll(`.${z}`))H.classList.remove(z,F);this.#o=!1}}}const _=W}),ve("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Z=V("packages/dom/src/editors/common.js"),N=Z.el,z=Z.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction,L="lat-find",k=12,S=120;class y{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#v=null;#b=null;#y=!1;constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document||r.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=r.settings&&typeof r.settings=="object"?r.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(r,t){const n=this.#e;return(n&&n.messages&&H(n.messages.t)?n.messages:U).t(r,t)}mount(){const r=this.#S();if(!r)return;r.attachUi({open:n=>this.show(n),close:()=>this.hide(),focus:()=>{this.#a&&this.#a.focus()}}),r.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&H(t.addEventListener)&&this.#o.shortcut!==!1){const n=i=>{if(!(i.ctrlKey||i.metaKey)||i.altKey||i.shiftKey||i.key!=="f"&&i.key!=="F")return;const s=i.target;if(this.#a&&s===this.#a){i.preventDefault(),i.stopPropagation(),H(this.#a.select)&&this.#a.select();return}W(s)||(i.preventDefault(),i.stopPropagation(),this.show())};t.addEventListener("keydown",n,!0),this.#g.push(()=>t.removeEventListener("keydown",n,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#R())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(r){const t=this.#j();if(!t)return;const n=t.style.display!=="none";t.style.display="",n||this.#w(),this.#S().setOpen(!0),r!=null&&(this.#a.value=String(r),this.#C()),this.#a.focus(),H(this.#a.select)&&this.#a.select(),this.#R()}hide(){this.#_();const r=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),r&&(r.clear(),r.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(H(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;H(s.focus)&&s.focus()}search(){this.#C()}destroy(){this.#y=!0,this.#_();for(const t of this.#g)t();this.#g=[];const r=this.#S();r&&(r.attachUi(null),r.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const r=this.#t;r&&H(r.invalidate)&&r.invalidate("size")}#S(){const r=this.#e&&this.#e.find;return r&&H(r.model)?r.model():null}#j(){if(this.#i)return this.#i;const r=this.#t.viewport,t=r?.root,n=this.#n;if(!t||!n||!H(t.insertBefore))return null;const i=N(n,"div",{class:L,attrs:{role:"search","aria-label":this.t("find.label")}});this.#a=N(n,"input",{class:`${L}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#s=N(n,"span",{class:`${L}__count`,attrs:{"aria-hidden":"true"}}),this.#l=N(n,"span",{class:`${L}__scope`,attrs:{"aria-hidden":"true"}}),this.#l.style.display="none",this.#u=N(n,"span",{class:`${L}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=N(n,"button",{class:`${L}__nav ${L}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),c=N(n,"button",{class:`${L}__nav ${L}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=N(n,"button",{class:`${L}__toggle ${L}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=N(n,"button",{class:`${L}__toggle ${L}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=N(n,"select",{class:`${L}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const d=N(n,"button",{class:`${L}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),f=N(n,"div",{class:`${L}__options`,children:[this.#c,this.#d,this.#h]});for(const g of[this.#a,this.#s,this.#l,this.#u,s,c,d,f])i.appendChild(g);this.#g.push(z(this.#a,"input",()=>this.#O())),this.#g.push(z(s,"click",()=>this.#e.find.prev())),this.#g.push(z(c,"click",()=>this.#e.find.next())),this.#g.push(z(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#C()})),this.#g.push(z(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#C()})),this.#g.push(z(this.#h,"change",()=>{const g=this.#h.value;this.#p=g?String(g):null,this.#C()})),this.#g.push(z(d,"click",()=>this.hide()));const h=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),this.hide();return}g.key==="Enter"&&g.target===this.#a&&(g.preventDefault(),g.stopPropagation(),this.#v!==null&&(this.#N(),this.#C()),g.shiftKey?this.#e.find.prev():this.#e.find.next())};return i.addEventListener("keydown",h),this.#g.push(()=>i.removeEventListener("keydown",h)),i.style.display="none",t.insertBefore(i,r.header||t.firstChild),this.#i=i,this.#A(),i}#A(){const r=this.#h;if(!r)return;const t=this.#n;for(;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(N(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const n=this.#e.columns,i=n&&H(n.visible)?n.visible():[];let s=!1;for(const c of i){if(!c||c.id===void 0)continue;const d=String(c.id);r.appendChild(N(t,"option",{text:c.title||d,attrs:{value:d}})),d===this.#p&&(s=!0)}s||(this.#p=null),r.value=this.#p||""}#O(){const r=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#N(),r===0||!H(this.#r.setTimeout)){this.#C();return}this.#v=this.#r.setTimeout(()=>{this.#v=null,this.#C()},r)}#C(){const r=this.#S();if(!r||this.#y)return;const t=this.#a?this.#a.value:"";if(!t){this.#M(),r.clear();return}r.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#E()}),this.#T()}#E(){const r=this.#t&&this.#t.window,t=r&&Number.isFinite(r.first)?r.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#y)return;const r=()=>{this.#b=null,this.#x()};H(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(r):H(this.#r.setTimeout)?this.#b=this.#r.setTimeout(r,0):r()}#x(){const r=this.#S();!r||this.#y||!r.active||(r.stale&&r.rescan({from:this.#E()}),!r.complete&&(r.step(k)||this.#T()))}#R(){if(!this.#i||this.#y)return;const r=this.#e.find.count(),t=this.#S().active;let n="",i="idle";t&&(r.total===0?(n=r.complete?this.t("find.none"):this.t("find.searching"),i=r.complete?"none":"searching"):(n=this.t(r.complete?"find.count":"find.countPartial",{current:r.current,total:r.total}),i=r.complete?"matches":"searching")),this.#s.textContent=n,this.#i.setAttribute("data-state",i);const s=t&&r.windowed;this.#l.textContent=s?this.t("find.loadedRows"):"",this.#l.style.display=s?"":"none",t?r.complete&&(this.#u.textContent=r.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:r.current,count:r.total})):this.#u.textContent=""}#N(){this.#v!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#v),this.#v=null}#M(){this.#b!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#N(),this.#M()}}const u=y}),ve("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Z="lat-cell--redacted",N="lat-cell";class z{#e;#t;#n=[];constructor(_){this.#e=_.grid,this.#t=_.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const _=this.#t.viewport?.root;if(!_||!_.querySelectorAll)return;const U=this.#e.redaction;if(!U)return;const B=U.active;for(const H of _.querySelectorAll(`.${N}[data-col]`))B&&U.has(H.getAttribute("data-col"))?H.classList.add(Z):H.classList.contains(Z)&&H.classList.remove(Z)}destroy(){for(const _ of this.#n)_();this.#n=[]}}const F=z}),ve("packages/dom/src/validationpaint.js",function(e,V){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/dom/src/editors/common.js").markInvalid,z="lat-cell";function F(U,B){let H=U;for(;H;){if(B(H))return H;H=H.parentNode}return null}class W{#e;#t;#n=[];constructor(B){this.#e=B.grid,this.#t=B.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const B of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(B,()=>this.paint()));this.paint()}#r(B){const H=F(B,L=>L.getAttribute&&L.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const B=this.#e.validation;if(!B||!B.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const L of H.querySelectorAll(`.${z}[data-col]`)){const k=L.getAttribute("data-col"),S=this.#r(L),y=S?B.errorFor(S,k):null;N(L,y?y.message:null)}}destroy(){for(const B of this.#n)B();this.#n=[]}}const _=W}),ve("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/renderer/textentry.js").isTextEntry,_=V("packages/dom/src/renderer/viewport.js").CLASS,U="lat-presenting",B="lat-presenting--changing",H="lat-presenting__progress",L="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#a=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",r=>this.#l(r))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&N(this.#n.watch)&&this.#r.push(this.#n.watch(r=>{r||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const o=this.#t.viewport?.root;if(o&&N(o.addEventListener)){const r=t=>this.#s(t);o.addEventListener("keydown",r),this.#r.push(()=>o.removeEventListener("keydown",r))}}#s(o){const r=this.#e.presentation;if(!r?.active)return;const t=o.ctrlKey||o.metaKey,n=o.key;if(n==="Escape"&&!this.#n){o.defaultPrevented||(r.stop(),o.preventDefault?.());return}if(t){n==="="||n==="+"?(r.nudge(1),o.preventDefault?.()):n==="-"||n==="_"?(r.nudge(-1),o.preventDefault?.()):n==="0"&&(r.setScale(1.5),o.preventDefault?.());return}if(!r.views.length||F(o.target))return;n==="ArrowRight"||n==="ArrowDown"||n==="PageDown"||n===" "?(r.step(1),o.preventDefault?.()):n==="ArrowLeft"||n==="ArrowUp"||n==="PageUp"?(r.step(-1),o.preventDefault?.()):n==="Home"?(r.goTo(0),o.preventDefault?.()):n==="End"?(r.goTo(r.views.length-1),o.preventDefault?.()):(n==="r"||n==="R")&&(r.reset(),o.preventDefault?.())}#l(o){!o||!o.viewId||(this.#u(),this.#e.views?.apply?.(o.viewId),this.#c(o))}#u(){const o=this.#t.viewport?.root;o?.classList&&(o.classList.remove(B),o.offsetWidth,o.classList.add(B))}#c(o){const r=this.#t.viewport?.overlays;if(!r||!this.#e.presentation.views.length)return;const t=r.ownerDocument;if(!t?.createElement)return;if(!this.#i){const s=t.createElement("div");s.className=H,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),r.appendChild(s),this.#i=s}const n=this.#e.views?.get?.(o.viewId),i=n&&n.name?n.name:"";this.#i.textContent=i?`${i} · ${(o.index||0)+1} / ${o.count||0}`:`${(o.index||0)+1} / ${o.count||0}`}#d(){if(this.#o){this.#f();return}const o=!!(this.#n&&this.#n.active());this.#n&&!o&&this.#n.enter();const r=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const i of k){if(r.has(i)||i==="toolPanel"&&this.#y())continue;const s=this.#w(i);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",t.push(s))}const n=this.#v();n&&n.style&&n.style.display!=="none"&&this.#b(n)&&(n.style.display="none",t.push(n)),this.#o={maximised:o,hidden:t},this.#t.viewport?.root?.classList?.add(U),this.#f(),this.#p()}#h(){const o=this.#o;this.#o=null;const r=this.#t.viewport?.root;if(r?.classList?.remove(U),r?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),r?.classList?.remove(B),this.#m(),o){const t=this.#e.toolPanel;t&&N(t.presentRestore)&&t.presentRestore();for(const n of o.hidden)n.style.display="";this.#n&&!o.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const o=this.#t.viewport?.root;!o||!o.style||(o.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const o=this.#t.viewport?.root;if(!o?.querySelectorAll)return;const r=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=r&&r.keys.length?new Set(r.keys):null,n=r&&r.colIds.length?new Set(r.colIds):null;for(const i of o.querySelectorAll("[data-key]")){const s=!t||t.has(i.getAttribute("data-key"));for(const c of i.querySelectorAll("[data-col]"))!r||s&&(!n||n.has(c.getAttribute("data-col")))?c.classList.remove(L):c.classList.add(L)}}#p(){this.#g();const o=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(o)||o<=0||!this.#e.presentation.views.length)return;const r=this.#t.viewport?.root?.ownerDocument?.defaultView;r?.setInterval&&(this.#a=r.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,o)))}#g(){if(this.#a===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#a),this.#a=null}#v(){const o=this.#e.element;return!o||!N(o.querySelector)?null:o.querySelector(`.${_.statusBar}`)}#b(o){const r=o.children||[];for(const t of r)if(!t.style||t.style.display!=="none")return!1;return!0}#y(){const o=this.#e.toolPanel;return!!(o&&N(o.presentOnly)&&o.presentOnly())}#w(o){const r=this.#e.element;if(!r||!N(r.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[o];return t?r.querySelector(t):null}destroy(){this.#o&&this.#h();for(const o of this.#r)o();this.#r=[]}}const y=S}),ve("packages/dom/src/capture.js",function(e,V){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const N=V("packages/core/src/internal/util.js").isFunction,z=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(H,L,k){const S=k.getComputedStyle(H),y=L.style;if(y)for(let u=0;u<S.length;u++){const o=S[u];z.has(o)||y.setProperty(o,S.getPropertyValue(o),S.getPropertyPriority(o))}}function W(H,L,k){if(F(H,L,k),H.tagName==="CANVAS"&&N(H.toDataURL))try{const u=H.toDataURL("image/png"),o=L.style;o&&(o.setProperty("background-image",`url(${u})`),o.setProperty("background-size","100% 100%"),o.setProperty("background-repeat","no-repeat"))}catch{}const S=H.children||[],y=L.children||[];for(let u=0;u<S.length&&u<y.length;u++)W(S[u],y[u],k)}function _(H,L){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,L).origin===L}catch{return!0}}async function U(H,L={}){const k=H.ownerDocument,S=k?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(y.width)),o=Math.max(1,Math.ceil(y.height)),r=Math.max(.1,Number(L.scale)||2),t=S.location?.origin||"";for(const h of H.querySelectorAll("img")){const g=h.getAttribute("src")||"";if(!_(g,t))throw new Error(`capture refused: the image at ${g} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const n=H.cloneNode(!0);W(H,n,S),n.style.width=`${u}px`,n.style.height=`${o}px`,n.style.margin="0";const i=new S.XMLSerializer().serializeToString(n),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${o}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${i}</div></foreignObject></svg>`,c=new S.Image;await new Promise((h,g)=>{c.onload=()=>h(void 0),c.onerror=()=>g(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const d=k.createElement("canvas");d.width=Math.round(u*r),d.height=Math.round(o*r);const f=d.getContext("2d");if(!f)throw new Error("capture could not get a 2d context");return f.fillStyle=L.background||S.getComputedStyle(H).backgroundColor||"#ffffff",f.fillRect(0,0,d.width,d.height),f.drawImage(c,0,0,d.width,d.height),new Promise((h,g)=>{d.toBlob(w=>w?h({blob:w,width:d.width,height:d.height}):g(new Error("capture produced no image")),L.type||"image/png",L.quality)})}const B=U}),ve("packages/dom/src/annotate.js",function(e,V){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,_=Object.freeze(["pen","arrow","rect","highlight"]),U=Object.freeze(["freehand","arrow","rect","highlight","text"]),B=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),H=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),L=14,k="system-ui, -apple-system, sans-serif";function S(s,c){if(!s||typeof s!="object")return null;const d=B[s.type];if(!d)return null;const f=Array.isArray(s.points)?s.points:[],h=[];for(const w of f){const p=Number(w&&w.x),m=Number(w&&w.y);Number.isFinite(p)&&Number.isFinite(m)&&h.push({x:p,y:m})}const g=typeof s.colour=="string"&&s.colour?s.colour:c;if(d==="text"){const w=typeof s.text=="string"?s.text:"";if(!h.length||!w)return null;const p={tool:d,colour:g,points:[h[0]],text:w,region:y(s.region)},m=Number(s.fontSize);return Number.isFinite(m)&&m>0&&(p.fontSize=m),typeof s.background=="string"&&s.background&&(p.background=s.background),p}return h.length<2?null:{tool:d,colour:g,points:h,region:y(s.region)}}function y(s){return s==="start"||s==="end"?s:"centre"}function u(s){const c={type:H[s.tool]||s.tool,colour:s.colour,points:s.points.map(d=>({x:d.x,y:d.y}))};return(s.region==="start"||s.region==="end")&&(c.region=s.region),s.tool==="text"&&(c.text=s.text,s.fontSize!==void 0&&(c.fontSize=s.fontSize),s.background!==void 0&&(c.background=s.background)),c}const o="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(s){return s==="arrow"||s==="rect"}class n{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#a=[];#s=null;#l=[];#u=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#u=Array.isArray(c.seed)?c.seed:null}get tool(){return this.#o}get count(){return this.#a.length}mount(){this.#l.push(this.#e.on("scroll",()=>this.redraw())),this.#l.push(this.#e.on("render:done",()=>this.redraw())),this.#l.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(c){const d=S(c,this.#i);return d?(d.durable=!0,this.#a.push(d),this.#w(),this.redraw(),this.#A(),this.#a.length):(z("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${U.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#a.length)}list(){return this.#a.map(u)}replaceAll(c){const d=Array.isArray(c)?c:[];this.#a=d.map(f=>S(f,this.#i)).filter(Boolean);for(const f of this.#a)f.durable=!0;this.#a.length&&this.#w(),this.redraw(),this.#A()}#c(){const c=this.#t.viewport?.root;if(!c||!N(c.addEventListener))return;const d=f=>{!this.#o||!f||f.key!=="Escape"||(this.use(null),f.preventDefault?.())};c.addEventListener("keydown",d,!0),this.#l.push(()=>c.removeEventListener("keydown",d,!0))}#d(){const c=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!c||!N(c.matchMedia))return;let d=null;const f=()=>{const h=c.devicePixelRatio||1;let g;try{g=c.matchMedia(`(resolution: ${h}dppx)`)}catch{return}d=g;const w=()=>{this.redraw(),f()};N(g.addEventListener)?g.addEventListener("change",w,{once:!0}):N(g.addListener)&&g.addListener(w)};f(),this.#l.push(()=>{d=null})}use(c,d={}){const f=!!d.colour&&c===this.#o;d.colour&&(this.#i=String(d.colour));const h=c&&_.includes(c)?c:null;this.#o=h&&h===this.#o&&!f?null:h;const g=this.#o?this.#w():this.#n;return g&&(g.style.pointerEvents=this.#o?"auto":"none",g.style.cursor=this.#o?"crosshair":""),this.#A(),this.#o}undo(){return this.#a.pop(),this.redraw(),this.#A(),this.#a.length}clear(){this.#a.length&&(this.#a=[],this.redraw(),this.#A())}#h(){const c=this.#a.filter(d=>d.durable);c.length!==this.#a.length&&(this.#a=c,this.redraw(),this.#A())}redraw(){!this.#n&&this.#a.length&&this.#w();const c=this.#n,d=this.#r;if(!c||!d)return;this.#S();const{left:f,top:h}=this.#y();d.clearRect(0,0,c.width,c.height);const g=this.#s?[...this.#a,this.#s]:this.#a;for(const w of["centre","start","end"]){const p=g.filter(m=>y(m.region)===w);if(p.length){d.save(),this.#f(d,w),d.translate((w==="centre"?-f:0)||0,-h||0);for(const m of p)this.#v(d,m);d.restore()}}}#f(c,d="centre"){const f=this.#n,h=this.#t.viewport?.bodyViewport;if(!N(f?.getBoundingClientRect)||!N(h?.getBoundingClientRect))return;const g=f.getBoundingClientRect(),w=h.getBoundingClientRect();if(!w.width||!w.height)return;const p=this.#m(d,w);p&&(c.beginPath(),c.rect(p.left-g.left,w.top-g.top,p.width,w.height),c.clip())}#m(c,d){const f=b=>{if(!N(b?.getBoundingClientRect))return null;const v=b.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},h=f(this.#t.viewport?.bodyStart),g=f(this.#t.viewport?.bodyEnd);if(c==="start")return h;if(c==="end")return g;let w=d.left,p=d.left+d.width;const m=d.left+d.width/2;for(const b of[h,g]){if(!b)continue;const v=b.left+b.width;b.left+b.width/2<m?w=Math.max(w,v):p=Math.min(p,b.left)}return p>w?{left:w,width:p-w}:null}#p(c){for(const[d,f]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!N(f?.getBoundingClientRect))continue;const h=f.getBoundingClientRect();if(h&&h.width>0&&c>=h.left&&c<h.left+h.width)return d}return"centre"}#g(c){const d=this.#t.viewport?.bodyViewport;if(!N(d?.getBoundingClientRect))return!0;const f=d.getBoundingClientRect();return!f.width||!f.height?!0:c.clientX>=f.left&&c.clientX<=f.right&&c.clientY>=f.top&&c.clientY<=f.bottom}#v(c,d){const f=d.points;if(!f.length)return;const h=this.#e.presentation?.scale||1;c.lineWidth=(r[d.tool]||3)*h,c.strokeStyle=d.colour,c.fillStyle=d.colour,c.lineCap="round",c.lineJoin="round",c.globalAlpha=d.tool==="highlight"?.32:1;const g=f[0],w=f[f.length-1];if(d.tool==="text"){const p=(d.fontSize||L)*h;c.font=`${p}px ${k}`,c.textBaseline="top";const m=d.text||"";if(d.background){let b=m.length*p*.6;if(typeof c.measureText=="function"){const v=c.measureText(m);v&&Number.isFinite(v.width)&&(b=v.width)}c.fillStyle=d.background,c.fillRect(g.x-p*.15,g.y-p*.1,b+p*.3,p*1.2)}c.fillStyle=d.colour,c.fillText(m,g.x,g.y),c.globalAlpha=1;return}if(d.tool==="rect")c.strokeRect(g.x,g.y,w.x-g.x,w.y-g.y);else if(d.tool==="arrow")c.beginPath(),c.moveTo(g.x,g.y),c.lineTo(w.x,w.y),c.stroke(),this.#b(c,g,w,c.lineWidth);else{c.beginPath(),c.moveTo(g.x,g.y);for(let p=1;p<f.length;p++)c.lineTo(f[p].x,f[p].y);c.stroke()}c.globalAlpha=1}#b(c,d,f,h){const g=Math.atan2(f.y-d.y,f.x-d.x),w=Math.max(8,h*3);c.beginPath(),c.moveTo(f.x,f.y),c.lineTo(f.x-w*Math.cos(g-Math.PI/7),f.y-w*Math.sin(g-Math.PI/7)),c.lineTo(f.x-w*Math.cos(g+Math.PI/7),f.y-w*Math.sin(g+Math.PI/7)),c.closePath(),c.fill()}#y(){const c=N(this.#t.scrollPosition)?this.#t.scrollPosition():null,d=this.#t.viewport?.rtl===!0;return{left:W(c?.left||0,d),top:c?.top||0}}#w(){if(this.#n)return this.#n;const c=this.#t.viewport?.overlays,d=c?.ownerDocument;if(!c||!d?.createElement)return null;const f=d.createElement("canvas");return f.className=o,f.style.position="absolute",f.style.inset="0",f.style.pointerEvents="none",c.appendChild(f),this.#n=f,this.#r=f.getContext?f.getContext("2d"):null,this.#S(),this.#j(f),f}#S(){const c=this.#n,d=this.#t.viewport?.root;if(!c||!d?.getBoundingClientRect)return;const f=d.getBoundingClientRect(),g=c.ownerDocument?.defaultView?.devicePixelRatio||1,w=Math.max(1,Math.round(f.width*g)),p=Math.max(1,Math.round(f.height*g));c.width===w&&c.height===p||(c.width=w,c.height=p,c.style&&(c.style.width=`${Math.max(1,f.width)}px`,c.style.height=`${Math.max(1,f.height)}px`),this.#r?.setTransform(g,0,0,g,0,0))}#j(c){const d=(p,m="centre")=>{const b=c.getBoundingClientRect(),{left:v,top:l}=this.#y();return{x:p.clientX-b.left+(m==="centre"?v:0),y:p.clientY-b.top+l}},f=p=>{if(!this.#o||!this.#g(p))return;const m=this.#p(p.clientX);this.#s={tool:this.#o,colour:this.#i,points:[d(p,m)],region:m},c.setPointerCapture?.(p.pointerId),p.preventDefault?.()},h=p=>{if(!this.#s)return;const m=d(p,this.#s.region);t(this.#s.tool)&&this.#s.points.length>1&&this.#s.points.pop(),this.#s.points.push(m),this.redraw()},g=p=>{this.#s&&(this.#s.points.length>1&&this.#a.push(this.#s),this.#s=null,c.releasePointerCapture?.(p.pointerId),this.redraw(),this.#A())},w=p=>{if(!this.#o)return;const m=this.#t.viewport?.bodyViewport;if(!m)return;let b=!1;p.deltaY&&typeof m.scrollTop=="number"&&(m.scrollTop+=p.deltaY,b=!0),p.deltaX&&typeof m.scrollLeft=="number"&&(m.scrollLeft+=p.deltaX,b=!0),b&&p.preventDefault?.()};c.addEventListener("pointerdown",f),c.addEventListener("pointermove",h),c.addEventListener("pointerup",g),c.addEventListener("pointercancel",g),c.addEventListener("wheel",w,{passive:!1}),this.#l.push(()=>{c.removeEventListener("pointerdown",f),c.removeEventListener("pointermove",h),c.removeEventListener("pointerup",g),c.removeEventListener("pointercancel",g),c.removeEventListener("wheel",w)})}#A(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#a.length},"user")}destroy(){for(const c of this.#l)c();this.#l=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#a=[]}}const i=n}),ve("packages/dom/src/timelinebar.js",function(e,V){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function _(L){if(!Number.isFinite(L)||L<1e3)return"now";const k=Math.round(L/1e3);if(k<60)return`${k}s ago`;const S=Math.round(k/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function U(L,k){return Number.isFinite(L)?new Date(L).toLocaleTimeString(k||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class B{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#a.push(this.#e.on("timeline:attached",()=>{this.#l(),this.refresh()})),this.#a.push(this.#e.on("timeline:detached",()=>this.#u())),this.#a.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#a.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,S=k.depth,y=k.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-y)),this.#r.disabled=S===0;const u=k.at(),o=k.live;this.#o&&(this.#o.textContent=o?this.#s("timeline.live"):_(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",o?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#s("timeline.recording"):U(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",o?"true":"false")}#s(k,S){const y=this.#e;return(y&&y.messages?y.messages:F).t(k,S)}#l(){if(this.#n)return;const k=this.#t.viewport?.overlays,S=k?.ownerDocument;if(!k||!S?.createElement)return;const y=S.createElement("div");y.className=W;const u=S.createElement("span");u.className=`${W}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const o=S.createElement("input");o.className=`${W}__range`,o.type="range",o.min="0",o.step="1",o.setAttribute("aria-label",this.#s("timeline.scrub"));const r=S.createElement("span");r.className=`${W}__clock`;const t=S.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#s("timeline.goLive"),t.setAttribute("aria-label",this.#s("timeline.returnToPresent")),y.appendChild(u),y.appendChild(o),y.appendChild(r),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=o,this.#o=u,this.#i=r;const n=()=>{const c=this.#e.timeline.depth;this.#e.timeline.seek(c-Number(o.value))};o.addEventListener("input",n);const i=()=>this.#e.timeline.toLive();t.addEventListener("click",i);const s=c=>c.stopPropagation();o.addEventListener("keydown",s),this.#a.push(()=>{o.removeEventListener("input",n),t.removeEventListener("click",i),o.removeEventListener("keydown",s)})}#u(){this.#n&&(N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#a)k();this.#a=[],this.#u()}}const H=B}),ve("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/direction.js").isRtlElement,U="lat-comment-mark",B="lat-cell--commented",H="lat-cell--commented-open";class L{#e;#t;#n=[];#r=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#a(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const o=[];for(const r of u.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key");if(t){o.push(t);for(const n of r.querySelectorAll("[data-col]")){const i=n.getAttribute("data-col"),s=y.at(t,i),c=!!(s&&s.count);n.classList.toggle(B,c),n.classList.toggle(H,c&&s.unresolved>0),this.#i(n,s,i)}}}(o.length!==this.#r.length||o.some((r,t)=>r!==this.#r[t]))&&(this.#r=o,y.request(o))}#o(y,u){const o=this.#e;return(o&&o.messages?o.messages:F).t(y,u)}#i(y,u,o){if(!u||!u.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const r=u.count,t=u.unresolved,n=this.#o("count.comments",{count:r});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:n,unresolved:t}):this.#o("comments.allResolved",{comments:n}))}#a(){const y=this.#t.viewport?.root;if(!y||!N(y.addEventListener))return;const u=r=>{const t=this.#e.comments;if(!t||!t.enabled)return;const n=r.target&&N(r.target.closest)?r.target.closest("[data-col]"):null;if(!n||!n.classList.contains(B)||!this.#s(n,r))return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.stopPropagation(),r.preventDefault(),t.open(s,n.getAttribute("data-col")))},o=r=>{const t=this.#e.comments;if(!t||!t.enabled||!r.altKey||r.key!=="m"&&r.key!=="M")return;const n=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&N(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!n)return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.preventDefault(),r.stopPropagation(),t.open(s,n.getAttribute("data-col")))};y.addEventListener("click",u,!0),y.addEventListener("keydown",o,!0),this.#n.push(()=>{y.removeEventListener("click",u,!0),y.removeEventListener("keydown",o,!0)})}#s(y,u){if(!N(y.getBoundingClientRect))return!1;const o=y.getBoundingClientRect(),r=Math.max(14,Math.min(24,o.height*.6));return(_(y)?u.clientX<=o.left+r:u.clientX>=o.right-r)&&u.clientY<=o.top+r}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=L}),ve("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/editors/common.js").cssEscape,B=V("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class L{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#a=null;constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){const y=this.#e.presence;if(!(!y||!y.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,o=>this.#s(u,o)));this.#l(),this.paint()}}#s(y,u){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const r=u&&u.peer;r&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:r.name}))}#l(){const y=this.#t.viewport?.overlays,u=y?.ownerDocument;if(!y||!u?.createElement)return;const o=this.#e.get("presence")||{},r=u.createElement("span");if(r.className=`${H}__live`,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),y.appendChild(r),this.#r=r,o.roster===!1)return;const t=u.createElement("div");t.className=H,o.roster&&o.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,u=this.#t.viewport?.root;if(!y||!y.enabled||!u?.querySelectorAll)return;this.#d(u);const o=y.peers(),r=[...o].sort((t,n)=>t.at-n.at);for(const t of r)for(const n of t.ranges||[])for(const i of n.rowIds||[])for(const s of n.columns||[])this.#c(u,i,s,t,"range");for(const t of r)t.cursor&&this.#c(u,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of r)t.editing&&this.#c(u,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(o)}#u(y){if(this.#a!==null)return;const u=y.filter(t=>t.cursorFresh);if(!u.length)return;const r=Math.max(...u.map(t=>t.cursorAt||0))+B-Date.now();this.#a=setTimeout(()=>{this.#a=null,this.paint()},Math.max(50,r))}#c(y,u,o,r,t){const n=y.querySelector(`[data-key="${_(u)}"]`),i=n&&n.querySelector(`[data-col="${_(o)}"]`);i&&(i.setAttribute("data-presence",t),i.style.setProperty("--lat-peer",r.colour),i.setAttribute("data-peer-name",r.name),i.setAttribute("data-peer-initial",r.initials||(r.name||"?").slice(0,1).toUpperCase()),r.idle?i.setAttribute("data-peer-idle","true"):i.removeAttribute("data-peer-idle"),t==="cursor"&&r.cursorFresh&&i.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${o}`))}#d(y){if(this.#o.size){for(const u of y.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const r of u){const t=y.createElement("button");t.className=`${H}__peer`,t.type="button",t.style.setProperty("--lat-peer",r.colour),t.toggleAttribute("data-idle",!!r.idle),t.toggleAttribute("data-hidden",!!r.hidden);let n="presence.peer";r.hidden?n="presence.peerHidden":r.idle&&(n="presence.peerIdle"),t.setAttribute("aria-label",this.#f(n,{name:r.name}));const i=y.createElement("span");i.className=`${H}__dot`,i.setAttribute("aria-hidden","true"),i.textContent=r.initials||(r.name||"?").slice(0,1).toUpperCase(),t.appendChild(i);const s=y.createElement("span");s.className=`${H}__name`,s.textContent=r.name,t.appendChild(s),t.addEventListener("click",()=>this.#e.presence.jumpTo(r.id)),this.#n.appendChild(t)}const o=u.filter(r=>r.hidden).length;if(o){const r=y.createElement("span");r.className=`${H}__hidden`,r.textContent=this.#f("presence.hidden",{count:o}),this.#n.appendChild(r)}}announceRefusal(y){if(!this.#r)return;const u=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(y,u){const o=this.#e;return(o&&o.messages?o.messages:F).t(y,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#a!==null&&clearTimeout(this.#a),this.#a=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=L}),ve("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/editors/common.js").cssEscape,B=V("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",L=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(r,t){if(!Number.isFinite(r))return"";const n=Math.max(0,Math.round((t-r)/1e3));if(n<60)return"just now";const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function y(r,t,n,i){t.textContent="";const s=String(n??"");if(!i){t.textContent=s;return}const c=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let d=0,f=c.exec(s);for(;f;){f.index>d&&t.appendChild(r.createTextNode(s.slice(d,f.index)));const h=f[0];if(h.startsWith("*")){const g=r.createElement("em");g.textContent=h.slice(1,-1),t.appendChild(g)}else if(h.startsWith("`")){const g=r.createElement("code");g.textContent=h.slice(1,-1),t.appendChild(g)}else{const g=h.indexOf("]("),w=h.slice(1,g),p=h.slice(g+2,-1);if(L.test(p)){const m=r.createElement("a");m.href=p,m.textContent=w,m.rel="noopener noreferrer",m.target="_blank",t.appendChild(m)}else t.appendChild(r.createTextNode(w))}d=f.index+h.length,f=c.exec(s)}d<s.length&&t.appendChild(r.createTextNode(s.slice(d)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#s.push(this.#e.on("comment:threadOpened",t=>this.#l(t))),this.#s.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#s.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#s.push(this.#e.on("stream:evicted",()=>this.#c()))}#l(t){const n=this.#t.viewport?.root?.ownerDocument;n&&(this.#a=n.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(n),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&N(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#a;this.#a=null,t&&N(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:n}=B(t);this.#e.rows.byKey(n)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const i=this.#r.ownerDocument.createElement("p");i.className=`${H}__note`,i.setAttribute("role","status"),i.textContent=t,this.#r.appendChild(i)}#h(t,n){const i=this.#t.viewport?.root;if(!i||!i.querySelector)return null;const s=i.querySelector(`[data-key="${_(t)}"]`);return s?s.querySelector(`[data-col="${n}"]`):null}#f(t,n){const i=this.#e;return(i&&i.messages?i.messages:F).t(t,n)}#m(t){const n=t.createElement("div");n.className=H,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",this.#f("comments.panel"));const i=t.createElement("header");i.className=`${H}__head`;const s=t.createElement("div");s.className=`${H}__title`,i.appendChild(s);const c=t.createElement("button");c.className=`${H}__resolve`,c.type="button",i.appendChild(c);const d=t.createElement("button");d.className=`${H}__close`,d.type="button",d.setAttribute("aria-label",this.#f("comments.close")),d.textContent="×",i.appendChild(d);const f=t.createElement("div");f.className=`${H}__list`,f.setAttribute("role","log"),f.setAttribute("aria-live","polite");const h=t.createElement("form");h.className=`${H}__composer`;const g=t.createElement("textarea");g.className=`${H}__input`,g.rows=2,g.setAttribute("aria-label",this.#f("comments.write"));const w=t.createElement("button");w.className=`${H}__send`,w.type="submit",w.textContent=this.#f("comments.post"),h.appendChild(g),h.appendChild(w),n.appendChild(i),n.appendChild(f),n.appendChild(h),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(n),this.#n=n,this.#r=f,this.#o=g,this.#p=s,this.#g=c;const p=l=>{l.preventDefault();const a=String(g.value||"").trim();a&&(g.value="",this.#e.comments.add(a))},m=()=>this.#e.comments.close(),b=()=>{this.#v()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=l=>{if(l.stopPropagation(),l.key==="Escape"){l.preventDefault(),this.#e.comments.close();return}if(l.key!=="Tab")return;const a=[...n.querySelectorAll(k)].filter(M=>M.offsetParent!==null||M===g);if(!a.length)return;const O=a[0],T=a[a.length-1],A=n.ownerDocument.activeElement;l.shiftKey&&A===O?(l.preventDefault(),T.focus()):!l.shiftKey&&A===T&&(l.preventDefault(),O.focus())};h.addEventListener("submit",p),d.addEventListener("click",m),c.addEventListener("click",b),n.addEventListener("keydown",v),this.#s.push(()=>{h.removeEventListener("submit",p),d.removeEventListener("click",m),c.removeEventListener("click",b),n.removeEventListener("keydown",v)})}#p=null;#g=null;#v(){return(this.#e.comments.thread||[]).filter(n=>!n.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const n=this.#n.ownerDocument,i=this.#e.get("comments")||{},s=Date.now(),c=t.openKey,{rowId:d,field:f}=B(c),h=this.#e.columns.get(f),g=this.#e.rows.byKey(d),w=N(i.rowLabel)&&g?i.rowLabel(g):d;if(this.#p.textContent=this.#f("comments.cellTitle",{column:h&&(h.title??h.id)||f,row:w}),this.#g.textContent=this.#v()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const p=t.thread||[];if(!p.length){this.#d(this.#f("comments.empty"));return}const m=g&&h?h.getValue(g.data,g):void 0;for(const b of p)this.#r.appendChild(this.#y(n,b,s,m,i))}#y(t,n,i,s,c){const d=t.createElement("article");d.className=`${H}__item`,n.pending&&d.setAttribute("data-pending","true"),n.resolved&&d.setAttribute("data-resolved","true");const f=t.createElement("div");f.className=`${H}__meta`;const h=t.createElement("span");h.className=`${H}__author`,h.textContent=n.author&&(n.author.name||n.author.initials)||this.#f("comments.unknownAuthor"),f.appendChild(h);const g=t.createElement("time");g.className=`${H}__time`;const w=S(n.at,i);g.textContent=n.edited?this.#f("comments.edited",{time:w}):w,f.appendChild(g),d.appendChild(f);const p=t.createElement("div");if(p.className=`${H}__body`,y(t,p,n.body,!!c.markdown),d.appendChild(p),n.value!==void 0&&!Object.is(n.value,s)){const v=t.createElement("p");v.className=`${H}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(n.value),now:String(s)}),d.appendChild(v)}const m=n.can||{},b=v=>m[v]!==!1;if(b("edit")||b("delete")){const v=t.createElement("div");if(v.className=`${H}__actions`,b("delete")){const l=t.createElement("button");l.type="button",l.className=`${H}__action`,l.textContent=this.#f("comments.delete"),l.addEventListener("click",()=>this.#e.comments.remove(n.id)),v.appendChild(l)}d.appendChild(v)}return d}#w(){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 n=this.#e.comments.openKey,{rowId:i,field:s}=B(n),c=this.#h(i,s)||this.#i,d=this.#t.viewport?.root;if(!c||!d||!N(c.getBoundingClientRect))return;const f=c.getBoundingClientRect(),h=d.getBoundingClientRect(),g=this.#n.getBoundingClientRect();let w=f.bottom-h.top+4;w+g.height>h.height&&f.top-h.top>g.height&&(w=f.top-h.top-g.height-4);let p=f.left-h.left;p+g.width>h.width&&(p=Math.max(0,h.width-g.width-4)),this.#n.style.top=`${Math.max(0,w)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const m=f.bottom<h.top||f.top>h.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const t of this.#s)t();this.#s=[],this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const o=u}),ve("packages/dom/src/watermark.js",function(e,V){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,U=W.on,B="lat-watermark",H="https://www.latticegrid.dev",L=["br","bl","tl","tr"],k=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#a=0;#s=null;constructor(o){this.#e=o.grid,this.#t=o.document,this.#n=o.element,this.#i=o.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),N(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const o=this.#e.licence&&this.#e.licence.ready;o&&N(o.then)&&o.then(()=>this.refresh(),()=>this.refresh())}refresh(){const o=this.#d();o&&!this.#r?(this.#h(),this.#u()):!o&&this.#r&&(this.#f(),this.#c())}#l(){const o=this.#i;if(!o||!N(o.matchMedia))return!1;try{return!!o.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),N(this.#i.setTimeout)&&(this.#l()||(this.#s=this.#i.setTimeout(()=>{if(this.#s=null,!this.#d()){this.#f();return}this.#a=(this.#a+1)%L.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#s!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#s),this.#s=null}#d(){const o=this.#e.licence;return!!(o&&N(o.watermark)&&o.watermark())}#h(){const o=_(this.#t,"a",{class:`${B}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}});this.#r=_(this.#t,"div",{class:`${B} ${B}--${L[this.#a]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o]}),this.#o.push(U(this.#r,"pointerdown",r=>{N(r.stopPropagation)&&r.stopPropagation()})),this.#n&&N(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const o of this.#o)o();this.#o=[],this.#f()}}const y=S}),ve("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isFunction,F=V("packages/dom/src/editors/common.js"),W=F.el,_=F.on,U="lat-maximised",B={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"},H="lat-maximised-host",L="lat-maximise-placeholder";class k{#e;#t;#n;#r;#o;#i=null;#a=null;#s=new Set;#l=null;#u=null;constructor(u){this.#e=u.element,this.#t=u.document,this.#n=z(u.onChange)?u.onChange:null,this.#r=z(u.captureScroll)?u.captureScroll:null,this.#o=z(u.restoreScroll)?u.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const u=this.#e.parentNode;if(!u||!this.#t.body)return N("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:L}),this.#i.style.visibility="hidden";const o=this.#e.offsetWidth,r=this.#e.offsetHeight;o&&(this.#i.style.width=`${o}px`),r&&(this.#i.style.height=`${r}px`);const t=this.#r?this.#r():null;u.insertBefore(this.#i,this.#e),this.#c(()=>this.#t.body.appendChild(this.#e)),this.#l={};for(const[n,i]of Object.entries(B))this.#l[n]=this.#e.style[n]||"",this.#e.style[n]=i;return this.#u=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(H),t&&this.#o&&this.#o(t),this.#a=_(this.#t,"keydown",n=>this.#d(n)),this.#h(),!0}exit(){if(!this.active())return!1;const u=this.#r?this.#r():null,o=this.#i,r=o.parentNode;if(r&&z(r.insertBefore)&&this.#c(()=>r.insertBefore(this.#e,o)),z(o.remove)&&o.remove(),this.#i=null,this.#l){for(const[t,n]of Object.entries(this.#l))this.#e.style[t]=n;this.#l=null}return this.#u!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#u),this.#u=null,this.#e.classList.remove(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(H),u&&this.#o&&this.#o(u),this.#a&&this.#a(),this.#a=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#c(u){const o=this.#t.activeElement,r=o&&o!==this.#t.body&&z(this.#e.contains)&&this.#e.contains(o)?o:null;u(),r&&z(r.focus)&&r.focus()}#d(u){!u||u.key!=="Escape"||u.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const u of this.#s)u(this.active())}watch(u){return z(u)?(this.#s.add(u),()=>this.#s.delete(u)):()=>{}}destroy(){this.exit()}}const S=k}),ve("packages/dom/src/promptbar.js",function(e,V){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return n}});const Z=V("packages/dom/src/editors/common.js"),N=Z.documentFor,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/ai/schema.js"),k=L.describeGrid,S=L.promptText,y=V("packages/core/src/ai/intent.js"),u=y.applyPlan,o=y.buildPrompt,r=y.planIntent,t="lat-prompt";class n{#e;#t=null;#n=null;#r={};#o;#i={};#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#v="idle";#b=0;#y=!1;#w=[];t(d,f){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(d,f)}init(d={}){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||U,this.#e=N(d),this.#t=d.grid||null,this.#n=H(d.ask)?d.ask:null,this.#r=d.schemaOptions||{},this.#o=d.context,this.#i={onPlan:H(d.onPlan)?d.onPlan:null,onApply:H(d.onApply)?d.onApply:null,onError:H(d.onError)?d.onError:null},this.#a=z(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(d)}element(){return this.#a}refresh(){this.#y||!this.#a||this.#v!=="busy"&&this.#C()}destroy(){this.#y=!0,this.#b++;for(const d of this.#w)d();this.#w.length=0,this.#g=null,this.#a=null,this.#s=null,this.#l=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(d){if(this.#y||this.#v==="busy")return null;const f=String(d??(this.#s&&this.#s.value)??"").trim();if(!f)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const h=++this.#b;this.#j("busy"),this.#E("Thinking…");let g;try{const w=k(this.#t,this.#r),p=S(w);if(g=await this.#n({prompt:f,schema:w,schemaText:p,message:o(f,p),context:this.#o}),this.#y||h!==this.#b)return null;const m=r(g,w);return this.#A(m),m}catch(w){return this.#y||h!==this.#b||(this.#i.onError&&this.#i.onError(w),this.#T(w instanceof Error?w.message:String(w))),null}}apply(){const d=this.#g;if(this.#y||!d||!d.ok)return null;const f=this.#t?.ai,h=H(f?.apply)?f.apply(d):u(d,this.#t);return this.#i.onApply&&this.#i.onApply(h,d),this.#C(),this.#s&&(this.#s.value=""),h.failed.length?this.#T(`Applied ${h.applied.length}; ${h.failed.map(g=>`${g.type} failed: ${g.reason}`).join("; ")}`):this.#E(`Applied: ${d.describe()}`),h}discard(){this.#y||(this.#C(),this.#E("Discarded."))}#S(d){const f=this.#e,h=z(f,"div",{class:`${t}__row`});this.#s=z(f,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:d.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":d.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push(F(this.#s,"keydown",w=>{const p=w&&w.key;p==="Enter"?(H(w.preventDefault)&&w.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(H(w.preventDefault)&&w.preventDefault(),this.discard())})),h.appendChild(this.#s),this.#l=z(f,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(F(this.#l,"click",()=>{this.ask()})),h.appendChild(this.#l),this.#a.appendChild(h),this.#u=z(f,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=z(f,"p",{class:`${t}__summary`}),this.#d=z(f,"ul",{class:`${t}__notes`});const g=z(f,"div",{class:`${t}__buttons`});this.#h=z(f,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=z(f,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(F(this.#h,"click",()=>{this.apply()})),this.#w.push(F(this.#f,"click",()=>{this.discard()})),g.appendChild(this.#h),g.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(g),this.#a.appendChild(this.#u),this.#m=z(f,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=z(f,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#a.appendChild(this.#m),this.#a.appendChild(this.#p)}#j(d){if(this.#v=d,!this.#a)return;this.#a.setAttribute("data-state",d);const f=d==="busy";i(this.#s,f),i(this.#l,f),this.#l&&(this.#l.textContent=this.t(f?"prompt.asking":"prompt.ask")),s(this.#u,d!=="preview"),s(this.#p,d!=="error")}#A(d){const f=d;if(this.#i.onPlan&&this.#i.onPlan(d),!f.ok){this.#g=null;const h=f.rejected.length?f.rejected.map(g=>g.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${h}`);return}this.#g=d,this.#E(""),this.#c&&(this.#c.textContent=f.describe()),this.#O(f.rejected),this.#j("preview")}#O(d){const f=this.#d;if(f){W(f),s(f,!d.length);for(const h of d.slice(0,6))f.appendChild(z(this.#e,"li",{class:`${t}__note`,text:h.reason}));d.length>6&&f.appendChild(z(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:d.length-6})}))}}#C(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#E(d){this.#m&&(this.#m.textContent=d)}#T(d){this.#g=null,this.#E(""),this.#p&&(this.#p.textContent=d),this.#j("error")}}function i(c,d){c&&(c.disabled=d,d?c.setAttribute("disabled",""):c.removeAttribute("disabled"))}function s(c,d){c&&(c.hidden=d,d?c.setAttribute("hidden",""):c.removeAttribute("hidden"))}}),ve("packages/dom/src/stat.js",function(e,V){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return d}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.isObject,F=Z.warnOnce,_=V("packages/core/src/source/derive.js").reduceValues,B=V("packages/core/src/source/memory.js").isPipelineSettle,L=V("packages/core/src/i18n/index.js").defaultMessages,S=V("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",o=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),r=Object.freeze({direction:"flat",change:null,percent:null});function t(p,m){if(!Number.isFinite(p)||!Number.isFinite(m))return r;const b=p-m,v=b>0?"up":b<0?"down":"flat",l=m===0?null:b/Math.abs(m)*100;return{direction:v,change:b,percent:l}}function n(p,m){return p==="flat"||m==="neither"?"flat":p===m?"good":"bad"}function i(p,m,b=null){if(N(m)){const A=m(p,b);return A==="good"||A==="warn"||A==="bad"?A:null}if(!z(m))return null;const v=typeof p=="number"&&Number.isFinite(p)?p:null;if(v===null)return null;const l=Number.isFinite(Number(m.good))?Number(m.good):null,a=Number.isFinite(Number(m.warn))?Number(m.warn):null,O=String(m.direction||"up")==="down",T=A=>O?v<=A:v>=A;return l!==null&&T(l)?"good":a!==null&&T(a)?"warn":l===null&&a===null?null:"bad"}function s(p){return!(N(p.value)||p.value!==void 0&&!z(p.value))}function c(p){return!p||!p.rows||!N(p.rows.totalCount)?!0:p.rows.totalCount()>0}function d(p){const m=z(p)?p:{},b=m.grid||null,v=g(m.container,b);if(!v)return F("stat.container","createStat needs a `container`: an element or a selector."),w();const l=v.ownerDocument||(typeof document>"u"?null:document);if(!l)return F("stat.document","createStat needs a document; it draws DOM."),w();const a=l.createElement("div");a.className=["lattice",y.root,m.class].filter(Boolean).join(" "),a.setAttribute("role","group");const O=l.createElement("div");O.className=y.title;const T=l.createElement("div");T.className=y.value;const A=l.createElement("div");A.className=y.interval;const M=l.createElement("div");M.className=y.delta;const C=l.createElement("div");C.className=y.footer;const P=l.createElement("div");if(P.className=y.note,P.hidden=!0,m.icon!=null&&m.icon!==""){const ne=l.createElement("span");ne.className=y.icon,ne.setAttribute("aria-hidden","true"),S(ne,m.icon,`stat:${m.title||"stat"}`),a.appendChild(ne);const re=l.createElement("div");re.className=y.body,re.appendChild(O),re.appendChild(T),re.appendChild(P),re.appendChild(A),re.appendChild(M),re.appendChild(C),a.appendChild(re)}else a.appendChild(O),a.appendChild(T),a.appendChild(P),a.appendChild(A),a.appendChild(M),a.appendChild(C);v.appendChild(a);let K=null;const I=[];let D=!1;function j(){if(N(m.value))return m.value(b);if(m.value!==void 0&&!z(m.value))return m.value;const ne=z(m.value)?m.value:m,re=ne.of,oe=ne.fn||"sum",ie=ne.show;return b?oe==="count"?$().length:re?ie?q(String(re),String(oe),String(ie)):E()==="filtered"&&b.statistics&&N(b.statistics.reduce)?b.statistics.reduce(String(re),String(oe)):_($().map(te=>h(te,String(re))),String(oe)):null:null}function E(){return String(m.scope||"filtered")}function $(){if(!b||!b.rows)return[];const ne=E();if(ne==="all"){const oe=[];return N(b.rows.forEachAll)&&b.rows.forEachAll(ie=>{ie.group||oe.push(f(ie))}),oe}if(ne==="selected")return(b.selection&&N(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(f);const re=[];return N(b.rows.forEach)&&b.rows.forEach(oe=>{oe.group||re.push(f(oe))}),re}function q(ne,re,oe){if(re!=="min"&&re!=="max")return F(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ie=null,te=null;for(const ce of $()){const ue=Number(h(ce,ne));Number.isFinite(ue)&&(ie===null||(re==="max"?ue>ie:ue<ie))&&(ie=ue,te=ce)}return te===null?null:h(te,oe)}function X(ne){if(N(m.format))return String(m.format(ne,b));if(ne==null)return m.empty??"—";const re=z(m.value)?m.value:m,oe=re.show||re.of;if((re.show?!0:o.has(String(re.fn||"sum")))&&b&&oe&&N(b.columns?.get)){const te=b.columns.get(String(oe));if(te&&N(te.formatValue))return te.formatValue(ne)}return typeof ne=="number"?Number.isInteger(ne)?String(ne):ne.toFixed(m.decimals??2):String(ne)}function Q(ne){return ne?(b&&b.messages||L).t(`stat.tone.${ne}`):""}function J(){if(D)return;const ne=j(),re=s(m)&&!!b&&!c(b),oe=re?null:ne,ie=N(m.baseline)?m.baseline(b):m.baseline;K=oe,O.textContent=m.title??"",O.hidden=!m.title,T.textContent=X(oe),P.hidden=!re,re&&(P.textContent=b.messages.t("stat.noData"));const te=re||ie===void 0||ie===null?r:t(typeof oe=="number"?oe:null,Number(ie)),ce=n(te.direction,m.goodWhen||"up");if(M.hidden=te.change===null,te.change!==null){const he=te.direction==="up"?"↑":te.direction==="down"?"↓":"→",ke=te.percent===null?X(Math.abs(te.change)):`${Math.abs(te.percent).toFixed(1)}%`;M.textContent=`${he} ${ke}`,M.setAttribute("data-tone",ce),M.setAttribute("data-direction",te.direction)}const ue=N(m.interval)?m.interval(oe,b):null,ae=!!ue&&Number.isFinite(ue.lower)&&Number.isFinite(ue.upper);A.hidden=!ae,ae&&(A.textContent=`${X(ue.lower)} – ${X(ue.upper)}`,Number.isFinite(ue.confidence)&&A.setAttribute("title",`${Math.round(ue.confidence*100)}%`));const pe=re?u:m.bands?i(oe,m.bands,b):null;pe?a.setAttribute("data-tone",pe):a.removeAttribute("data-tone"),C.textContent=N(m.footer)?String(m.footer(oe,b)):m.footer??"",C.hidden=!C.textContent,a.setAttribute("aria-label",[m.title,T.textContent,re?P.textContent:"",ae?A.textContent:"",te.change===null?"":M.textContent,te.change===null?"":Q(ce),C.textContent].filter(Boolean).join(", "))}if(b&&N(b.on)&&m.live!==!1)for(const ne of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=oe=>{ne==="model:changed"&&!B(oe)||J()};b.on(ne,re),I.push(()=>N(b.off)&&b.off(ne,re))}return J(),{element:()=>a,value:()=>K,refresh:J,destroy(){D=!0;for(const ne of I)try{ne()}catch{}I.length=0,a.remove()}}}function f(p){return z(p)&&"data"in p?p.data:p}function h(p,m){if(!z(p))return;if(!m.includes("."))return p[m];let b=p;for(const v of m.split(".")){if(!z(b))return;b=b[v]}return b}function g(p,m){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const b=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(p):null}function w(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),ve("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isObject,F=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class _{#e;#t;#n;#r=null;#o=[];constructor({grid:B,document:H,kpis:L}){this.#e=B,this.#t=H,this.#n=Array.isArray(L)?L.filter(N):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${W.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const L of this.#n){const k=F({...L,grid:this.#e,container:H});this.#o.push(k)}}destroy(){for(const B of this.#o)try{B.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),ve("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const N=V("packages/core/src/index.js").createHeadlessGrid,F=V("packages/core/src/defaults.js").applyDefaults,_=V("packages/core/src/export/download.js").downloadBlob,U=V("packages/core/src/internal/util.js"),B=U.fail,H=U.isFunction,L=U.warnOnce,S=V("packages/dom/src/localviews.js").createLocalViewStorage,u=V("packages/dom/src/renderer/index.js").DomRenderer,r=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),n=t.icon,i=t.iconNames,c=V("packages/dom/src/editors/index.js").editors,f=V("packages/dom/src/filters/index.js").filters,h=V("packages/dom/src/ui/index.js"),g=h.StatusBar,w=h.TooltipManager,p=h.Pagination,m=h.GroupByZone,v=V("packages/dom/src/ui/celltooltip.js").CellTooltips,a=V("packages/dom/src/filtermenu.js").FilterMenu,T=V("packages/dom/src/columnmenu.js").ColumnMenu,M=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,K=V("packages/dom/src/alignedgrids.js").AlignedGrids,D=V("packages/dom/src/columntagbar.js").ColumnTagBar,E=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,X=V("packages/dom/src/toolpanelmount.js"),Q=X.ToolPanelDock,J=X.panelHost,re=V("packages/dom/src/celledit.js").CellEditController,ie=V("packages/dom/src/editbar.js").EditBar,ce=V("packages/dom/src/rangeselect.js").RangeController,ae=V("packages/core/src/model/selection.js").resolveSelectionConfig,he=V("packages/dom/src/importer.js").ImportController,Oe=V("packages/dom/src/historybar.js").HistoryBar,_e=V("packages/dom/src/diffpaint.js").DiffPainter,xe=V("packages/dom/src/detailhost.js").DetailHost,qe=V("packages/dom/src/highlightpaint.js").HighlightPainter,Je=V("packages/dom/src/findpaint.js").FindPainter,Ae=V("packages/dom/src/findbar.js").FindBar,Ve=V("packages/dom/src/redactpaint.js").RedactionPainter,lt=V("packages/dom/src/validationpaint.js").ValidationPainter,Pt=V("packages/dom/src/presentation.js").PresentationController,Rt=V("packages/dom/src/capture.js").captureElement,zt=V("packages/dom/src/annotate.js").AnnotationLayer,Qt=V("packages/dom/src/timelinebar.js").TimelineBar,de=V("packages/dom/src/commentpaint.js").CommentPainter,Te=V("packages/dom/src/presencepaint.js").PresencePainter,He=V("packages/dom/src/commentpanel.js").CommentPanel,dt=V("packages/dom/src/watermark.js").Watermark,we=V("packages/dom/src/maximise.js").Maximiser,je=V("packages/dom/src/promptbar.js").PromptBar,Ne=V("packages/dom/src/kpistrip.js").KpiStrip;function Re(Ee,tt,rt){const ht=tt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?Ee(ht):Ee(tt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Fe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Le=2e3;function Ze(Ee,tt,rt){const ht=tt.annotate===!0?Ye(Ee):[];if(tt.actions===!1)return[];if(tt.actions===void 0&&tt.side!=="left")return ht;const Dt=Array.isArray(tt.actions)?tt.actions:Fe,Nt=(vt,Ht)=>Ee.messages.t(vt,Ht),ot={undo:{name:"undo",title:()=>Re(Nt,"undo",Ee.history.peek("undo")),icon:"undo",run:()=>Ee.history.undo(),enabled:()=>Ee.history.canUndo()},redo:{name:"redo",title:()=>Re(Nt,"redo",Ee.history.peek("redo")),icon:"redo",run:()=>Ee.history.redo(),enabled:()=>Ee.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Ee.export.csv({download:!0,fileName:tt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ee.export.excel({download:!0,fileName:tt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Ee.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Ee.export.print()},pause:{name:"pause",title:()=>{if(!Ee.updates.paused)return Nt("toolbar.pause");const vt=Ee.updates.stats().pending;return vt?Nt("toolbar.applyHeld",{count:vt}):Nt("toolbar.resume")},icon:()=>Ee.updates.paused?"play":"pause",run:()=>Ee.updates.paused?Ee.updates.resume():Ee.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Ee.state.reset(),enabled:()=>Ee.state.modified()},maximise:{name:"maximise",title:()=>Nt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete ot.maximise,Dt.map(vt=>vt==="-"?{name:"-",separator:!0}:typeof vt=="string"?ot[vt]:!vt||typeof vt!="object"||!vt.name?null:{...vt,run:H(vt.run)?()=>vt.run({grid:Ee,keys:Ee.selection&&H(Ee.selection.keys)?Ee.selection.keys():[],cells:Ee.selection&&H(Ee.selection.cells)?Ee.selection.cells():[]}):void 0}).filter(Boolean).concat(ht)}function Ye(Ee){const tt=ht=>Ee.messages.t(ht),rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(ht=>({name:ht,title:()=>tt(`toolbar.annotate.${ht}`),icon:rt[ht],run:()=>Ee.annotate?.use(ht),active:()=>Ee.annotate?.tool===ht,annotation:!0}))}const mt=["pen","arrow","rect","highlight"];function pt(Ee){return{rowCount:()=>{if(H(Ee.rows.matchCount))return Ee.rows.matchCount();const tt=Ee.pagination&&H(Ee.pagination.get)?Ee.pagination.get():null;return tt&&Number.isFinite(tt.total)?tt.total:Ee.rows.count()},totalRowCount:()=>H(Ee.rows.totalCount)?Ee.rows.totalCount():Ee.rows.count(),selectedCount:()=>{const tt=Ee.selection&&Ee.selection.keys?Ee.selection.keys():null;return tt?tt.length:0},rangeValues:()=>{const tt=Ee.selection;return!tt||!H(tt.cells)?[]:tt.cells().map(({key:rt,colId:ht})=>Ee.rows.value(rt,ht))},hiddenUnresolved:()=>H(Ee.comments&&Ee.comments.hiddenUnresolved)?Ee.comments.hiddenUnresolved():0,progress:()=>H(Ee.source&&Ee.source.progress)?Ee.source.progress():null,updateStats:()=>Ee.updates?Ee.updates.stats():null}}function yt(Ee,tt){for(const[rt,ht]of Object.entries(c||{}))Ee.register("editor",rt,ht);for(const[rt,ht]of Object.entries(f||{}))Ee.register("filter",rt,ht);for(const[rt,ht]of Object.entries(tt.components||{}))Ee.register("component",rt,ht);for(const[rt,ht]of Object.entries(tt.pipes||{}))Ee.register("pipe",rt,ht);for(const[rt,ht]of Object.entries(tt.totalFns||{}))Ee.register("totalFn",rt,ht)}function ft(Ee,tt,rt,ht,Dt,Nt){const ot=[],vt=tt.viewport;let Ht=null;if(rt.maximise!==!1&&(Ht=new we({element:Nt,document:ht,onChange:()=>tt.invalidate("all"),captureScroll:()=>tt.scrollState(),restoreScroll:Xe=>tt.restoreScroll(Xe)}),Ee.maximise=Ht,ot.push(()=>Ht.destroy())),rt.statusBar){const Xe=typeof rt.statusBar=="object"?rt.statusBar:{},st=new g;st.init({document:ht,host:pt(Ee),panels:Xe.panels,registry:Xe.registry,locale:Ee.get("locale"),messages:Ee.messages}),vt.statusBar.appendChild(st.element());const Ot=()=>{const tn=vt.statusBar.offsetHeight||vt.statusBar.getBoundingClientRect?.().height||0;vt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Ft=()=>{st.refresh(),Ot()},Ut=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>Ee.on(tn,Ft));Ft(),Ot(),ot.push(()=>{for(const tn of Ut)tn();vt.root.style.removeProperty("--lattice-status-height"),st.destroy?.()})}const Gt=ae(rt.selection);if(Gt.ranges){const Xe=new ce({grid:Ee,renderer:tt,document:ht});Xe.mount(),Ee.ranges=Xe,ot.push(()=>Xe.destroy())}if(rt.import){const Xe=new he({grid:Ee,renderer:tt,document:ht,settings:typeof rt.import=="object"?rt.import:{}});Ee.importer=Xe,ot.push(()=>Xe.destroy())}if(rt.historyBar){const Xe=typeof rt.historyBar=="object"?rt.historyBar.element:null,st=new Oe;st.init({document:ht,host:{undo:()=>Ee.history.undo(),redo:()=>Ee.history.redo(),canUndo:()=>Ee.history.canUndo(),canRedo:()=>Ee.history.canRedo(),peek:Ft=>Ee.history.peek(Ft),list:()=>Ee.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(Xe||vt.root).appendChild(st.element());const Ot=[Ee.on("history:changed",()=>st.refresh())];Ee.historyBar=st,ot.push(()=>{for(const Ft of Ot)Ft();st.destroy()})}if(rt.diff){const Xe=new _e({grid:Ee,renderer:tt});Xe.mount(),Ee.diffPainter=Xe,ot.push(()=>Xe.destroy())}if(rt.ai&&H(rt.ai.ask)){const Xe=new je;Xe.init({document:ht,grid:Ee,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const st=rt.ai.element||vt.root;st===vt.root?st.insertBefore(Xe.element(),st.firstChild):st.appendChild(Xe.element()),Ee.promptBar=Xe,ot.push(()=>Xe.destroy())}if(rt.groupPanel){const Xe=typeof rt.groupPanel=="object"?rt.groupPanel:{},st=new m;st.init({document:ht,grid:Ee,host:J(Ee,ht,(Ot,Ft)=>tt.announce?.(Ot,Ft)),props:{header:vt.header,hint:Xe.hint}}),vt.root.insertBefore(st.element(),vt.header),Ee.groupPanel=st;for(const Ot of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ee.on)&&ot.push(Ee.on(Ot,()=>st.refresh()));ot.push(()=>st.destroy())}if(rt.kpis){const Xe=new Ne({grid:Ee,document:ht,kpis:rt.kpis});Xe.active&&(Xe.mount(),vt.root.insertBefore(Xe.element(),vt.header),Ee.kpiStrip=Xe,ot.push(()=>Xe.destroy()))}if(rt.toolPanel){const Xe=typeof rt.toolPanel=="object"?rt.toolPanel:{},st=new Q({grid:Ee,document:ht,root:vt.root,panels:Xe.panels,openPanel:Xe.openPanel,side:Xe.side,icons:Xe.icons,actions:Ze(Ee,Xe,Ht),announce:(Ot,Ft)=>tt.announce?.(Ot,Ft)});st.mount(),Ee.toolPanel=st,ot.push(()=>st.destroy()),Xe.annotate===void 0&&(ot.push(Ee.on("presentation:started",()=>{for(const Ot of Ye(Ee))st.addAction(Ot)})),ot.push(Ee.on("presentation:ended",()=>{for(const Ot of mt)st.removeAction(Ot)})))}if(rt.pagination){const Xe=typeof rt.pagination=="object"?rt.pagination:{},st=new p;st.init({document:ht,pageSize:Xe.pageSize,pageSizes:Xe.pageSizes,page:Xe.page,total:Xe.total,locale:Ee.get("locale"),messages:Ee.messages,onChange:({page:Ut,pageSize:tn})=>Ee.pagination.set({page:Ut,pageSize:tn})});const Ot=()=>{const Ut=Ee.pagination.get();st.total=Ut.total,st.counting=Ut.counting===!0,st.page=Ut.page,st.paint()};Ee.pagination.set({pageSize:st.pageSize}),Ot();const Ft=["rows:changed","filter:changed","model:changed"].map(Ut=>Ee.on(Ut,Ot));vt.statusBar.appendChild(st.element()),ot.push(()=>{for(const Ut of Ft)Ut();st.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const Xe=new ie({grid:Ee,document:ht,root:vt.root});Xe.mount(),Ee.editBar=Xe,ot.push(()=>Xe.destroy())}else{const Xe=new re({grid:Ee,document:ht,renderer:tt,registry:Dt,cellLayer:tt.cellLayer});Xe.mount(),ot.push(()=>Xe.destroy())}const sn=new a({grid:Ee,document:ht,layer:vt.overlays,registry:Dt});sn.mount(),ot.push(()=>sn.destroy());const an=new T({grid:Ee,document:ht,host:vt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:H(rt.contextMenu)?rt.contextMenu:void 0,headerItems:H(rt.columnMenu)?rt.columnMenu:void 0});if(an.mount(),ot.push(()=>an.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const Xe=new K;Xe.add(Ee);for(const st of rt.alignedGrids)st&&st!==Ee&&Xe.add(st);ot.push(()=>Xe.destroy())}const xt=new q({grid:Ee,renderer:tt,document:ht,registry:Dt});xt.active&&(xt.mount(),ot.push(()=>xt.destroy())),Object.defineProperty(Ee,"form",{configurable:!0,value:Object.freeze({open(Xe){return xt.active?xt.openRow(Xe):!1},close(){xt.active&&xt.close()},save(){return xt.active?xt.save():!1},isOpen(){return xt.active?xt.open:!1}})}),ot.push(()=>{delete Ee.form}),Object.defineProperty(Ee,"icons",{configurable:!0,value:Object.freeze({get(Xe){const st=n(Xe);return st?{viewBox:st.viewBox,paths:st.paths.slice(),paint:st.paint==="stroke"?"stroke":"fill"}:null},names(){return i()}})}),ot.push(()=>{delete Ee.icons});const ln=new D({grid:Ee,renderer:tt,document:ht});ln.active&&(ln.mount(),ot.push(()=>ln.destroy()));const un=new E({grid:Ee,renderer:tt,document:ht});un.active&&(un.mount(),ot.push(()=>un.destroy()));const nn=new P({grid:Ee,renderer:tt,document:ht});if(nn.active){nn.mount(),nn.paint();const Xe=Ee.on("render:done",()=>nn.paint());ot.push(()=>{Xe(),nn.destroy()})}if(rt.shortcuts!==!1){const Xe=new M({grid:Ee,renderer:tt});Xe.mount(),ot.push(()=>Xe.destroy())}const bt=new qe({grid:Ee,renderer:tt,window:ht.defaultView||void 0});bt.mount(),ot.push(()=>bt.destroy());const Ct=new Je({grid:Ee,renderer:tt,window:ht.defaultView||void 0});if(Ct.mount(),ot.push(()=>Ct.destroy()),rt.find!==!1){const Xe=new Ae({grid:Ee,renderer:tt,document:ht,settings:rt.find});Xe.mount(),ot.push(()=>Xe.destroy())}const Tt=new Ve({grid:Ee,renderer:tt});Tt.mount(),ot.push(()=>Tt.destroy());const Bt=new lt({grid:Ee,renderer:tt});Bt.mount(),ot.push(()=>Bt.destroy());const Yt=new Pt({grid:Ee,renderer:tt,maximiser:Ht});Yt.mount(),ot.push(()=>Yt.destroy());const Kt=new Qt({grid:Ee,renderer:tt});Kt.mount(),ot.push(()=>Kt.destroy()),rt.environment||Ee.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 qt=null;for(const[Xe,st]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ot.push(Ee.on(Xe,()=>{qt=st}));ot.push(Ee.on("render:done",Xe=>{Ee.diagnostics.render(qt||Xe.cause,Xe.phases),qt=null}));const Jt=new Te({grid:Ee,renderer:tt});if(Jt.mount(),ot.push(()=>Jt.destroy()),ot.push(Ee.on("presence:lockRefused",Xe=>Jt.announceRefusal(Xe.peer))),Ee.presence&&Ee.presence.enabled){for(const Ot of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ot.push(Ee.on(Ot,()=>Ee.presence.publish()));let Xe="";ot.push(Ee.on("render:done",()=>{const Ot=tt.focusState&&tt.focusState(),Ft=Ot?`${Ot.rowKey}${Ot.colId}`:"";Ft!==Xe&&(Xe=Ft,Ee.presence.publish())}));const st=Nt.ownerDocument;if(st&&H(st.addEventListener)){const Ot=()=>Ee.presence.setPaused(st.visibilityState==="hidden");st.addEventListener("visibilitychange",Ot),Ot(),ot.push(()=>st.removeEventListener("visibilitychange",Ot))}}const Zt=new de({grid:Ee,renderer:tt});Zt.mount(),ot.push(()=>Zt.destroy());const cn=new He({grid:Ee,renderer:tt});cn.mount(),ot.push(()=>cn.destroy()),ot.push(Ee.on("facet:computed",()=>tt.refreshHeader?.())),Gt&&Gt.headerCheckbox===!0&&ot.push(Ee.on("selection:changed",()=>tt.refreshHeader?.())),ot.push(Ee.on("facet:expanded",()=>tt.invalidate("columns"))),ot.push(Ee.on("model:changed",()=>tt.invalidate("rows")));const Vt=(Xe,st)=>tt.announce?.(Xe,st),dn=Ee.messages,It=(Xe,st)=>dn.t(Xe,st),mn=Xe=>It("count.rows",{count:Xe});ot.push(Ee.on("sort:changed",()=>{const Xe=Ee.sort.get();if(!Xe.length){Vt(It("a11y.sort.cleared"));return}const st=Xe.map(Ot=>{const Ft=Ee.columns.get(Ot.col);return It("a11y.sort.column",{column:Ft&&Ft.title||Ot.col,direction:It(Ot.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Vt(It("a11y.sort.by",{columns:dn.list(st)}))})),ot.push(Ee.on("filter:changed",()=>{const Xe=Ee.rows.matchCount?Ee.rows.matchCount():Ee.rows.count(),st=Ee.rows.totalCount?Ee.rows.totalCount():Xe;Vt(Xe===st?It("a11y.filter.cleared",{rows:mn(st)}):It("a11y.filter.applied",{shown:mn(Xe),total:mn(st)}))})),ot.push(Ee.on("selection:changed",()=>{const Xe=Ee.selection.keys().length;Vt(Xe===0?It("a11y.selection.cleared"):It("a11y.selection.count",{count:Xe}))})),ot.push(Ee.on("group:toggled",Xe=>{const st=Ee.rows.byKey?Ee.rows.byKey(Xe.key):null,Ot=(st&&(st.groupLabel??st.groupValue))??Xe.key;Vt(It(Xe.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Ot,rows:mn(Ee.rows.count())}))})),ot.push(Ee.on("column:grouped",Xe=>{const st=Array.isArray(Xe.columns)?Xe.columns:[];if(!st.length){Vt(It("a11y.group.cleared"));return}const Ot=st.map(Ft=>{const Ut=Ee.columns.get(Ft);return Ut&&Ut.title||Ft});Vt(It("a11y.group.by",{columns:dn.list(Ot)}))})),ot.push(Ee.on("page:changed",Xe=>{const st=Number(Xe.size)||0,Ot=Number(Xe.total)||0,Ft=st>0?Math.max(1,Math.ceil(Ot/st)):1;Vt(It("a11y.page.position",{page:(Number(Xe.page)||0)+1,pages:Ft}))}));let en={added:0,removed:0},Wt=null;const Tn=()=>{Wt=null;const Xe=[];en.added&&Xe.push(It("count.rowsAdded",{count:en.added})),en.removed&&Xe.push(It("count.rowsRemoved",{count:en.removed})),en={added:0,removed:0},Xe.length&&Vt(dn.list(Xe))};ot.push(Ee.on("rows:changed",Xe=>{if(!Xe||typeof Xe.added!="number")return;const st=Number(Xe.added)||0,Ot=Number(Xe.removed)||0;!st&&!Ot||(en.added+=st,en.removed+=Ot,Wt||(Wt=setTimeout(Tn,Le)))})),ot.push(()=>{Wt&&clearTimeout(Wt)}),ot.push(Ee.on("rows:paused",()=>{Wt&&(clearTimeout(Wt),Wt=null),en={added:0,removed:0},Vt(It("a11y.updates.paused"),{repeat:!0})})),ot.push(Ee.on("rows:resumed",()=>Vt(It("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const kn=()=>{hn=null;const{count:Xe,first:st}=fn;if(fn={count:0,first:null},!Xe||!st)return;const Ot=Ee.columns.get(st.colId),Ft=Ot&&Ot.title||st.colId,Ut=st.reason?It("a11y.edit.reason",{reason:st.reason}):"";if(Xe===1){const tn=st.restored===void 0||st.restored===null||st.restored===""?It("value.empty"):String(st.restored);Vt(It("a11y.edit.refusedOne",{column:Ft,value:tn,reason:Ut}),{repeat:!0});return}Vt(It("a11y.edit.refusedMany",{count:Xe,reason:Ut}),{repeat:!0})};ot.push(Ee.on("cell:reverted",Xe=>{!Xe||!Xe.applied||(fn.count+=1,fn.first||(fn.first=Xe),hn||(hn=setTimeout(kn,150)))})),ot.push(()=>{hn&&clearTimeout(hn)}),ot.push(Ee.on("history:applied",Xe=>{const st=!!(Xe&&Xe.direction==="redo"),Ot=Xe&&Xe.step&&Xe.step.label;Vt(Ot?It(st?"a11y.history.redo":"a11y.history.undo",{label:Ot}):It(st?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const pn=new zt({grid:Ee,renderer:tt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});pn.mount(),ot.push(()=>pn.destroy()),Ee.annotate=pn,Ee.capture=async(Xe={})=>{const{blob:st,width:Ot,height:Ft}=await Rt(tt.viewport.root,Xe);return(Xe.download===!0||Xe.download!==!1&&Xe.fileName)&&_(st,Xe.fileName||`${Ee.get("exportName")||"grid"}.png`),Ee.emit("presentation:captured",{width:Ot,height:Ft,bytes:st.size,mimeType:st.type,fileName:Xe.fileName||null},"api"),st};const Sn=new dt({grid:Ee,document:ht,element:vt.overlays,window:ht.defaultView||void 0});Sn.mount(),ot.push(()=>Sn.destroy());const Mn=new w({grid:Ee,document:ht,element:vt.overlays});Mn.mount?.(),ot.push(()=>Mn.destroy?.());const On=new v({grid:Ee,host:Ee.rendererHost(),viewport:vt,document:ht});return On.mount(),ot.push(()=>On.destroy()),ot}function kt(Ee){const tt=[],rt=ht=>{if(ht&&(ht.__lattice&&tt.push(ht),ht.children))for(const Dt of ht.children)rt(Dt)};return rt(Ee),tt}function St(Ee,tt={}){(!Ee||typeof Ee!="object"||!("appendChild"in Ee))&&B("createGrid needs a host element as its first argument."),tt=F(tt);const rt=Ee.ownerDocument||(typeof document<"u"?document:null);rt||B("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ht=rt.documentElement&&rt.documentElement.lang,Dt=!tt.licence&&H(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...tt};if(!tt.locale&&ht&&(Nt.locale=ht),Dt&&(Nt.licence=Dt),tt.views&&tt.views.local)if(tt.views.storage)L("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const xt=tt.views.local===!0?{}:tt.views.local;Nt.views={...tt.views,storage:S(xt)}}const ot=N(Nt),vt=ot.rendererHost();vt.document=rt,yt(vt.registry,tt),vt.cellLayer=r(vt),vt.detailHost=new xe({grid:ot,document:Ee.ownerDocument||globalThis.document,createGrid:(xt,ln)=>St(xt,ln)});const Ht=new u(Ee,vt),Gt=ot.on("detail:toggled",()=>{vt.detailHost.syncTarget(),vt.detailHost.prune()}),on=ot.on("config:changed",xt=>{xt&&xt.key==="detail"&&vt.detailHost.reconfigure()});ot.on("destroy",()=>{Gt(),on(),vt.detailHost.destroy()}),vt.detailHost.syncTarget(),ot.attachRenderer(Ht),Ht.mount();const sn=ft(ot,Ht,tt,rt,vt.registry,Ee),an=ot.destroy.bind(ot);return ot.destroy=()=>{for(const xt of sn)try{xt()}catch{}Ee.__lattice===ot&&(Ee.__lattice=null),an()},Ee.__lattice=ot,ot}}),ve("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/createGrid.js").createGrid;function W(k,S){for(const y of k.children)if(y.tagName===S.toUpperCase())return y;return null}function _(k,S){const y=[];for(const u of k.children)u.tagName===S.toUpperCase()&&y.push(u);return y}function U(k,S){const y=N(k.getAttribute)?k.getAttribute("data-field"):null;return y||String(k.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${S}`}function B(k){const S=k.trim();if(S==="")return null;if(S==="true"||S==="false")return S==="true";const y=Number(S);return Number.isFinite(y)&&S!==""?y:S}function H(k){const S=W(k,"thead"),y=W(S||k,"tr"),o=(y?_(y,"th").length?_(y,"th"):_(y,"td"):[]).map((i,s)=>{const c=U(i,s);return{id:c,field:c,title:String(i.textContent||"").trim()||c}}),r=W(k,"tbody"),n=(r?_(r,"tr"):_(k,"tr").filter(i=>i!==y)).map((i,s)=>{const c=_(i,"td"),f={__row:(N(i.getAttribute)?i.getAttribute("data-id"):null)||`row${s}`};return o.forEach((h,g)=>{f[h.field]=c[g]?B(String(c[g].textContent||"")):null}),f});return{columns:o,rows:n}}function L(k,S={}){const{columns:y,rows:u}=H(k),o=k.ownerDocument.createElement("div");return k.parentNode.insertBefore(o,k),k.parentNode.removeChild(k),F(o,{rowKey:"__row",columns:y,rows:u,...S,columns:S.columns!==void 0?S.columns:y,rows:S.rows!==void 0?S.rows:u})}}),ve("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/createGrid.js").createGrid,_=V("packages/dom/src/hydrate.js").hydrateTable;function U(k,S){const y=[];return N(k.hasAttribute)&&k.hasAttribute(S)&&y.push(k),N(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${S}]`)),y}function B(k){const S=k.parentNode;if(!S||!S.children)return null;const y=[...S.children],u=y.indexOf(k),o=[y[u+1],y[u-1]];for(const r of o)if(r&&r.tagName==="SCRIPT"&&N(r.getAttribute)&&r.hasAttribute("data-lattice-config"))return r;return null}function H(k){const S=B(k);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function L(k){const S=k||(typeof document<"u"?document:null);if(!S)return[];const y=[];for(const u of U(S,"data-lattice-grid")){if(u.__lattice)continue;const o=H(u);y.push(u.tagName==="TABLE"?_(u,o):F(u,o))}return y}}),ve("packages/modules/htmx/controller.js",function(e,V){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return F}});const N=V("packages/core/src/internal/util.js").isFunction;function z(W,_){if(!W||!N(_))return 0;let U=0;for(const B of _(W))B.__lattice&&N(B.__lattice.destroy)&&(B.__lattice.destroy(),U+=1);return U}function F(W,_){return!W||!N(_)?[]:_(W)}}),ve("packages/modules/htmx/history.js",function(e,V){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return B}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/core/src/model/state.js"),F=z.serialiseState,W=z.restoreState;function _(H,L){const k=[];return H&&(N(H.hasAttribute)&&H.hasAttribute(L)&&k.push(H),N(H.querySelectorAll)&&k.push(...H.querySelectorAll(`[${L}]`))),k}function U(H,L){if(!H||!N(L))return 0;let k=0;for(const S of L(H))!S.__lattice||!N(S.setAttribute)||(S.setAttribute("data-lattice-state",F(S.__lattice)),k+=1);return k}function B(H,L){if(!H)return 0;const k=_(H,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of k)for(;y.firstChild;)y.removeChild(y.firstChild);k.length&&N(L)&&L(H);let S=0;for(const y of _(H,"data-lattice-state")){const u=N(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!u||!y.__lattice||(W(y.__lattice,u),S+=1)}return S}}),ve("packages/modules/htmx/rowmodel.js",function(e,V){"use strict";Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return L}});const Z=V("packages/dom/src/hydrate.js"),N=Z.coerceCell,z=Z.childTags,F=Z.firstChildTag,W=5e3;function _(k,S={}){const y=k.pagination.get(),u=S.limit??(y.pageSize||100);return{offset:S.offset??(y.page??0)*u,limit:u,sort:JSON.stringify(k.sort.get()),filters:JSON.stringify(k.filters.get())}}function U(k,S){let y;if(k.tagName==="TR")y=[k];else{const u=F(k,"tbody")||k;y=z(u,"tr").length?z(u,"tr"):z(k,"tr")}return y.map((u,o)=>{const r=z(u,"td"),n={__row:(typeof u.getAttribute=="function"?u.getAttribute("data-id"):null)||`row${o}`};return S.forEach((i,s)=>{n[i.field]=r[s]?N(String(r[s].textContent||"")):null}),n})}function B(k){const S=JSON.parse(k);return Array.isArray(S)?{rows:S,total:void 0}:{rows:S.rows||[],total:S.total}}function H(k){k<=W||console.warn(`lattice-grid/htmx: parsed ${k} rows from an HTML fragment, past the documented ${W}-row boundary for that path. Consider a JSON response for this size.`)}function L(k,S){if(/json/i.test(k.contentType||""))return B(k.text);const u=U(k.fragment,S);return H(u.length),{rows:u,total:void 0}}}),ve("packages/modules/htmx/oob.js",function(e,V){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(_,U={}){const B=U.doc||(typeof document<"u"?document:null);if(!B||!N(B.addEventListener))return()=>{};const H=L=>{const k=L.detail,S=k&&k.target,y=S&&N(S.getAttribute)?S.getAttribute("data-lattice-row"):null;if(!y||!k.fragment)return;const u=U.columns||_.columns.visible().map(r=>({field:r.field||r.id})),[o]=F(k.fragment,u);o&&(delete o.__row,_.rows.apply({update:[{...o,[_.get("rowKey")]:y}]})),k.shouldSwap=!1};return B.addEventListener("htmx:oobBeforeSwap",H),()=>B.removeEventListener("htmx:oobBeforeSwap",H)}}),ve("packages/modules/htmx/servermode.js",function(e,V){"use strict";Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/modules/htmx/rowmodel.js"),F=z.queryParams,W=z.ingestResponse,_="lattice:query-changed";function U(k,S){const y=k.createElement("tbody");if(N(k.createRange)){const u=k.createRange();u.selectNodeContents(y),y.appendChild(u.createContextualFragment(S))}return y}function B(k,S,y={}){const u=S.ownerDocument;let o=!1;const r=f=>{f.target!==S||!f.detail||!f.detail.parameters||Object.assign(f.detail.parameters,F(k,y))},t=f=>{f.target===S&&(o=!0)},n=f=>{if(o=!1,f.target!==S)return;const h=f.detail&&f.detail.xhr&&f.detail.xhr.status,g=h?`Could not load rows (server responded ${h}).`:"Could not load rows, the request failed to reach the server.";k.overlay.show("empty",g)},i=f=>{if(f.target!==S||(o=!1,f.detail&&(f.detail.shouldSwap=!1),!f.detail||!f.detail.xhr||f.detail.isError))return;const{xhr:h}=f.detail,g=N(h.getResponseHeader)&&h.getResponseHeader("Content-Type")||"",w=f.detail.serverResponse??h.responseText??"",p=y.columns||k.columns.visible().map(v=>({field:v.field||v.id})),m=/json/i.test(g)?null:U(u,w),{rows:b}=W({contentType:g,text:w,fragment:m},p);k.rows.load(b)},s=()=>{if(o&&N(S.dispatchEvent)){const h=u.defaultView&&u.defaultView.CustomEvent;S.dispatchEvent(h?new h("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const f=globalThis.htmx;f&&N(f.trigger)&&f.trigger(S,_)};u.addEventListener("htmx:configRequest",r),u.addEventListener("htmx:beforeRequest",t),u.addEventListener("htmx:beforeSwap",i),u.addEventListener("htmx:responseError",n),u.addEventListener("htmx:sendError",n);const c=k.on("sort:changed",s),d=k.on("filter:changed",s);return()=>{u.removeEventListener("htmx:configRequest",r),u.removeEventListener("htmx:beforeRequest",t),u.removeEventListener("htmx:beforeSwap",i),u.removeEventListener("htmx:responseError",n),u.removeEventListener("htmx:sendError",n),c(),d()}}const H="lattice:scroll-near-end";function L(k,S,y={}){const u=S.ownerDocument,o=y.threshold??20;let r=!1,t=!1;const n=l=>{l.target!==S||!l.detail||!l.detail.parameters||Object.assign(l.detail.parameters,F(k,{...y,offset:k.rows.count()}))},i=l=>{l.target===S&&(r=!0)},s=l=>{l.target===S&&(r=!1)},c=l=>{if(l.target!==S||(r=!1,l.detail&&(l.detail.shouldSwap=!1),!l.detail||!l.detail.xhr||l.detail.isError))return;const{xhr:a}=l.detail,O=N(a.getResponseHeader)&&a.getResponseHeader("Content-Type")||"",T=l.detail.serverResponse??a.responseText??"",A=y.columns||k.columns.visible().map(P=>({field:P.field||P.id})),M=/json/i.test(O)?null:U(u,T),{rows:C}=W({contentType:O,text:T,fragment:M},A);if(!C.length){t=!0;return}k.rows.apply({add:C})},d=()=>{t=!1},f=()=>{if(r||t)return;const l=globalThis.htmx;l&&N(l.trigger)&&l.trigger(S,H)};let h=!1;const g=()=>{h=!0},w=({last:l})=>{h&&(h=!1,(k.rows.count()===0||l>=k.rows.count()-1-o)&&f())};u.addEventListener("htmx:configRequest",n),u.addEventListener("htmx:beforeRequest",i),u.addEventListener("htmx:beforeSwap",c),u.addEventListener("htmx:responseError",s),u.addEventListener("htmx:sendError",s);const p=k.on("render:done",w),m=k.on("scroll",g),b=k.on("sort:changed",d),v=k.on("filter:changed",d);return()=>{u.removeEventListener("htmx:configRequest",n),u.removeEventListener("htmx:beforeRequest",i),u.removeEventListener("htmx:beforeSwap",c),u.removeEventListener("htmx:responseError",s),u.removeEventListener("htmx:sendError",s),p(),m(),b(),v()}}}),ve("packages/modules/htmx/index.js",function(e,V){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/createGrid.js"),F=z.gridElementsWithin,W=V("packages/dom/src/autoinit.js"),_=W.autoInit,U=V("packages/modules/htmx/controller.js"),B=U.destroyWithin,H=U.initWithin,L=V("packages/modules/htmx/history.js"),k=L.saveStateWithin,S=L.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return z.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return z.gridElementsWithin}});const y=V("packages/dom/src/hydrate.js");Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return y.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return y.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}});const u=V("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return u.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return u.restoreState}});const o=V("packages/core/src/index.js");Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return o.createHeadlessGrid}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return o.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return o.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return o.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return o.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return o.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return o.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return o.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return o.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return o.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return o.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return o.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return o.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return o.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return o.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return o.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return o.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return o.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return o.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return o.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return o.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return o.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return o.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return o.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return o.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return o.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return o.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return o.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return o.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return o.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return o.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return o.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return o.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return o.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return o.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return o.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return o.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return o.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return o.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return o.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return o.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return o.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return o.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return o.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return o.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return o.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return o.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return o.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return o.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return o.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return o.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return o.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return o.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return o.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return o.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return o.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return o.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return o.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return o.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return o.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return o.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return o.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return o.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return o.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return o.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return o.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return o.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return o.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return o.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return o.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return o.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return o.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return o.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return o.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return o.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return o.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return o.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return o.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return o.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return o.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return o.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return o.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return o.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return o.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return o.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return o.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return o.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return o.WINDOW_KINDS}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return o.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return o.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return o.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return o.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return o.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return o.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return o.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return o.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return o.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return o.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return o.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return o.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return o.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return o.createStreamSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return o.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return o.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return o.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return o.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return o.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return o.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return o.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return o.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return o.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return o.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return o.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return o.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return o.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return o.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return o.filtersToSql}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return o.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return o.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return o.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return o.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return o.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return o.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return o.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return o.STATE_VERSION}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return o.VERSION}});const r=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return r.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return r.toneOf}});const t=V("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return t.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return t.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return t.licenceState}}),Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return U.destroyWithin}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return U.initWithin}}),Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return L.saveStateWithin}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return L.restoreStateWithin}});const n=V("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return n.driveOobUpdates}});const i=V("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return i.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return i.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return i.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return i.SCROLL_NEAR_END_EVENT}});const s=V("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return s.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return s.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return s.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return s.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return s.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return s.HTML_ROW_WARNING_THRESHOLD}});function c(f){const h=f||(typeof document<"u"?document:null);if(!h||!N(h.addEventListener))return()=>{};const g=b=>B(b.target,F),w=b=>H(b.detail&&b.detail.elt||b.target,_),p=b=>{k(b.detail&&b.detail.historyElt||h,F)},m=b=>{b.detail&&b.detail.cacheMiss||S(h,_)};return h.addEventListener("htmx:beforeCleanupElement",g),h.addEventListener("htmx:load",w),h.addEventListener("htmx:beforeHistorySave",p),h.addEventListener("htmx:historyRestore",m),()=>{h.removeEventListener("htmx:beforeCleanupElement",g),h.removeEventListener("htmx:load",w),h.removeEventListener("htmx:beforeHistorySave",p),h.removeEventListener("htmx:historyRestore",m)}}c();const d=c});try{Cn("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.0";async function ae(){return le}const Q="1.71.0",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).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(/^./,J=>J.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=1,te=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class ie{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){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 f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=ae(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Y(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return g}}),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 U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),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 a}});const le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.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,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(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,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-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 m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`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,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[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 m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;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||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);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<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;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 m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`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]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={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)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);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 m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,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:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}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 m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}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 d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!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 m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#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 m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let g=0;g<M.length;g++){const e=M[g];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.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=ae(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&ae()-i<s);return this.#o+=ae()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(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,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`ingest.mixed.${a.id}`,`column "${a.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(m))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,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 l=a[n],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,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 l=a[n],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,g=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(M,i){const s=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(M).reduce((e,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="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 b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(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 l=Number(n);if(Number.isFinite(l))return l;const b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;z<f?(c=Math.sqrt(-2*Math.log(z)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):z<=1-f?(c=z-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-z)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),i=2/(2+M),s=4*i-2,u=[-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 f=0,c=0,t;for(let g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#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(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}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 D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}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(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.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"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),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 l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),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 ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=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"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).fail}),S=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 V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(r)(n[n.length-1])}s.kernel=!0;function u(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 f={sum:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,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"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("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 u.totalOf=="function"?u.totalOf:null,a=[];for(const g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=ie(i,c,f[t],u);return c}function ie(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function z(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 s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,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 ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var En=Cn("packages/modules/htmx/index.js");typeof module=="object"&&module.exports?module.exports=En:typeof define=="function"&&define.amd?define(function(){return En}):ir.LatticeGridHtmx=En})(typeof globalThis<"u"?globalThis:this);
|
|
54
|
+
`)||(f.preventDefault(),this.fromText(h))})))}openFile(){const d=S(this.#n,"input",{attrs:{type:"file",accept:i}});d.style.display="none",this.#o.push(u(d,"change",()=>{const f=d.files&&d.files[0];f&&this.#c(f),d.parentNode&&d.parentNode.removeChild(d)})),this.#n.body.appendChild(d),d.click()}#c(d){if(N(d.arrayBuffer)){d.arrayBuffer().then(h=>{const g=new Uint8Array(h);if(L(g)){this.fromXlsx(g,d.name);return}this.fromText(new TextDecoder().decode(g),d.name)});return}if(N(d.text)){d.text().then(h=>this.fromText(h,d.name));return}const f=new this.#n.defaultView.FileReader;f.onload=()=>this.fromText(String(f.result||""),d.name),f.readAsText(d)}async fromXlsx(d,f){const{header:h,rows:g}=await H(d);if(!h.length)return;const w=U(h,g,{columns:this.#e.columns.all()}),p=g.filter(m=>m.length!==h.length).length;this.#s={rows:g,columns:w,delimiter:null,name:f,warnings:p?[`${p} row(s) do not have ${h.length} columns`]:[]},this.#d()}fromText(d,f){const{header:h,rows:g,delimiter:w}=_(d);if(!h.length)return;const p=U(h,g,{columns:this.#e.columns.all()}),m=g.filter(b=>b.length!==h.length).length;this.#s={rows:g,columns:p,delimiter:w,name:f,warnings:m?[`${m} row(s) do not have ${h.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#l=this.#n.activeElement,this.#i.hidden=!1;const d=this.#i.querySelector(n);d&&N(d.focus)&&d.focus(),this.#h(this.#f("import.opened",{count:this.#s.rows.length}),{repeat:!0})}#h(d,f){const h=this.#t&&this.#t.announce;N(h)&&h.call(this.#t,d,f)}#f(d,f){return(this.#e&&this.#e.messages?this.#e.messages:F).t(d,f)}#m(){const d=this.#n,f=S(d,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),h=S(d,"div",{class:`${t}__panel`});h.appendChild(S(d,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#a=S(d,"div",{class:`${t}__body`}),h.appendChild(this.#a);const g=S(d,"div",{class:`${t}__footer`}),w=S(d,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=S(d,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(w,"click",()=>this.close())),this.#o.push(u(p,"click",()=>this.#g())),g.appendChild(w),g.appendChild(p),h.appendChild(g),f.appendChild(h),this.#o.push(u(f,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const v=[...f.querySelectorAll(n)].filter(O=>!O.hidden);if(!v.length)return;const l=v[0],a=v[v.length-1];b.shiftKey&&this.#n.activeElement===l?(b.preventDefault(),a.focus()):!b.shiftKey&&this.#n.activeElement===a&&(b.preventDefault(),l.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(f),this.#i=f}#p(){const d=this.#n,f=y(this.#a),{rows:h,columns:g,name:w,warnings:p}=this.#s;f.appendChild(S(d,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:h.length,name:w||this.#f("import.clipboard")})}));for(const O of p)f.appendChild(S(d,"p",{class:`${t}__warning`,text:O}));const m=this.#e.columns.all().map(O=>O.field||O.id).filter(Boolean),b=S(d,"table",{class:`${t}__map`}),v=S(d,"tr",{});for(const O of["import.colSource","import.colField","import.colType"])v.appendChild(S(d,"th",{text:this.#f(O)}));b.appendChild(v),g.forEach((O,T)=>{const A=S(d,"tr",{});A.appendChild(S(d,"td",{text:O.source}));const M=S(d,"select",{attrs:{"data-col":String(T),"aria-label":this.#f("import.mapLabel",{source:O.source})}});M.appendChild(S(d,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of m)M.appendChild(S(d,"option",{text:P,attrs:{value:P,selected:P===O.field?!0:null}}));O.field&&!m.includes(O.field)&&M.appendChild(S(d,"option",{text:O.field,attrs:{value:O.field,selected:!0}}));const C=S(d,"td",{});C.appendChild(M),A.appendChild(C),A.appendChild(S(d,"td",{class:`${t}__type`,text:O.type})),b.appendChild(A)}),f.appendChild(b);const l=S(d,"div",{class:`${t}__mode`}),a=S(d,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});a.appendChild(S(d,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),a.appendChild(S(d,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),l.appendChild(S(d,"label",{text:this.#f("import.modeLabel")})),l.appendChild(a),f.appendChild(l)}#g(){const{rows:d,columns:f}=this.#s;for(const m of this.#i.querySelectorAll("select[data-col]")){const b=Number(m.getAttribute("data-col"));f[b]&&m.value!==void 0&&m.value!==null&&(f[b].field=m.value)}const h=this.#i.querySelector("select[data-mode]"),g=h?h.value:void 0,w=g==="replace"||g==="append"?g:this.#r.mode,p=B(d,f);this.#e.import.apply(p,{mode:w}),this.close(),this.#h(this.#f("import.done",{count:p.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#s=null,this.#l&&N(this.#l.focus)&&this.#l.focus(),this.#l=null}destroy(){for(const d of this.#o)d();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null}}}),ve("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,U=W.on,B=W.clear,H=W.documentFor,L="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,o)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const o=u||{};if(this.doc=H(o),this.host=o.host||{},this.props=o.props||{},this.root=_(this.doc,"div",{class:["lattice-tokens",L],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 r=_(this.doc,"button",{class:`${L}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(U(r,"click",()=>this.toggle())),this.root.appendChild(r),this.toggleButton=r,this.menu=_(this.doc,"div",{class:`${L}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,o,r){const t=_(this.doc,"button",{class:`${L}__${u}`,attrs:{type:"button"},children:[_(this.doc,"span",{class:`${L}__glyph`,text:r,attrs:{"aria-hidden":"true"}}),_(this.doc,"span",{class:`${L}__label`,text:o})]});return this.off.push(U(t,"click",()=>{const n=this.host[u];N(n)&&n(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,o=N(u.canUndo)?u.canUndo():!1,r=N(u.canRedo)?u.canRedo():!1,t=N(u.peek)?u.peek("undo"):null,n=N(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",o,t),this.#t(this.redoButton,"redo",r,n),this.open&&this.#n()}#t(u,o,r,t){if(!u)return;u.disabled=!r;const n=o==="undo",i=this.t(n?"history.undo":"history.redo"),s=u.querySelector(`.${L}__label`);s&&(s.textContent=i);const c=t&&t.label?this.t("history.described",{action:i,label:t.label}):i;u.setAttribute("title",r?c:this.t(n?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",r?c:this.t(n?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;B(u);const o=N(this.host.list)?this.host.list():[];if(!o.length){u.appendChild(_(this.doc,"p",{class:`${L}__empty`,text:this.t("history.empty")}));return}o.forEach((r,t)=>{const n=_(this.doc,"button",{class:`${L}__item`,attrs:{type:"button",role:"menuitem","data-type":r.type,"data-undone":r.undone?"true":null},children:[_(this.doc,"span",{class:`${L}__kind`,text:r.type}),_(this.doc,"span",{class:`${L}__text`,text:r.label||r.type})]});this.off.push(U(n,"click",()=>{const i=t+1;for(let s=0;s<i;s++)N(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(n)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&N(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=k}),ve("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,_={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},U="lat-cell--changed",B="lat-cell--added-column";class H{#e;#t;#n=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){for(const y of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(y,()=>this.paint()));this.paint()}paint(){const y=this.#t.viewport.root;if(!y||!y.querySelectorAll)return;const u=this.#e.diff,o=u&&u.enabled;for(const r of y.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key"),n=o?u.statusOf(t):"unchanged";for(const s of Object.values(_))r.classList.remove(s);o&&_[n]&&r.classList.add(_[n]),r.setAttribute("data-diff",o?n:"");const i=o&&n==="changed";for(const s of r.querySelectorAll("[data-col]")){const c=s.getAttribute("data-col");if(s.classList.remove(U,B),s.removeAttribute("data-before"),!i)continue;const d=u.cellStatus(t,c);if(d==="changed"){s.classList.add(U);const f=this.#r(u,t,c);f===null?s.removeAttribute("title"):(s.setAttribute("data-before",f),s.setAttribute("title",this.#o("diff.before",{value:f})))}else d==="added-column"&&s.classList.add(B)}}}#r(y,u,o){const r=this.#e,t=r&&r.columns,n=t&&N(t.get)?t.get(o):null,i=r&&r.permissions;if(n&&i&&N(i.isSecret)&&i.isSecret(n))return null;const s=y.before(u,o);if(s==null)return this.#o("diff.empty");if(!n||!N(n.formatValue))return String(s);const c=N(y.beforeRow)?y.beforeRow(u):void 0,f={...(r.rows&&N(r.rows.byKey)?r.rows.byKey(u):null)||{},data:c===void 0?{}:c};try{const h=n.formatValue(s,f,f.data);return h==null?"":String(h)}catch(h){return z(`diff-before-format:${o}`,`the formatter for column "${o}" threw while formatting a previous value, so the diff hover shows the raw one.`,h),String(s)}}#o(y,u){const o=this.#e;return(o&&o.messages?o.messages:W).t(y,u)}destroy(){for(const u of this.#n)u();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const u of y.querySelectorAll("[data-key]")){for(const o of Object.values(_))u.classList.remove(o);u.removeAttribute("data-diff")}for(const u of y.querySelectorAll("[data-col]"))u.classList.remove(U,B),u.removeAttribute("data-before")}}}function L(S){return!!(S&&S.diff&&(N(S.diff)||typeof S.diff=="object"))}const k=H}),ve("packages/dom/src/highlightpaint.js",function(e,V){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z="lat-cell--highlight",F="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(B){this.#e=B.grid,this.#t=B.renderer,this.#i=B.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 B=()=>{this.#o=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):N(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const H=this.#s();if(H){H.sweep();for(const L of B.querySelectorAll("[data-key]")){const k=L.getAttribute("data-key");for(const S of L.querySelectorAll("[data-col]")){const y=H.active?H.colourFor(k,S.getAttribute("data-col")):null;y?(S.classList.add(z),S.style.setProperty(F,y)):S.classList.contains(z)&&(S.classList.remove(z),S.style.removeProperty(F))}}this.#a(H)}}#a(B){this.#r!==null&&N(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=B.nextExpiry;if(!Number.isFinite(H)||!N(this.#i.setTimeout))return;const L=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},L)}#s(){const B=this.#e.highlight;return B&&N(B.model)?B.model():null}destroy(){this.#r!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll))for(const H of B.querySelectorAll(`.${z}`))H.classList.remove(z),H.style.removeProperty(F)}}const _=W}),ve("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isFunction,z="lat-cell--find",F="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(B){this.#e=B.grid,this.#t=B.renderer,this.#i=B.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 B=()=>{this.#r=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):N(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const H=this.#e.find;if(!H||!N(H.stateFor))return;const L=N(H.model)?H.model():null,k=!!L&&L.active;if(!k&&!this.#o)return;let S=!1;for(const y of B.querySelectorAll("[data-key]")){const u=y.getAttribute("data-key");for(const o of y.querySelectorAll("[data-col]")){const r=k?H.stateFor(u,o.getAttribute("data-col")):null;r?(S=!0,o.classList.add(z),o.classList.toggle(F,r==="current")):o.classList.contains(z)&&o.classList.remove(z,F)}}this.#o=S}destroy(){for(const H of this.#n)H();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll)){for(const H of B.querySelectorAll(`.${z}`))H.classList.remove(z,F);this.#o=!1}}}const _=W}),ve("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Z=V("packages/dom/src/editors/common.js"),N=Z.el,z=Z.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction,L="lat-find",k=12,S=120;class y{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#v=null;#b=null;#y=!1;constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document||r.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=r.settings&&typeof r.settings=="object"?r.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(r,t){const n=this.#e;return(n&&n.messages&&H(n.messages.t)?n.messages:U).t(r,t)}mount(){const r=this.#S();if(!r)return;r.attachUi({open:n=>this.show(n),close:()=>this.hide(),focus:()=>{this.#a&&this.#a.focus()}}),r.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&H(t.addEventListener)&&this.#o.shortcut!==!1){const n=i=>{if(!(i.ctrlKey||i.metaKey)||i.altKey||i.shiftKey||i.key!=="f"&&i.key!=="F")return;const s=i.target;if(this.#a&&s===this.#a){i.preventDefault(),i.stopPropagation(),H(this.#a.select)&&this.#a.select();return}W(s)||(i.preventDefault(),i.stopPropagation(),this.show())};t.addEventListener("keydown",n,!0),this.#g.push(()=>t.removeEventListener("keydown",n,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#R())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(r){const t=this.#j();if(!t)return;const n=t.style.display!=="none";t.style.display="",n||this.#w(),this.#S().setOpen(!0),r!=null&&(this.#a.value=String(r),this.#C()),this.#a.focus(),H(this.#a.select)&&this.#a.select(),this.#R()}hide(){this.#_();const r=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),r&&(r.clear(),r.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const s=(H(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;H(s.focus)&&s.focus()}search(){this.#C()}destroy(){this.#y=!0,this.#_();for(const t of this.#g)t();this.#g=[];const r=this.#S();r&&(r.attachUi(null),r.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const r=this.#t;r&&H(r.invalidate)&&r.invalidate("size")}#S(){const r=this.#e&&this.#e.find;return r&&H(r.model)?r.model():null}#j(){if(this.#i)return this.#i;const r=this.#t.viewport,t=r?.root,n=this.#n;if(!t||!n||!H(t.insertBefore))return null;const i=N(n,"div",{class:L,attrs:{role:"search","aria-label":this.t("find.label")}});this.#a=N(n,"input",{class:`${L}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#s=N(n,"span",{class:`${L}__count`,attrs:{"aria-hidden":"true"}}),this.#l=N(n,"span",{class:`${L}__scope`,attrs:{"aria-hidden":"true"}}),this.#l.style.display="none",this.#u=N(n,"span",{class:`${L}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const s=N(n,"button",{class:`${L}__nav ${L}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),c=N(n,"button",{class:`${L}__nav ${L}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=N(n,"button",{class:`${L}__toggle ${L}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=N(n,"button",{class:`${L}__toggle ${L}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=N(n,"select",{class:`${L}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const d=N(n,"button",{class:`${L}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),f=N(n,"div",{class:`${L}__options`,children:[this.#c,this.#d,this.#h]});for(const g of[this.#a,this.#s,this.#l,this.#u,s,c,d,f])i.appendChild(g);this.#g.push(z(this.#a,"input",()=>this.#O())),this.#g.push(z(s,"click",()=>this.#e.find.prev())),this.#g.push(z(c,"click",()=>this.#e.find.next())),this.#g.push(z(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#C()})),this.#g.push(z(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#C()})),this.#g.push(z(this.#h,"change",()=>{const g=this.#h.value;this.#p=g?String(g):null,this.#C()})),this.#g.push(z(d,"click",()=>this.hide()));const h=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),this.hide();return}g.key==="Enter"&&g.target===this.#a&&(g.preventDefault(),g.stopPropagation(),this.#v!==null&&(this.#N(),this.#C()),g.shiftKey?this.#e.find.prev():this.#e.find.next())};return i.addEventListener("keydown",h),this.#g.push(()=>i.removeEventListener("keydown",h)),i.style.display="none",t.insertBefore(i,r.header||t.firstChild),this.#i=i,this.#A(),i}#A(){const r=this.#h;if(!r)return;const t=this.#n;for(;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(N(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const n=this.#e.columns,i=n&&H(n.visible)?n.visible():[];let s=!1;for(const c of i){if(!c||c.id===void 0)continue;const d=String(c.id);r.appendChild(N(t,"option",{text:c.title||d,attrs:{value:d}})),d===this.#p&&(s=!0)}s||(this.#p=null),r.value=this.#p||""}#O(){const r=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#N(),r===0||!H(this.#r.setTimeout)){this.#C();return}this.#v=this.#r.setTimeout(()=>{this.#v=null,this.#C()},r)}#C(){const r=this.#S();if(!r||this.#y)return;const t=this.#a?this.#a.value:"";if(!t){this.#M(),r.clear();return}r.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#E()}),this.#T()}#E(){const r=this.#t&&this.#t.window,t=r&&Number.isFinite(r.first)?r.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#y)return;const r=()=>{this.#b=null,this.#x()};H(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(r):H(this.#r.setTimeout)?this.#b=this.#r.setTimeout(r,0):r()}#x(){const r=this.#S();!r||this.#y||!r.active||(r.stale&&r.rescan({from:this.#E()}),!r.complete&&(r.step(k)||this.#T()))}#R(){if(!this.#i||this.#y)return;const r=this.#e.find.count(),t=this.#S().active;let n="",i="idle";t&&(r.total===0?(n=r.complete?this.t("find.none"):this.t("find.searching"),i=r.complete?"none":"searching"):(n=this.t(r.complete?"find.count":"find.countPartial",{current:r.current,total:r.total}),i=r.complete?"matches":"searching")),this.#s.textContent=n,this.#i.setAttribute("data-state",i);const s=t&&r.windowed;this.#l.textContent=s?this.t("find.loadedRows"):"",this.#l.style.display=s?"":"none",t?r.complete&&(this.#u.textContent=r.total===0?this.t(s?"a11y.find.noneLoaded":"a11y.find.none"):this.t(s?"a11y.find.countLoaded":"a11y.find.count",{current:r.current,count:r.total})):this.#u.textContent=""}#N(){this.#v!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#v),this.#v=null}#M(){this.#b!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#N(),this.#M()}}const u=y}),ve("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Z="lat-cell--redacted",N="lat-cell";class z{#e;#t;#n=[];constructor(_){this.#e=_.grid,this.#t=_.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const _=this.#t.viewport?.root;if(!_||!_.querySelectorAll)return;const U=this.#e.redaction;if(!U)return;const B=U.active;for(const H of _.querySelectorAll(`.${N}[data-col]`))B&&U.has(H.getAttribute("data-col"))?H.classList.add(Z):H.classList.contains(Z)&&H.classList.remove(Z)}destroy(){for(const _ of this.#n)_();this.#n=[]}}const F=z}),ve("packages/dom/src/validationpaint.js",function(e,V){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const N=V("packages/dom/src/editors/common.js").markInvalid,z="lat-cell";function F(U,B){let H=U;for(;H;){if(B(H))return H;H=H.parentNode}return null}class W{#e;#t;#n=[];constructor(B){this.#e=B.grid,this.#t=B.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const B of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(B,()=>this.paint()));this.paint()}#r(B){const H=F(B,L=>L.getAttribute&&L.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const B=this.#e.validation;if(!B||!B.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const L of H.querySelectorAll(`.${z}[data-col]`)){const k=L.getAttribute("data-col"),S=this.#r(L),y=S?B.errorFor(S,k):null;N(L,y?y.message:null)}}destroy(){for(const B of this.#n)B();this.#n=[]}}const _=W}),ve("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/renderer/textentry.js").isTextEntry,_=V("packages/dom/src/renderer/viewport.js").CLASS,U="lat-presenting",B="lat-presenting--changing",H="lat-presenting__progress",L="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#a=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#n=o.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",r=>this.#l(r))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&N(this.#n.watch)&&this.#r.push(this.#n.watch(r=>{r||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const o=this.#t.viewport?.root;if(o&&N(o.addEventListener)){const r=t=>this.#s(t);o.addEventListener("keydown",r),this.#r.push(()=>o.removeEventListener("keydown",r))}}#s(o){const r=this.#e.presentation;if(!r?.active)return;const t=o.ctrlKey||o.metaKey,n=o.key;if(n==="Escape"&&!this.#n){o.defaultPrevented||(r.stop(),o.preventDefault?.());return}if(t){n==="="||n==="+"?(r.nudge(1),o.preventDefault?.()):n==="-"||n==="_"?(r.nudge(-1),o.preventDefault?.()):n==="0"&&(r.setScale(1.5),o.preventDefault?.());return}if(!r.views.length||F(o.target))return;n==="ArrowRight"||n==="ArrowDown"||n==="PageDown"||n===" "?(r.step(1),o.preventDefault?.()):n==="ArrowLeft"||n==="ArrowUp"||n==="PageUp"?(r.step(-1),o.preventDefault?.()):n==="Home"?(r.goTo(0),o.preventDefault?.()):n==="End"?(r.goTo(r.views.length-1),o.preventDefault?.()):(n==="r"||n==="R")&&(r.reset(),o.preventDefault?.())}#l(o){!o||!o.viewId||(this.#u(),this.#e.views?.apply?.(o.viewId),this.#c(o))}#u(){const o=this.#t.viewport?.root;o?.classList&&(o.classList.remove(B),o.offsetWidth,o.classList.add(B))}#c(o){const r=this.#t.viewport?.overlays;if(!r||!this.#e.presentation.views.length)return;const t=r.ownerDocument;if(!t?.createElement)return;if(!this.#i){const s=t.createElement("div");s.className=H,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),r.appendChild(s),this.#i=s}const n=this.#e.views?.get?.(o.viewId),i=n&&n.name?n.name:"";this.#i.textContent=i?`${i} · ${(o.index||0)+1} / ${o.count||0}`:`${(o.index||0)+1} / ${o.count||0}`}#d(){if(this.#o){this.#f();return}const o=!!(this.#n&&this.#n.active());this.#n&&!o&&this.#n.enter();const r=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const i of k){if(r.has(i)||i==="toolPanel"&&this.#y())continue;const s=this.#w(i);s&&s.style&&s.style.display!=="none"&&(s.style.display="none",t.push(s))}const n=this.#v();n&&n.style&&n.style.display!=="none"&&this.#b(n)&&(n.style.display="none",t.push(n)),this.#o={maximised:o,hidden:t},this.#t.viewport?.root?.classList?.add(U),this.#f(),this.#p()}#h(){const o=this.#o;this.#o=null;const r=this.#t.viewport?.root;if(r?.classList?.remove(U),r?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),r?.classList?.remove(B),this.#m(),o){const t=this.#e.toolPanel;t&&N(t.presentRestore)&&t.presentRestore();for(const n of o.hidden)n.style.display="";this.#n&&!o.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const o=this.#t.viewport?.root;!o||!o.style||(o.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const o=this.#t.viewport?.root;if(!o?.querySelectorAll)return;const r=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=r&&r.keys.length?new Set(r.keys):null,n=r&&r.colIds.length?new Set(r.colIds):null;for(const i of o.querySelectorAll("[data-key]")){const s=!t||t.has(i.getAttribute("data-key"));for(const c of i.querySelectorAll("[data-col]"))!r||s&&(!n||n.has(c.getAttribute("data-col")))?c.classList.remove(L):c.classList.add(L)}}#p(){this.#g();const o=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(o)||o<=0||!this.#e.presentation.views.length)return;const r=this.#t.viewport?.root?.ownerDocument?.defaultView;r?.setInterval&&(this.#a=r.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,o)))}#g(){if(this.#a===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#a),this.#a=null}#v(){const o=this.#e.element;return!o||!N(o.querySelector)?null:o.querySelector(`.${_.statusBar}`)}#b(o){const r=o.children||[];for(const t of r)if(!t.style||t.style.display!=="none")return!1;return!0}#y(){const o=this.#e.toolPanel;return!!(o&&N(o.presentOnly)&&o.presentOnly())}#w(o){const r=this.#e.element;if(!r||!N(r.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[o];return t?r.querySelector(t):null}destroy(){this.#o&&this.#h();for(const o of this.#r)o();this.#r=[]}}const y=S}),ve("packages/dom/src/capture.js",function(e,V){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const N=V("packages/core/src/internal/util.js").isFunction,z=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(H,L,k){const S=k.getComputedStyle(H),y=L.style;if(y)for(let u=0;u<S.length;u++){const o=S[u];z.has(o)||y.setProperty(o,S.getPropertyValue(o),S.getPropertyPriority(o))}}function W(H,L,k){if(F(H,L,k),H.tagName==="CANVAS"&&N(H.toDataURL))try{const u=H.toDataURL("image/png"),o=L.style;o&&(o.setProperty("background-image",`url(${u})`),o.setProperty("background-size","100% 100%"),o.setProperty("background-repeat","no-repeat"))}catch{}const S=H.children||[],y=L.children||[];for(let u=0;u<S.length&&u<y.length;u++)W(S[u],y[u],k)}function _(H,L){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,L).origin===L}catch{return!0}}async function U(H,L={}){const k=H.ownerDocument,S=k?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(y.width)),o=Math.max(1,Math.ceil(y.height)),r=Math.max(.1,Number(L.scale)||2),t=S.location?.origin||"";for(const h of H.querySelectorAll("img")){const g=h.getAttribute("src")||"";if(!_(g,t))throw new Error(`capture refused: the image at ${g} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const n=H.cloneNode(!0);W(H,n,S),n.style.width=`${u}px`,n.style.height=`${o}px`,n.style.margin="0";const i=new S.XMLSerializer().serializeToString(n),s=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${o}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${i}</div></foreignObject></svg>`,c=new S.Image;await new Promise((h,g)=>{c.onload=()=>h(void 0),c.onerror=()=>g(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`});const d=k.createElement("canvas");d.width=Math.round(u*r),d.height=Math.round(o*r);const f=d.getContext("2d");if(!f)throw new Error("capture could not get a 2d context");return f.fillStyle=L.background||S.getComputedStyle(H).backgroundColor||"#ffffff",f.fillRect(0,0,d.width,d.height),f.drawImage(c,0,0,d.width,d.height),new Promise((h,g)=>{d.toBlob(w=>w?h({blob:w,width:d.width,height:d.height}):g(new Error("capture produced no image")),L.type||"image/png",L.quality)})}const B=U}),ve("packages/dom/src/annotate.js",function(e,V){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,_=Object.freeze(["pen","arrow","rect","highlight"]),U=Object.freeze(["freehand","arrow","rect","highlight","text"]),B=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),H=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),L=14,k="system-ui, -apple-system, sans-serif";function S(s,c){if(!s||typeof s!="object")return null;const d=B[s.type];if(!d)return null;const f=Array.isArray(s.points)?s.points:[],h=[];for(const w of f){const p=Number(w&&w.x),m=Number(w&&w.y);Number.isFinite(p)&&Number.isFinite(m)&&h.push({x:p,y:m})}const g=typeof s.colour=="string"&&s.colour?s.colour:c;if(d==="text"){const w=typeof s.text=="string"?s.text:"";if(!h.length||!w)return null;const p={tool:d,colour:g,points:[h[0]],text:w,region:y(s.region)},m=Number(s.fontSize);return Number.isFinite(m)&&m>0&&(p.fontSize=m),typeof s.background=="string"&&s.background&&(p.background=s.background),p}return h.length<2?null:{tool:d,colour:g,points:h,region:y(s.region)}}function y(s){return s==="start"||s==="end"?s:"centre"}function u(s){const c={type:H[s.tool]||s.tool,colour:s.colour,points:s.points.map(d=>({x:d.x,y:d.y}))};return(s.region==="start"||s.region==="end")&&(c.region=s.region),s.tool==="text"&&(c.text=s.text,s.fontSize!==void 0&&(c.fontSize=s.fontSize),s.background!==void 0&&(c.background=s.background)),c}const o="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(s){return s==="arrow"||s==="rect"}class n{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#a=[];#s=null;#l=[];#u=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#u=Array.isArray(c.seed)?c.seed:null}get tool(){return this.#o}get count(){return this.#a.length}mount(){this.#l.push(this.#e.on("scroll",()=>this.redraw())),this.#l.push(this.#e.on("render:done",()=>this.redraw())),this.#l.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(c){const d=S(c,this.#i);return d?(d.durable=!0,this.#a.push(d),this.#w(),this.redraw(),this.#A(),this.#a.length):(z("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${U.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#a.length)}list(){return this.#a.map(u)}replaceAll(c){const d=Array.isArray(c)?c:[];this.#a=d.map(f=>S(f,this.#i)).filter(Boolean);for(const f of this.#a)f.durable=!0;this.#a.length&&this.#w(),this.redraw(),this.#A()}#c(){const c=this.#t.viewport?.root;if(!c||!N(c.addEventListener))return;const d=f=>{!this.#o||!f||f.key!=="Escape"||(this.use(null),f.preventDefault?.())};c.addEventListener("keydown",d,!0),this.#l.push(()=>c.removeEventListener("keydown",d,!0))}#d(){const c=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!c||!N(c.matchMedia))return;let d=null;const f=()=>{const h=c.devicePixelRatio||1;let g;try{g=c.matchMedia(`(resolution: ${h}dppx)`)}catch{return}d=g;const w=()=>{this.redraw(),f()};N(g.addEventListener)?g.addEventListener("change",w,{once:!0}):N(g.addListener)&&g.addListener(w)};f(),this.#l.push(()=>{d=null})}use(c,d={}){const f=!!d.colour&&c===this.#o;d.colour&&(this.#i=String(d.colour));const h=c&&_.includes(c)?c:null;this.#o=h&&h===this.#o&&!f?null:h;const g=this.#o?this.#w():this.#n;return g&&(g.style.pointerEvents=this.#o?"auto":"none",g.style.cursor=this.#o?"crosshair":""),this.#A(),this.#o}undo(){return this.#a.pop(),this.redraw(),this.#A(),this.#a.length}clear(){this.#a.length&&(this.#a=[],this.redraw(),this.#A())}#h(){const c=this.#a.filter(d=>d.durable);c.length!==this.#a.length&&(this.#a=c,this.redraw(),this.#A())}redraw(){!this.#n&&this.#a.length&&this.#w();const c=this.#n,d=this.#r;if(!c||!d)return;this.#S();const{left:f,top:h}=this.#y();d.clearRect(0,0,c.width,c.height);const g=this.#s?[...this.#a,this.#s]:this.#a;for(const w of["centre","start","end"]){const p=g.filter(m=>y(m.region)===w);if(p.length){d.save(),this.#f(d,w),d.translate((w==="centre"?-f:0)||0,-h||0);for(const m of p)this.#v(d,m);d.restore()}}}#f(c,d="centre"){const f=this.#n,h=this.#t.viewport?.bodyViewport;if(!N(f?.getBoundingClientRect)||!N(h?.getBoundingClientRect))return;const g=f.getBoundingClientRect(),w=h.getBoundingClientRect();if(!w.width||!w.height)return;const p=this.#m(d,w);p&&(c.beginPath(),c.rect(p.left-g.left,w.top-g.top,p.width,w.height),c.clip())}#m(c,d){const f=b=>{if(!N(b?.getBoundingClientRect))return null;const v=b.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},h=f(this.#t.viewport?.bodyStart),g=f(this.#t.viewport?.bodyEnd);if(c==="start")return h;if(c==="end")return g;let w=d.left,p=d.left+d.width;const m=d.left+d.width/2;for(const b of[h,g]){if(!b)continue;const v=b.left+b.width;b.left+b.width/2<m?w=Math.max(w,v):p=Math.min(p,b.left)}return p>w?{left:w,width:p-w}:null}#p(c){for(const[d,f]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!N(f?.getBoundingClientRect))continue;const h=f.getBoundingClientRect();if(h&&h.width>0&&c>=h.left&&c<h.left+h.width)return d}return"centre"}#g(c){const d=this.#t.viewport?.bodyViewport;if(!N(d?.getBoundingClientRect))return!0;const f=d.getBoundingClientRect();return!f.width||!f.height?!0:c.clientX>=f.left&&c.clientX<=f.right&&c.clientY>=f.top&&c.clientY<=f.bottom}#v(c,d){const f=d.points;if(!f.length)return;const h=this.#e.presentation?.scale||1;c.lineWidth=(r[d.tool]||3)*h,c.strokeStyle=d.colour,c.fillStyle=d.colour,c.lineCap="round",c.lineJoin="round",c.globalAlpha=d.tool==="highlight"?.32:1;const g=f[0],w=f[f.length-1];if(d.tool==="text"){const p=(d.fontSize||L)*h;c.font=`${p}px ${k}`,c.textBaseline="top";const m=d.text||"";if(d.background){let b=m.length*p*.6;if(typeof c.measureText=="function"){const v=c.measureText(m);v&&Number.isFinite(v.width)&&(b=v.width)}c.fillStyle=d.background,c.fillRect(g.x-p*.15,g.y-p*.1,b+p*.3,p*1.2)}c.fillStyle=d.colour,c.fillText(m,g.x,g.y),c.globalAlpha=1;return}if(d.tool==="rect")c.strokeRect(g.x,g.y,w.x-g.x,w.y-g.y);else if(d.tool==="arrow")c.beginPath(),c.moveTo(g.x,g.y),c.lineTo(w.x,w.y),c.stroke(),this.#b(c,g,w,c.lineWidth);else{c.beginPath(),c.moveTo(g.x,g.y);for(let p=1;p<f.length;p++)c.lineTo(f[p].x,f[p].y);c.stroke()}c.globalAlpha=1}#b(c,d,f,h){const g=Math.atan2(f.y-d.y,f.x-d.x),w=Math.max(8,h*3);c.beginPath(),c.moveTo(f.x,f.y),c.lineTo(f.x-w*Math.cos(g-Math.PI/7),f.y-w*Math.sin(g-Math.PI/7)),c.lineTo(f.x-w*Math.cos(g+Math.PI/7),f.y-w*Math.sin(g+Math.PI/7)),c.closePath(),c.fill()}#y(){const c=N(this.#t.scrollPosition)?this.#t.scrollPosition():null,d=this.#t.viewport?.rtl===!0;return{left:W(c?.left||0,d),top:c?.top||0}}#w(){if(this.#n)return this.#n;const c=this.#t.viewport?.overlays,d=c?.ownerDocument;if(!c||!d?.createElement)return null;const f=d.createElement("canvas");return f.className=o,f.style.position="absolute",f.style.inset="0",f.style.pointerEvents="none",c.appendChild(f),this.#n=f,this.#r=f.getContext?f.getContext("2d"):null,this.#S(),this.#j(f),f}#S(){const c=this.#n,d=this.#t.viewport?.root;if(!c||!d?.getBoundingClientRect)return;const f=d.getBoundingClientRect(),g=c.ownerDocument?.defaultView?.devicePixelRatio||1,w=Math.max(1,Math.round(f.width*g)),p=Math.max(1,Math.round(f.height*g));c.width===w&&c.height===p||(c.width=w,c.height=p,c.style&&(c.style.width=`${Math.max(1,f.width)}px`,c.style.height=`${Math.max(1,f.height)}px`),this.#r?.setTransform(g,0,0,g,0,0))}#j(c){const d=(p,m="centre")=>{const b=c.getBoundingClientRect(),{left:v,top:l}=this.#y();return{x:p.clientX-b.left+(m==="centre"?v:0),y:p.clientY-b.top+l}},f=p=>{if(!this.#o||!this.#g(p))return;const m=this.#p(p.clientX);this.#s={tool:this.#o,colour:this.#i,points:[d(p,m)],region:m},c.setPointerCapture?.(p.pointerId),p.preventDefault?.()},h=p=>{if(!this.#s)return;const m=d(p,this.#s.region);t(this.#s.tool)&&this.#s.points.length>1&&this.#s.points.pop(),this.#s.points.push(m),this.redraw()},g=p=>{this.#s&&(this.#s.points.length>1&&this.#a.push(this.#s),this.#s=null,c.releasePointerCapture?.(p.pointerId),this.redraw(),this.#A())},w=p=>{if(!this.#o)return;const m=this.#t.viewport?.bodyViewport;if(!m)return;let b=!1;p.deltaY&&typeof m.scrollTop=="number"&&(m.scrollTop+=p.deltaY,b=!0),p.deltaX&&typeof m.scrollLeft=="number"&&(m.scrollLeft+=p.deltaX,b=!0),b&&p.preventDefault?.()};c.addEventListener("pointerdown",f),c.addEventListener("pointermove",h),c.addEventListener("pointerup",g),c.addEventListener("pointercancel",g),c.addEventListener("wheel",w,{passive:!1}),this.#l.push(()=>{c.removeEventListener("pointerdown",f),c.removeEventListener("pointermove",h),c.removeEventListener("pointerup",g),c.removeEventListener("pointercancel",g),c.removeEventListener("wheel",w)})}#A(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#a.length},"user")}destroy(){for(const c of this.#l)c();this.#l=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#a=[]}}const i=n}),ve("packages/dom/src/timelinebar.js",function(e,V){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function _(L){if(!Number.isFinite(L)||L<1e3)return"now";const k=Math.round(L/1e3);if(k<60)return`${k}s ago`;const S=Math.round(k/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function U(L,k){return Number.isFinite(L)?new Date(L).toLocaleTimeString(k||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class B{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#a.push(this.#e.on("timeline:attached",()=>{this.#l(),this.refresh()})),this.#a.push(this.#e.on("timeline:detached",()=>this.#u())),this.#a.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#a.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,S=k.depth,y=k.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-y)),this.#r.disabled=S===0;const u=k.at(),o=k.live;this.#o&&(this.#o.textContent=o?this.#s("timeline.live"):_(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",o?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#s("timeline.recording"):U(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",o?"true":"false")}#s(k,S){const y=this.#e;return(y&&y.messages?y.messages:F).t(k,S)}#l(){if(this.#n)return;const k=this.#t.viewport?.overlays,S=k?.ownerDocument;if(!k||!S?.createElement)return;const y=S.createElement("div");y.className=W;const u=S.createElement("span");u.className=`${W}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const o=S.createElement("input");o.className=`${W}__range`,o.type="range",o.min="0",o.step="1",o.setAttribute("aria-label",this.#s("timeline.scrub"));const r=S.createElement("span");r.className=`${W}__clock`;const t=S.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#s("timeline.goLive"),t.setAttribute("aria-label",this.#s("timeline.returnToPresent")),y.appendChild(u),y.appendChild(o),y.appendChild(r),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=o,this.#o=u,this.#i=r;const n=()=>{const c=this.#e.timeline.depth;this.#e.timeline.seek(c-Number(o.value))};o.addEventListener("input",n);const i=()=>this.#e.timeline.toLive();t.addEventListener("click",i);const s=c=>c.stopPropagation();o.addEventListener("keydown",s),this.#a.push(()=>{o.removeEventListener("input",n),t.removeEventListener("click",i),o.removeEventListener("keydown",s)})}#u(){this.#n&&(N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#a)k();this.#a=[],this.#u()}}const H=B}),ve("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/direction.js").isRtlElement,U="lat-comment-mark",B="lat-cell--commented",H="lat-cell--commented-open";class L{#e;#t;#n=[];#r=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#a(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const o=[];for(const r of u.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key");if(t){o.push(t);for(const n of r.querySelectorAll("[data-col]")){const i=n.getAttribute("data-col"),s=y.at(t,i),c=!!(s&&s.count);n.classList.toggle(B,c),n.classList.toggle(H,c&&s.unresolved>0),this.#i(n,s,i)}}}(o.length!==this.#r.length||o.some((r,t)=>r!==this.#r[t]))&&(this.#r=o,y.request(o))}#o(y,u){const o=this.#e;return(o&&o.messages?o.messages:F).t(y,u)}#i(y,u,o){if(!u||!u.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const r=u.count,t=u.unresolved,n=this.#o("count.comments",{count:r});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:n,unresolved:t}):this.#o("comments.allResolved",{comments:n}))}#a(){const y=this.#t.viewport?.root;if(!y||!N(y.addEventListener))return;const u=r=>{const t=this.#e.comments;if(!t||!t.enabled)return;const n=r.target&&N(r.target.closest)?r.target.closest("[data-col]"):null;if(!n||!n.classList.contains(B)||!this.#s(n,r))return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.stopPropagation(),r.preventDefault(),t.open(s,n.getAttribute("data-col")))},o=r=>{const t=this.#e.comments;if(!t||!t.enabled||!r.altKey||r.key!=="m"&&r.key!=="M")return;const n=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&N(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!n)return;const i=n.closest("[data-key]"),s=i&&i.getAttribute("data-key");s&&(r.preventDefault(),r.stopPropagation(),t.open(s,n.getAttribute("data-col")))};y.addEventListener("click",u,!0),y.addEventListener("keydown",o,!0),this.#n.push(()=>{y.removeEventListener("click",u,!0),y.removeEventListener("keydown",o,!0)})}#s(y,u){if(!N(y.getBoundingClientRect))return!1;const o=y.getBoundingClientRect(),r=Math.max(14,Math.min(24,o.height*.6));return(_(y)?u.clientX<=o.left+r:u.clientX>=o.right-r)&&u.clientY<=o.top+r}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=L}),ve("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/editors/common.js").cssEscape,B=V("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class L{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#a=null;constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){const y=this.#e.presence;if(!(!y||!y.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,o=>this.#s(u,o)));this.#l(),this.paint()}}#s(y,u){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const r=u&&u.peer;r&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:r.name}))}#l(){const y=this.#t.viewport?.overlays,u=y?.ownerDocument;if(!y||!u?.createElement)return;const o=this.#e.get("presence")||{},r=u.createElement("span");if(r.className=`${H}__live`,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),y.appendChild(r),this.#r=r,o.roster===!1)return;const t=u.createElement("div");t.className=H,o.roster&&o.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,u=this.#t.viewport?.root;if(!y||!y.enabled||!u?.querySelectorAll)return;this.#d(u);const o=y.peers(),r=[...o].sort((t,n)=>t.at-n.at);for(const t of r)for(const n of t.ranges||[])for(const i of n.rowIds||[])for(const s of n.columns||[])this.#c(u,i,s,t,"range");for(const t of r)t.cursor&&this.#c(u,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of r)t.editing&&this.#c(u,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(o)}#u(y){if(this.#a!==null)return;const u=y.filter(t=>t.cursorFresh);if(!u.length)return;const r=Math.max(...u.map(t=>t.cursorAt||0))+B-Date.now();this.#a=setTimeout(()=>{this.#a=null,this.paint()},Math.max(50,r))}#c(y,u,o,r,t){const n=y.querySelector(`[data-key="${_(u)}"]`),i=n&&n.querySelector(`[data-col="${_(o)}"]`);i&&(i.setAttribute("data-presence",t),i.style.setProperty("--lat-peer",r.colour),i.setAttribute("data-peer-name",r.name),i.setAttribute("data-peer-initial",r.initials||(r.name||"?").slice(0,1).toUpperCase()),r.idle?i.setAttribute("data-peer-idle","true"):i.removeAttribute("data-peer-idle"),t==="cursor"&&r.cursorFresh&&i.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${o}`))}#d(y){if(this.#o.size){for(const u of y.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const r of u){const t=y.createElement("button");t.className=`${H}__peer`,t.type="button",t.style.setProperty("--lat-peer",r.colour),t.toggleAttribute("data-idle",!!r.idle),t.toggleAttribute("data-hidden",!!r.hidden);let n="presence.peer";r.hidden?n="presence.peerHidden":r.idle&&(n="presence.peerIdle"),t.setAttribute("aria-label",this.#f(n,{name:r.name}));const i=y.createElement("span");i.className=`${H}__dot`,i.setAttribute("aria-hidden","true"),i.textContent=r.initials||(r.name||"?").slice(0,1).toUpperCase(),t.appendChild(i);const s=y.createElement("span");s.className=`${H}__name`,s.textContent=r.name,t.appendChild(s),t.addEventListener("click",()=>this.#e.presence.jumpTo(r.id)),this.#n.appendChild(t)}const o=u.filter(r=>r.hidden).length;if(o){const r=y.createElement("span");r.className=`${H}__hidden`,r.textContent=this.#f("presence.hidden",{count:o}),this.#n.appendChild(r)}}announceRefusal(y){if(!this.#r)return;const u=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(y,u){const o=this.#e;return(o&&o.messages?o.messages:F).t(y,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#a!==null&&clearTimeout(this.#a),this.#a=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=L}),ve("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/editors/common.js").cssEscape,B=V("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",L=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(r,t){if(!Number.isFinite(r))return"";const n=Math.max(0,Math.round((t-r)/1e3));if(n<60)return"just now";const i=Math.round(n/60);if(i<60)return`${i}m ago`;const s=Math.round(i/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function y(r,t,n,i){t.textContent="";const s=String(n??"");if(!i){t.textContent=s;return}const c=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let d=0,f=c.exec(s);for(;f;){f.index>d&&t.appendChild(r.createTextNode(s.slice(d,f.index)));const h=f[0];if(h.startsWith("*")){const g=r.createElement("em");g.textContent=h.slice(1,-1),t.appendChild(g)}else if(h.startsWith("`")){const g=r.createElement("code");g.textContent=h.slice(1,-1),t.appendChild(g)}else{const g=h.indexOf("]("),w=h.slice(1,g),p=h.slice(g+2,-1);if(L.test(p)){const m=r.createElement("a");m.href=p,m.textContent=w,m.rel="noopener noreferrer",m.target="_blank",t.appendChild(m)}else t.appendChild(r.createTextNode(w))}d=f.index+h.length,f=c.exec(s)}d<s.length&&t.appendChild(r.createTextNode(s.slice(d)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#s.push(this.#e.on("comment:threadOpened",t=>this.#l(t))),this.#s.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#s.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#s.push(this.#e.on("stream:evicted",()=>this.#c()))}#l(t){const n=this.#t.viewport?.root?.ownerDocument;n&&(this.#a=n.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(n),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&N(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#a;this.#a=null,t&&N(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:n}=B(t);this.#e.rows.byKey(n)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const i=this.#r.ownerDocument.createElement("p");i.className=`${H}__note`,i.setAttribute("role","status"),i.textContent=t,this.#r.appendChild(i)}#h(t,n){const i=this.#t.viewport?.root;if(!i||!i.querySelector)return null;const s=i.querySelector(`[data-key="${_(t)}"]`);return s?s.querySelector(`[data-col="${n}"]`):null}#f(t,n){const i=this.#e;return(i&&i.messages?i.messages:F).t(t,n)}#m(t){const n=t.createElement("div");n.className=H,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",this.#f("comments.panel"));const i=t.createElement("header");i.className=`${H}__head`;const s=t.createElement("div");s.className=`${H}__title`,i.appendChild(s);const c=t.createElement("button");c.className=`${H}__resolve`,c.type="button",i.appendChild(c);const d=t.createElement("button");d.className=`${H}__close`,d.type="button",d.setAttribute("aria-label",this.#f("comments.close")),d.textContent="×",i.appendChild(d);const f=t.createElement("div");f.className=`${H}__list`,f.setAttribute("role","log"),f.setAttribute("aria-live","polite");const h=t.createElement("form");h.className=`${H}__composer`;const g=t.createElement("textarea");g.className=`${H}__input`,g.rows=2,g.setAttribute("aria-label",this.#f("comments.write"));const w=t.createElement("button");w.className=`${H}__send`,w.type="submit",w.textContent=this.#f("comments.post"),h.appendChild(g),h.appendChild(w),n.appendChild(i),n.appendChild(f),n.appendChild(h),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(n),this.#n=n,this.#r=f,this.#o=g,this.#p=s,this.#g=c;const p=l=>{l.preventDefault();const a=String(g.value||"").trim();a&&(g.value="",this.#e.comments.add(a))},m=()=>this.#e.comments.close(),b=()=>{this.#v()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=l=>{if(l.stopPropagation(),l.key==="Escape"){l.preventDefault(),this.#e.comments.close();return}if(l.key!=="Tab")return;const a=[...n.querySelectorAll(k)].filter(M=>M.offsetParent!==null||M===g);if(!a.length)return;const O=a[0],T=a[a.length-1],A=n.ownerDocument.activeElement;l.shiftKey&&A===O?(l.preventDefault(),T.focus()):!l.shiftKey&&A===T&&(l.preventDefault(),O.focus())};h.addEventListener("submit",p),d.addEventListener("click",m),c.addEventListener("click",b),n.addEventListener("keydown",v),this.#s.push(()=>{h.removeEventListener("submit",p),d.removeEventListener("click",m),c.removeEventListener("click",b),n.removeEventListener("keydown",v)})}#p=null;#g=null;#v(){return(this.#e.comments.thread||[]).filter(n=>!n.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const n=this.#n.ownerDocument,i=this.#e.get("comments")||{},s=Date.now(),c=t.openKey,{rowId:d,field:f}=B(c),h=this.#e.columns.get(f),g=this.#e.rows.byKey(d),w=N(i.rowLabel)&&g?i.rowLabel(g):d;if(this.#p.textContent=this.#f("comments.cellTitle",{column:h&&(h.title??h.id)||f,row:w}),this.#g.textContent=this.#v()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const p=t.thread||[];if(!p.length){this.#d(this.#f("comments.empty"));return}const m=g&&h?h.getValue(g.data,g):void 0;for(const b of p)this.#r.appendChild(this.#y(n,b,s,m,i))}#y(t,n,i,s,c){const d=t.createElement("article");d.className=`${H}__item`,n.pending&&d.setAttribute("data-pending","true"),n.resolved&&d.setAttribute("data-resolved","true");const f=t.createElement("div");f.className=`${H}__meta`;const h=t.createElement("span");h.className=`${H}__author`,h.textContent=n.author&&(n.author.name||n.author.initials)||this.#f("comments.unknownAuthor"),f.appendChild(h);const g=t.createElement("time");g.className=`${H}__time`;const w=S(n.at,i);g.textContent=n.edited?this.#f("comments.edited",{time:w}):w,f.appendChild(g),d.appendChild(f);const p=t.createElement("div");if(p.className=`${H}__body`,y(t,p,n.body,!!c.markdown),d.appendChild(p),n.value!==void 0&&!Object.is(n.value,s)){const v=t.createElement("p");v.className=`${H}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(n.value),now:String(s)}),d.appendChild(v)}const m=n.can||{},b=v=>m[v]!==!1;if(b("edit")||b("delete")){const v=t.createElement("div");if(v.className=`${H}__actions`,b("delete")){const l=t.createElement("button");l.type="button",l.className=`${H}__action`,l.textContent=this.#f("comments.delete"),l.addEventListener("click",()=>this.#e.comments.remove(n.id)),v.appendChild(l)}d.appendChild(v)}return d}#w(){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 n=this.#e.comments.openKey,{rowId:i,field:s}=B(n),c=this.#h(i,s)||this.#i,d=this.#t.viewport?.root;if(!c||!d||!N(c.getBoundingClientRect))return;const f=c.getBoundingClientRect(),h=d.getBoundingClientRect(),g=this.#n.getBoundingClientRect();let w=f.bottom-h.top+4;w+g.height>h.height&&f.top-h.top>g.height&&(w=f.top-h.top-g.height-4);let p=f.left-h.left;p+g.width>h.width&&(p=Math.max(0,h.width-g.width-4)),this.#n.style.top=`${Math.max(0,w)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const m=f.bottom<h.top||f.top>h.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const t of this.#s)t();this.#s=[],this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const o=u}),ve("packages/dom/src/watermark.js",function(e,V){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,U=W.on,B="lat-watermark",H="https://www.latticegrid.dev",L=["br","bl","tl","tr"],k=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#a=0;#s=null;constructor(o){this.#e=o.grid,this.#t=o.document,this.#n=o.element,this.#i=o.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),N(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const o=this.#e.licence&&this.#e.licence.ready;o&&N(o.then)&&o.then(()=>this.refresh(),()=>this.refresh())}refresh(){const o=this.#d();o&&!this.#r?(this.#h(),this.#u()):!o&&this.#r&&(this.#f(),this.#c())}#l(){const o=this.#i;if(!o||!N(o.matchMedia))return!1;try{return!!o.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),N(this.#i.setTimeout)&&(this.#l()||(this.#s=this.#i.setTimeout(()=>{if(this.#s=null,!this.#d()){this.#f();return}this.#a=(this.#a+1)%L.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#s!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#s),this.#s=null}#d(){const o=this.#e.licence;return!!(o&&N(o.watermark)&&o.watermark())}#h(){const o=_(this.#t,"a",{class:`${B}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}});this.#r=_(this.#t,"div",{class:`${B} ${B}--${L[this.#a]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o]}),this.#o.push(U(this.#r,"pointerdown",r=>{N(r.stopPropagation)&&r.stopPropagation()})),this.#n&&N(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const o of this.#o)o();this.#o=[],this.#f()}}const y=S}),ve("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const Z=V("packages/core/src/internal/util.js"),N=Z.warnOnce,z=Z.isFunction,F=V("packages/dom/src/editors/common.js"),W=F.el,_=F.on,U="lat-maximised",B={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"},H="lat-maximised-host",L="lat-maximise-placeholder";class k{#e;#t;#n;#r;#o;#i=null;#a=null;#s=new Set;#l=null;#u=null;constructor(u){this.#e=u.element,this.#t=u.document,this.#n=z(u.onChange)?u.onChange:null,this.#r=z(u.captureScroll)?u.captureScroll:null,this.#o=z(u.restoreScroll)?u.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const u=this.#e.parentNode;if(!u||!this.#t.body)return N("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:L}),this.#i.style.visibility="hidden";const o=this.#e.offsetWidth,r=this.#e.offsetHeight;o&&(this.#i.style.width=`${o}px`),r&&(this.#i.style.height=`${r}px`);const t=this.#r?this.#r():null;u.insertBefore(this.#i,this.#e),this.#c(()=>this.#t.body.appendChild(this.#e)),this.#l={};for(const[n,i]of Object.entries(B))this.#l[n]=this.#e.style[n]||"",this.#e.style[n]=i;return this.#u=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(H),t&&this.#o&&this.#o(t),this.#a=_(this.#t,"keydown",n=>this.#d(n)),this.#h(),!0}exit(){if(!this.active())return!1;const u=this.#r?this.#r():null,o=this.#i,r=o.parentNode;if(r&&z(r.insertBefore)&&this.#c(()=>r.insertBefore(this.#e,o)),z(o.remove)&&o.remove(),this.#i=null,this.#l){for(const[t,n]of Object.entries(this.#l))this.#e.style[t]=n;this.#l=null}return this.#u!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#u),this.#u=null,this.#e.classList.remove(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(H),u&&this.#o&&this.#o(u),this.#a&&this.#a(),this.#a=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#c(u){const o=this.#t.activeElement,r=o&&o!==this.#t.body&&z(this.#e.contains)&&this.#e.contains(o)?o:null;u(),r&&z(r.focus)&&r.focus()}#d(u){!u||u.key!=="Escape"||u.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const u of this.#s)u(this.active())}watch(u){return z(u)?(this.#s.add(u),()=>this.#s.delete(u)):()=>{}}destroy(){this.exit()}}const S=k}),ve("packages/dom/src/promptbar.js",function(e,V){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return n}});const Z=V("packages/dom/src/editors/common.js"),N=Z.documentFor,z=Z.el,F=Z.on,W=Z.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/ai/schema.js"),k=L.describeGrid,S=L.promptText,y=V("packages/core/src/ai/intent.js"),u=y.applyPlan,o=y.buildPrompt,r=y.planIntent,t="lat-prompt";class n{#e;#t=null;#n=null;#r={};#o;#i={};#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#v="idle";#b=0;#y=!1;#w=[];t(d,f){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(d,f)}init(d={}){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||U,this.#e=N(d),this.#t=d.grid||null,this.#n=H(d.ask)?d.ask:null,this.#r=d.schemaOptions||{},this.#o=d.context,this.#i={onPlan:H(d.onPlan)?d.onPlan:null,onApply:H(d.onApply)?d.onApply:null,onError:H(d.onError)?d.onError:null},this.#a=z(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(d)}element(){return this.#a}refresh(){this.#y||!this.#a||this.#v!=="busy"&&this.#C()}destroy(){this.#y=!0,this.#b++;for(const d of this.#w)d();this.#w.length=0,this.#g=null,this.#a=null,this.#s=null,this.#l=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(d){if(this.#y||this.#v==="busy")return null;const f=String(d??(this.#s&&this.#s.value)??"").trim();if(!f)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const h=++this.#b;this.#j("busy"),this.#E("Thinking…");let g;try{const w=k(this.#t,this.#r),p=S(w);if(g=await this.#n({prompt:f,schema:w,schemaText:p,message:o(f,p),context:this.#o}),this.#y||h!==this.#b)return null;const m=r(g,w);return this.#A(m),m}catch(w){return this.#y||h!==this.#b||(this.#i.onError&&this.#i.onError(w),this.#T(w instanceof Error?w.message:String(w))),null}}apply(){const d=this.#g;if(this.#y||!d||!d.ok)return null;const f=this.#t?.ai,h=H(f?.apply)?f.apply(d):u(d,this.#t);return this.#i.onApply&&this.#i.onApply(h,d),this.#C(),this.#s&&(this.#s.value=""),h.failed.length?this.#T(`Applied ${h.applied.length}; ${h.failed.map(g=>`${g.type} failed: ${g.reason}`).join("; ")}`):this.#E(`Applied: ${d.describe()}`),h}discard(){this.#y||(this.#C(),this.#E("Discarded."))}#S(d){const f=this.#e,h=z(f,"div",{class:`${t}__row`});this.#s=z(f,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:d.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":d.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push(F(this.#s,"keydown",w=>{const p=w&&w.key;p==="Enter"?(H(w.preventDefault)&&w.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(H(w.preventDefault)&&w.preventDefault(),this.discard())})),h.appendChild(this.#s),this.#l=z(f,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(F(this.#l,"click",()=>{this.ask()})),h.appendChild(this.#l),this.#a.appendChild(h),this.#u=z(f,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=z(f,"p",{class:`${t}__summary`}),this.#d=z(f,"ul",{class:`${t}__notes`});const g=z(f,"div",{class:`${t}__buttons`});this.#h=z(f,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=z(f,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(F(this.#h,"click",()=>{this.apply()})),this.#w.push(F(this.#f,"click",()=>{this.discard()})),g.appendChild(this.#h),g.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(g),this.#a.appendChild(this.#u),this.#m=z(f,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=z(f,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#a.appendChild(this.#m),this.#a.appendChild(this.#p)}#j(d){if(this.#v=d,!this.#a)return;this.#a.setAttribute("data-state",d);const f=d==="busy";i(this.#s,f),i(this.#l,f),this.#l&&(this.#l.textContent=this.t(f?"prompt.asking":"prompt.ask")),s(this.#u,d!=="preview"),s(this.#p,d!=="error")}#A(d){const f=d;if(this.#i.onPlan&&this.#i.onPlan(d),!f.ok){this.#g=null;const h=f.rejected.length?f.rejected.map(g=>g.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${h}`);return}this.#g=d,this.#E(""),this.#c&&(this.#c.textContent=f.describe()),this.#O(f.rejected),this.#j("preview")}#O(d){const f=this.#d;if(f){W(f),s(f,!d.length);for(const h of d.slice(0,6))f.appendChild(z(this.#e,"li",{class:`${t}__note`,text:h.reason}));d.length>6&&f.appendChild(z(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:d.length-6})}))}}#C(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#E(d){this.#m&&(this.#m.textContent=d)}#T(d){this.#g=null,this.#E(""),this.#p&&(this.#p.textContent=d),this.#j("error")}}function i(c,d){c&&(c.disabled=d,d?c.setAttribute("disabled",""):c.removeAttribute("disabled"))}function s(c,d){c&&(c.hidden=d,d?c.setAttribute("hidden",""):c.removeAttribute("hidden"))}}),ve("packages/dom/src/stat.js",function(e,V){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return d}});const Z=V("packages/core/src/internal/util.js"),N=Z.isFunction,z=Z.isObject,F=Z.warnOnce,_=V("packages/core/src/source/derive.js").reduceValues,B=V("packages/core/src/source/memory.js").isPipelineSettle,L=V("packages/core/src/i18n/index.js").defaultMessages,S=V("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",o=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),r=Object.freeze({direction:"flat",change:null,percent:null});function t(p,m){if(!Number.isFinite(p)||!Number.isFinite(m))return r;const b=p-m,v=b>0?"up":b<0?"down":"flat",l=m===0?null:b/Math.abs(m)*100;return{direction:v,change:b,percent:l}}function n(p,m){return p==="flat"||m==="neither"?"flat":p===m?"good":"bad"}function i(p,m,b=null){if(N(m)){const A=m(p,b);return A==="good"||A==="warn"||A==="bad"?A:null}if(!z(m))return null;const v=typeof p=="number"&&Number.isFinite(p)?p:null;if(v===null)return null;const l=Number.isFinite(Number(m.good))?Number(m.good):null,a=Number.isFinite(Number(m.warn))?Number(m.warn):null,O=String(m.direction||"up")==="down",T=A=>O?v<=A:v>=A;return l!==null&&T(l)?"good":a!==null&&T(a)?"warn":l===null&&a===null?null:"bad"}function s(p){return!(N(p.value)||p.value!==void 0&&!z(p.value))}function c(p){return!p||!p.rows||!N(p.rows.totalCount)?!0:p.rows.totalCount()>0}function d(p){const m=z(p)?p:{},b=m.grid||null,v=g(m.container,b);if(!v)return F("stat.container","createStat needs a `container`: an element or a selector."),w();const l=v.ownerDocument||(typeof document>"u"?null:document);if(!l)return F("stat.document","createStat needs a document; it draws DOM."),w();const a=l.createElement("div");a.className=["lattice",y.root,m.class].filter(Boolean).join(" "),a.setAttribute("role","group");const O=l.createElement("div");O.className=y.title;const T=l.createElement("div");T.className=y.value;const A=l.createElement("div");A.className=y.interval;const M=l.createElement("div");M.className=y.delta;const C=l.createElement("div");C.className=y.footer;const P=l.createElement("div");if(P.className=y.note,P.hidden=!0,m.icon!=null&&m.icon!==""){const ne=l.createElement("span");ne.className=y.icon,ne.setAttribute("aria-hidden","true"),S(ne,m.icon,`stat:${m.title||"stat"}`),a.appendChild(ne);const re=l.createElement("div");re.className=y.body,re.appendChild(O),re.appendChild(T),re.appendChild(P),re.appendChild(A),re.appendChild(M),re.appendChild(C),a.appendChild(re)}else a.appendChild(O),a.appendChild(T),a.appendChild(P),a.appendChild(A),a.appendChild(M),a.appendChild(C);v.appendChild(a);let K=null;const I=[];let D=!1;function j(){if(N(m.value))return m.value(b);if(m.value!==void 0&&!z(m.value))return m.value;const ne=z(m.value)?m.value:m,re=ne.of,oe=ne.fn||"sum",ie=ne.show;return b?oe==="count"?$().length:re?ie?q(String(re),String(oe),String(ie)):E()==="filtered"&&b.statistics&&N(b.statistics.reduce)?b.statistics.reduce(String(re),String(oe)):_($().map(te=>h(te,String(re))),String(oe)):null:null}function E(){return String(m.scope||"filtered")}function $(){if(!b||!b.rows)return[];const ne=E();if(ne==="all"){const oe=[];return N(b.rows.forEachAll)&&b.rows.forEachAll(ie=>{ie.group||oe.push(f(ie))}),oe}if(ne==="selected")return(b.selection&&N(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(f);const re=[];return N(b.rows.forEach)&&b.rows.forEach(oe=>{oe.group||re.push(f(oe))}),re}function q(ne,re,oe){if(re!=="min"&&re!=="max")return F(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ie=null,te=null;for(const ce of $()){const ue=Number(h(ce,ne));Number.isFinite(ue)&&(ie===null||(re==="max"?ue>ie:ue<ie))&&(ie=ue,te=ce)}return te===null?null:h(te,oe)}function X(ne){if(N(m.format))return String(m.format(ne,b));if(ne==null)return m.empty??"—";const re=z(m.value)?m.value:m,oe=re.show||re.of;if((re.show?!0:o.has(String(re.fn||"sum")))&&b&&oe&&N(b.columns?.get)){const te=b.columns.get(String(oe));if(te&&N(te.formatValue))return te.formatValue(ne)}return typeof ne=="number"?Number.isInteger(ne)?String(ne):ne.toFixed(m.decimals??2):String(ne)}function Q(ne){return ne?(b&&b.messages||L).t(`stat.tone.${ne}`):""}function J(){if(D)return;const ne=j(),re=s(m)&&!!b&&!c(b),oe=re?null:ne,ie=N(m.baseline)?m.baseline(b):m.baseline;K=oe,O.textContent=m.title??"",O.hidden=!m.title,T.textContent=X(oe),P.hidden=!re,re&&(P.textContent=b.messages.t("stat.noData"));const te=re||ie===void 0||ie===null?r:t(typeof oe=="number"?oe:null,Number(ie)),ce=n(te.direction,m.goodWhen||"up");if(M.hidden=te.change===null,te.change!==null){const he=te.direction==="up"?"↑":te.direction==="down"?"↓":"→",ke=te.percent===null?X(Math.abs(te.change)):`${Math.abs(te.percent).toFixed(1)}%`;M.textContent=`${he} ${ke}`,M.setAttribute("data-tone",ce),M.setAttribute("data-direction",te.direction)}const ue=N(m.interval)?m.interval(oe,b):null,ae=!!ue&&Number.isFinite(ue.lower)&&Number.isFinite(ue.upper);A.hidden=!ae,ae&&(A.textContent=`${X(ue.lower)} – ${X(ue.upper)}`,Number.isFinite(ue.confidence)&&A.setAttribute("title",`${Math.round(ue.confidence*100)}%`));const pe=re?u:m.bands?i(oe,m.bands,b):null;pe?a.setAttribute("data-tone",pe):a.removeAttribute("data-tone"),C.textContent=N(m.footer)?String(m.footer(oe,b)):m.footer??"",C.hidden=!C.textContent,a.setAttribute("aria-label",[m.title,T.textContent,re?P.textContent:"",ae?A.textContent:"",te.change===null?"":M.textContent,te.change===null?"":Q(ce),C.textContent].filter(Boolean).join(", "))}if(b&&N(b.on)&&m.live!==!1)for(const ne of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=oe=>{ne==="model:changed"&&!B(oe)||J()};b.on(ne,re),I.push(()=>N(b.off)&&b.off(ne,re))}return J(),{element:()=>a,value:()=>K,refresh:J,destroy(){D=!0;for(const ne of I)try{ne()}catch{}I.length=0,a.remove()}}}function f(p){return z(p)&&"data"in p?p.data:p}function h(p,m){if(!z(p))return;if(!m.includes("."))return p[m];let b=p;for(const v of m.split(".")){if(!z(b))return;b=b[v]}return b}function g(p,m){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const b=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(p):null}function w(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),ve("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return _}});const N=V("packages/core/src/internal/util.js").isObject,F=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class _{#e;#t;#n;#r=null;#o=[];constructor({grid:B,document:H,kpis:L}){this.#e=B,this.#t=H,this.#n=Array.isArray(L)?L.filter(N):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${W.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const L of this.#n){const k=F({...L,grid:this.#e,container:H});this.#o.push(k)}}destroy(){for(const B of this.#o)try{B.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),ve("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const N=V("packages/core/src/index.js").createHeadlessGrid,F=V("packages/core/src/defaults.js").applyDefaults,_=V("packages/core/src/export/download.js").downloadBlob,U=V("packages/core/src/internal/util.js"),B=U.fail,H=U.isFunction,L=U.warnOnce,S=V("packages/dom/src/localviews.js").createLocalViewStorage,u=V("packages/dom/src/renderer/index.js").DomRenderer,r=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),n=t.icon,i=t.iconNames,c=V("packages/dom/src/editors/index.js").editors,f=V("packages/dom/src/filters/index.js").filters,h=V("packages/dom/src/ui/index.js"),g=h.StatusBar,w=h.TooltipManager,p=h.Pagination,m=h.GroupByZone,v=V("packages/dom/src/ui/celltooltip.js").CellTooltips,a=V("packages/dom/src/filtermenu.js").FilterMenu,T=V("packages/dom/src/columnmenu.js").ColumnMenu,M=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,K=V("packages/dom/src/alignedgrids.js").AlignedGrids,D=V("packages/dom/src/columntagbar.js").ColumnTagBar,E=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,X=V("packages/dom/src/toolpanelmount.js"),Q=X.ToolPanelDock,J=X.panelHost,re=V("packages/dom/src/celledit.js").CellEditController,ie=V("packages/dom/src/editbar.js").EditBar,ce=V("packages/dom/src/rangeselect.js").RangeController,ae=V("packages/core/src/model/selection.js").resolveSelectionConfig,he=V("packages/dom/src/importer.js").ImportController,Oe=V("packages/dom/src/historybar.js").HistoryBar,_e=V("packages/dom/src/diffpaint.js").DiffPainter,xe=V("packages/dom/src/detailhost.js").DetailHost,qe=V("packages/dom/src/highlightpaint.js").HighlightPainter,Je=V("packages/dom/src/findpaint.js").FindPainter,Ae=V("packages/dom/src/findbar.js").FindBar,Ve=V("packages/dom/src/redactpaint.js").RedactionPainter,lt=V("packages/dom/src/validationpaint.js").ValidationPainter,Pt=V("packages/dom/src/presentation.js").PresentationController,Rt=V("packages/dom/src/capture.js").captureElement,zt=V("packages/dom/src/annotate.js").AnnotationLayer,Qt=V("packages/dom/src/timelinebar.js").TimelineBar,de=V("packages/dom/src/commentpaint.js").CommentPainter,Te=V("packages/dom/src/presencepaint.js").PresencePainter,He=V("packages/dom/src/commentpanel.js").CommentPanel,dt=V("packages/dom/src/watermark.js").Watermark,we=V("packages/dom/src/maximise.js").Maximiser,je=V("packages/dom/src/promptbar.js").PromptBar,Ne=V("packages/dom/src/kpistrip.js").KpiStrip;function Re(Ee,tt,rt){const ht=tt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?Ee(ht):Ee(tt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Fe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Le=2e3;function Ze(Ee,tt,rt){const ht=tt.annotate===!0?Ye(Ee):[];if(tt.actions===!1)return[];if(tt.actions===void 0&&tt.side!=="left")return ht;const Dt=Array.isArray(tt.actions)?tt.actions:Fe,Nt=(vt,Ht)=>Ee.messages.t(vt,Ht),ot={undo:{name:"undo",title:()=>Re(Nt,"undo",Ee.history.peek("undo")),icon:"undo",run:()=>Ee.history.undo(),enabled:()=>Ee.history.canUndo()},redo:{name:"redo",title:()=>Re(Nt,"redo",Ee.history.peek("redo")),icon:"redo",run:()=>Ee.history.redo(),enabled:()=>Ee.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Ee.export.csv({download:!0,fileName:tt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ee.export.excel({download:!0,fileName:tt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Ee.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Ee.export.print()},pause:{name:"pause",title:()=>{if(!Ee.updates.paused)return Nt("toolbar.pause");const vt=Ee.updates.stats().pending;return vt?Nt("toolbar.applyHeld",{count:vt}):Nt("toolbar.resume")},icon:()=>Ee.updates.paused?"play":"pause",run:()=>Ee.updates.paused?Ee.updates.resume():Ee.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Ee.state.reset(),enabled:()=>Ee.state.modified()},maximise:{name:"maximise",title:()=>Nt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete ot.maximise,Dt.map(vt=>vt==="-"?{name:"-",separator:!0}:typeof vt=="string"?ot[vt]:!vt||typeof vt!="object"||!vt.name?null:{...vt,run:H(vt.run)?()=>vt.run({grid:Ee,keys:Ee.selection&&H(Ee.selection.keys)?Ee.selection.keys():[],cells:Ee.selection&&H(Ee.selection.cells)?Ee.selection.cells():[]}):void 0}).filter(Boolean).concat(ht)}function Ye(Ee){const tt=ht=>Ee.messages.t(ht),rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(ht=>({name:ht,title:()=>tt(`toolbar.annotate.${ht}`),icon:rt[ht],run:()=>Ee.annotate?.use(ht),active:()=>Ee.annotate?.tool===ht,annotation:!0}))}const mt=["pen","arrow","rect","highlight"];function pt(Ee){return{rowCount:()=>{if(H(Ee.rows.matchCount))return Ee.rows.matchCount();const tt=Ee.pagination&&H(Ee.pagination.get)?Ee.pagination.get():null;return tt&&Number.isFinite(tt.total)?tt.total:Ee.rows.count()},totalRowCount:()=>H(Ee.rows.totalCount)?Ee.rows.totalCount():Ee.rows.count(),selectedCount:()=>{const tt=Ee.selection&&Ee.selection.keys?Ee.selection.keys():null;return tt?tt.length:0},rangeValues:()=>{const tt=Ee.selection;return!tt||!H(tt.cells)?[]:tt.cells().map(({key:rt,colId:ht})=>Ee.rows.value(rt,ht))},hiddenUnresolved:()=>H(Ee.comments&&Ee.comments.hiddenUnresolved)?Ee.comments.hiddenUnresolved():0,progress:()=>H(Ee.source&&Ee.source.progress)?Ee.source.progress():null,updateStats:()=>Ee.updates?Ee.updates.stats():null}}function yt(Ee,tt){for(const[rt,ht]of Object.entries(c||{}))Ee.register("editor",rt,ht);for(const[rt,ht]of Object.entries(f||{}))Ee.register("filter",rt,ht);for(const[rt,ht]of Object.entries(tt.components||{}))Ee.register("component",rt,ht);for(const[rt,ht]of Object.entries(tt.pipes||{}))Ee.register("pipe",rt,ht);for(const[rt,ht]of Object.entries(tt.totalFns||{}))Ee.register("totalFn",rt,ht)}function ft(Ee,tt,rt,ht,Dt,Nt){const ot=[],vt=tt.viewport;let Ht=null;if(rt.maximise!==!1&&(Ht=new we({element:Nt,document:ht,onChange:()=>tt.invalidate("all"),captureScroll:()=>tt.scrollState(),restoreScroll:Xe=>tt.restoreScroll(Xe)}),Ee.maximise=Ht,ot.push(()=>Ht.destroy())),rt.statusBar){const Xe=typeof rt.statusBar=="object"?rt.statusBar:{},st=new g;st.init({document:ht,host:pt(Ee),panels:Xe.panels,registry:Xe.registry,locale:Ee.get("locale"),messages:Ee.messages}),vt.statusBar.appendChild(st.element());const Ot=()=>{const tn=vt.statusBar.offsetHeight||vt.statusBar.getBoundingClientRect?.().height||0;vt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Ft=()=>{st.refresh(),Ot()},Ut=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>Ee.on(tn,Ft));Ft(),Ot(),ot.push(()=>{for(const tn of Ut)tn();vt.root.style.removeProperty("--lattice-status-height"),st.destroy?.()})}const Gt=ae(rt.selection);if(Gt.ranges){const Xe=new ce({grid:Ee,renderer:tt,document:ht});Xe.mount(),Ee.ranges=Xe,ot.push(()=>Xe.destroy())}if(rt.import){const Xe=new he({grid:Ee,renderer:tt,document:ht,settings:typeof rt.import=="object"?rt.import:{}});Ee.importer=Xe,ot.push(()=>Xe.destroy())}if(rt.historyBar){const Xe=typeof rt.historyBar=="object"?rt.historyBar.element:null,st=new Oe;st.init({document:ht,host:{undo:()=>Ee.history.undo(),redo:()=>Ee.history.redo(),canUndo:()=>Ee.history.canUndo(),canRedo:()=>Ee.history.canRedo(),peek:Ft=>Ee.history.peek(Ft),list:()=>Ee.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(Xe||vt.root).appendChild(st.element());const Ot=[Ee.on("history:changed",()=>st.refresh())];Ee.historyBar=st,ot.push(()=>{for(const Ft of Ot)Ft();st.destroy()})}if(rt.diff){const Xe=new _e({grid:Ee,renderer:tt});Xe.mount(),Ee.diffPainter=Xe,ot.push(()=>Xe.destroy())}if(rt.ai&&H(rt.ai.ask)){const Xe=new je;Xe.init({document:ht,grid:Ee,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const st=rt.ai.element||vt.root;st===vt.root?st.insertBefore(Xe.element(),st.firstChild):st.appendChild(Xe.element()),Ee.promptBar=Xe,ot.push(()=>Xe.destroy())}if(rt.groupPanel){const Xe=typeof rt.groupPanel=="object"?rt.groupPanel:{},st=new m;st.init({document:ht,grid:Ee,host:J(Ee,ht,(Ot,Ft)=>tt.announce?.(Ot,Ft)),props:{header:vt.header,hint:Xe.hint}}),vt.root.insertBefore(st.element(),vt.header),Ee.groupPanel=st;for(const Ot of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ee.on)&&ot.push(Ee.on(Ot,()=>st.refresh()));ot.push(()=>st.destroy())}if(rt.kpis){const Xe=new Ne({grid:Ee,document:ht,kpis:rt.kpis});Xe.active&&(Xe.mount(),vt.root.insertBefore(Xe.element(),vt.header),Ee.kpiStrip=Xe,ot.push(()=>Xe.destroy()))}if(rt.toolPanel){const Xe=typeof rt.toolPanel=="object"?rt.toolPanel:{},st=new Q({grid:Ee,document:ht,root:vt.root,panels:Xe.panels,openPanel:Xe.openPanel,side:Xe.side,icons:Xe.icons,actions:Ze(Ee,Xe,Ht),announce:(Ot,Ft)=>tt.announce?.(Ot,Ft)});st.mount(),Ee.toolPanel=st,ot.push(()=>st.destroy()),Xe.annotate===void 0&&(ot.push(Ee.on("presentation:started",()=>{for(const Ot of Ye(Ee))st.addAction(Ot)})),ot.push(Ee.on("presentation:ended",()=>{for(const Ot of mt)st.removeAction(Ot)})))}if(rt.pagination){const Xe=typeof rt.pagination=="object"?rt.pagination:{},st=new p;st.init({document:ht,pageSize:Xe.pageSize,pageSizes:Xe.pageSizes,page:Xe.page,total:Xe.total,locale:Ee.get("locale"),messages:Ee.messages,onChange:({page:Ut,pageSize:tn})=>Ee.pagination.set({page:Ut,pageSize:tn})});const Ot=()=>{const Ut=Ee.pagination.get();st.total=Ut.total,st.counting=Ut.counting===!0,st.page=Ut.page,st.paint()};Ee.pagination.set({pageSize:st.pageSize}),Ot();const Ft=["rows:changed","filter:changed","model:changed"].map(Ut=>Ee.on(Ut,Ot));vt.statusBar.appendChild(st.element()),ot.push(()=>{for(const Ut of Ft)Ut();st.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const Xe=new ie({grid:Ee,document:ht,root:vt.root});Xe.mount(),Ee.editBar=Xe,ot.push(()=>Xe.destroy())}else{const Xe=new re({grid:Ee,document:ht,renderer:tt,registry:Dt,cellLayer:tt.cellLayer});Xe.mount(),ot.push(()=>Xe.destroy())}const sn=new a({grid:Ee,document:ht,layer:vt.overlays,registry:Dt});sn.mount(),ot.push(()=>sn.destroy());const an=new T({grid:Ee,document:ht,host:vt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:H(rt.contextMenu)?rt.contextMenu:void 0,headerItems:H(rt.columnMenu)?rt.columnMenu:void 0});if(an.mount(),ot.push(()=>an.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const Xe=new K;Xe.add(Ee);for(const st of rt.alignedGrids)st&&st!==Ee&&Xe.add(st);ot.push(()=>Xe.destroy())}const xt=new q({grid:Ee,renderer:tt,document:ht,registry:Dt});xt.active&&(xt.mount(),ot.push(()=>xt.destroy())),Object.defineProperty(Ee,"form",{configurable:!0,value:Object.freeze({open(Xe){return xt.active?xt.openRow(Xe):!1},close(){xt.active&&xt.close()},save(){return xt.active?xt.save():!1},isOpen(){return xt.active?xt.open:!1}})}),ot.push(()=>{delete Ee.form}),Object.defineProperty(Ee,"icons",{configurable:!0,value:Object.freeze({get(Xe){const st=n(Xe);return st?{viewBox:st.viewBox,paths:st.paths.slice(),paint:st.paint==="stroke"?"stroke":"fill"}:null},names(){return i()}})}),ot.push(()=>{delete Ee.icons});const ln=new D({grid:Ee,renderer:tt,document:ht});ln.active&&(ln.mount(),ot.push(()=>ln.destroy()));const un=new E({grid:Ee,renderer:tt,document:ht});un.active&&(un.mount(),ot.push(()=>un.destroy()));const nn=new P({grid:Ee,renderer:tt,document:ht});if(nn.active){nn.mount(),nn.paint();const Xe=Ee.on("render:done",()=>nn.paint());ot.push(()=>{Xe(),nn.destroy()})}if(rt.shortcuts!==!1){const Xe=new M({grid:Ee,renderer:tt});Xe.mount(),ot.push(()=>Xe.destroy())}const bt=new qe({grid:Ee,renderer:tt,window:ht.defaultView||void 0});bt.mount(),ot.push(()=>bt.destroy());const Ct=new Je({grid:Ee,renderer:tt,window:ht.defaultView||void 0});if(Ct.mount(),ot.push(()=>Ct.destroy()),rt.find!==!1){const Xe=new Ae({grid:Ee,renderer:tt,document:ht,settings:rt.find});Xe.mount(),ot.push(()=>Xe.destroy())}const Tt=new Ve({grid:Ee,renderer:tt});Tt.mount(),ot.push(()=>Tt.destroy());const Bt=new lt({grid:Ee,renderer:tt});Bt.mount(),ot.push(()=>Bt.destroy());const Yt=new Pt({grid:Ee,renderer:tt,maximiser:Ht});Yt.mount(),ot.push(()=>Yt.destroy());const Kt=new Qt({grid:Ee,renderer:tt});Kt.mount(),ot.push(()=>Kt.destroy()),rt.environment||Ee.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 qt=null;for(const[Xe,st]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ot.push(Ee.on(Xe,()=>{qt=st}));ot.push(Ee.on("render:done",Xe=>{Ee.diagnostics.render(qt||Xe.cause,Xe.phases),qt=null}));const Jt=new Te({grid:Ee,renderer:tt});if(Jt.mount(),ot.push(()=>Jt.destroy()),ot.push(Ee.on("presence:lockRefused",Xe=>Jt.announceRefusal(Xe.peer))),Ee.presence&&Ee.presence.enabled){for(const Ot of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ot.push(Ee.on(Ot,()=>Ee.presence.publish()));let Xe="";ot.push(Ee.on("render:done",()=>{const Ot=tt.focusState&&tt.focusState(),Ft=Ot?`${Ot.rowKey}${Ot.colId}`:"";Ft!==Xe&&(Xe=Ft,Ee.presence.publish())}));const st=Nt.ownerDocument;if(st&&H(st.addEventListener)){const Ot=()=>Ee.presence.setPaused(st.visibilityState==="hidden");st.addEventListener("visibilitychange",Ot),Ot(),ot.push(()=>st.removeEventListener("visibilitychange",Ot))}}const Zt=new de({grid:Ee,renderer:tt});Zt.mount(),ot.push(()=>Zt.destroy());const cn=new He({grid:Ee,renderer:tt});cn.mount(),ot.push(()=>cn.destroy()),ot.push(Ee.on("facet:computed",()=>tt.refreshHeader?.())),Gt&&Gt.headerCheckbox===!0&&ot.push(Ee.on("selection:changed",()=>tt.refreshHeader?.())),ot.push(Ee.on("facet:expanded",()=>tt.invalidate("columns"))),ot.push(Ee.on("model:changed",()=>tt.invalidate("rows")));const Vt=(Xe,st)=>tt.announce?.(Xe,st),dn=Ee.messages,It=(Xe,st)=>dn.t(Xe,st),mn=Xe=>It("count.rows",{count:Xe});ot.push(Ee.on("sort:changed",()=>{const Xe=Ee.sort.get();if(!Xe.length){Vt(It("a11y.sort.cleared"));return}const st=Xe.map(Ot=>{const Ft=Ee.columns.get(Ot.col);return It("a11y.sort.column",{column:Ft&&Ft.title||Ot.col,direction:It(Ot.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Vt(It("a11y.sort.by",{columns:dn.list(st)}))})),ot.push(Ee.on("filter:changed",()=>{const Xe=Ee.rows.matchCount?Ee.rows.matchCount():Ee.rows.count(),st=Ee.rows.totalCount?Ee.rows.totalCount():Xe;Vt(Xe===st?It("a11y.filter.cleared",{rows:mn(st)}):It("a11y.filter.applied",{shown:mn(Xe),total:mn(st)}))})),ot.push(Ee.on("selection:changed",()=>{const Xe=Ee.selection.keys().length;Vt(Xe===0?It("a11y.selection.cleared"):It("a11y.selection.count",{count:Xe}))})),ot.push(Ee.on("group:toggled",Xe=>{const st=Ee.rows.byKey?Ee.rows.byKey(Xe.key):null,Ot=(st&&(st.groupLabel??st.groupValue))??Xe.key;Vt(It(Xe.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Ot,rows:mn(Ee.rows.count())}))})),ot.push(Ee.on("column:grouped",Xe=>{const st=Array.isArray(Xe.columns)?Xe.columns:[];if(!st.length){Vt(It("a11y.group.cleared"));return}const Ot=st.map(Ft=>{const Ut=Ee.columns.get(Ft);return Ut&&Ut.title||Ft});Vt(It("a11y.group.by",{columns:dn.list(Ot)}))})),ot.push(Ee.on("page:changed",Xe=>{const st=Number(Xe.size)||0,Ot=Number(Xe.total)||0,Ft=st>0?Math.max(1,Math.ceil(Ot/st)):1;Vt(It("a11y.page.position",{page:(Number(Xe.page)||0)+1,pages:Ft}))}));let en={added:0,removed:0},Wt=null;const Tn=()=>{Wt=null;const Xe=[];en.added&&Xe.push(It("count.rowsAdded",{count:en.added})),en.removed&&Xe.push(It("count.rowsRemoved",{count:en.removed})),en={added:0,removed:0},Xe.length&&Vt(dn.list(Xe))};ot.push(Ee.on("rows:changed",Xe=>{if(!Xe||typeof Xe.added!="number")return;const st=Number(Xe.added)||0,Ot=Number(Xe.removed)||0;!st&&!Ot||(en.added+=st,en.removed+=Ot,Wt||(Wt=setTimeout(Tn,Le)))})),ot.push(()=>{Wt&&clearTimeout(Wt)}),ot.push(Ee.on("rows:paused",()=>{Wt&&(clearTimeout(Wt),Wt=null),en={added:0,removed:0},Vt(It("a11y.updates.paused"),{repeat:!0})})),ot.push(Ee.on("rows:resumed",()=>Vt(It("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const kn=()=>{hn=null;const{count:Xe,first:st}=fn;if(fn={count:0,first:null},!Xe||!st)return;const Ot=Ee.columns.get(st.colId),Ft=Ot&&Ot.title||st.colId,Ut=st.reason?It("a11y.edit.reason",{reason:st.reason}):"";if(Xe===1){const tn=st.restored===void 0||st.restored===null||st.restored===""?It("value.empty"):String(st.restored);Vt(It("a11y.edit.refusedOne",{column:Ft,value:tn,reason:Ut}),{repeat:!0});return}Vt(It("a11y.edit.refusedMany",{count:Xe,reason:Ut}),{repeat:!0})};ot.push(Ee.on("cell:reverted",Xe=>{!Xe||!Xe.applied||(fn.count+=1,fn.first||(fn.first=Xe),hn||(hn=setTimeout(kn,150)))})),ot.push(()=>{hn&&clearTimeout(hn)}),ot.push(Ee.on("history:applied",Xe=>{const st=!!(Xe&&Xe.direction==="redo"),Ot=Xe&&Xe.step&&Xe.step.label;Vt(Ot?It(st?"a11y.history.redo":"a11y.history.undo",{label:Ot}):It(st?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const pn=new zt({grid:Ee,renderer:tt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});pn.mount(),ot.push(()=>pn.destroy()),Ee.annotate=pn,Ee.capture=async(Xe={})=>{const{blob:st,width:Ot,height:Ft}=await Rt(tt.viewport.root,Xe);return(Xe.download===!0||Xe.download!==!1&&Xe.fileName)&&_(st,Xe.fileName||`${Ee.get("exportName")||"grid"}.png`),Ee.emit("presentation:captured",{width:Ot,height:Ft,bytes:st.size,mimeType:st.type,fileName:Xe.fileName||null},"api"),st};const Sn=new dt({grid:Ee,document:ht,element:vt.overlays,window:ht.defaultView||void 0});Sn.mount(),ot.push(()=>Sn.destroy());const Mn=new w({grid:Ee,document:ht,element:vt.overlays});Mn.mount?.(),ot.push(()=>Mn.destroy?.());const On=new v({grid:Ee,host:Ee.rendererHost(),viewport:vt,document:ht});return On.mount(),ot.push(()=>On.destroy()),ot}function kt(Ee){const tt=[],rt=ht=>{if(ht&&(ht.__lattice&&tt.push(ht),ht.children))for(const Dt of ht.children)rt(Dt)};return rt(Ee),tt}function St(Ee,tt={}){(!Ee||typeof Ee!="object"||!("appendChild"in Ee))&&B("createGrid needs a host element as its first argument."),tt=F(tt);const rt=Ee.ownerDocument||(typeof document<"u"?document:null);rt||B("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ht=rt.documentElement&&rt.documentElement.lang,Dt=!tt.licence&&H(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...tt};if(!tt.locale&&ht&&(Nt.locale=ht),Dt&&(Nt.licence=Dt),tt.views&&tt.views.local)if(tt.views.storage)L("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const xt=tt.views.local===!0?{}:tt.views.local;Nt.views={...tt.views,storage:S(xt)}}const ot=N(Nt),vt=ot.rendererHost();vt.document=rt,yt(vt.registry,tt),vt.cellLayer=r(vt),vt.detailHost=new xe({grid:ot,document:Ee.ownerDocument||globalThis.document,createGrid:(xt,ln)=>St(xt,ln)});const Ht=new u(Ee,vt),Gt=ot.on("detail:toggled",()=>{vt.detailHost.syncTarget(),vt.detailHost.prune()}),on=ot.on("config:changed",xt=>{xt&&xt.key==="detail"&&vt.detailHost.reconfigure()});ot.on("destroy",()=>{Gt(),on(),vt.detailHost.destroy()}),vt.detailHost.syncTarget(),ot.attachRenderer(Ht),Ht.mount();const sn=ft(ot,Ht,tt,rt,vt.registry,Ee),an=ot.destroy.bind(ot);return ot.destroy=()=>{for(const xt of sn)try{xt()}catch{}Ee.__lattice===ot&&(Ee.__lattice=null),an()},Ee.__lattice=ot,ot}}),ve("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/createGrid.js").createGrid;function W(k,S){for(const y of k.children)if(y.tagName===S.toUpperCase())return y;return null}function _(k,S){const y=[];for(const u of k.children)u.tagName===S.toUpperCase()&&y.push(u);return y}function U(k,S){const y=N(k.getAttribute)?k.getAttribute("data-field"):null;return y||String(k.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${S}`}function B(k){const S=k.trim();if(S==="")return null;if(S==="true"||S==="false")return S==="true";const y=Number(S);return Number.isFinite(y)&&S!==""?y:S}function H(k){const S=W(k,"thead"),y=W(S||k,"tr"),o=(y?_(y,"th").length?_(y,"th"):_(y,"td"):[]).map((i,s)=>{const c=U(i,s);return{id:c,field:c,title:String(i.textContent||"").trim()||c}}),r=W(k,"tbody"),n=(r?_(r,"tr"):_(k,"tr").filter(i=>i!==y)).map((i,s)=>{const c=_(i,"td"),f={__row:(N(i.getAttribute)?i.getAttribute("data-id"):null)||`row${s}`};return o.forEach((h,g)=>{f[h.field]=c[g]?B(String(c[g].textContent||"")):null}),f});return{columns:o,rows:n}}function L(k,S={}){const{columns:y,rows:u}=H(k),o=k.ownerDocument.createElement("div");return k.parentNode.insertBefore(o,k),k.parentNode.removeChild(k),F(o,{rowKey:"__row",columns:y,rows:u,...S,columns:S.columns!==void 0?S.columns:y,rows:S.rows!==void 0?S.rows:u})}}),ve("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/createGrid.js").createGrid,_=V("packages/dom/src/hydrate.js").hydrateTable;function U(k,S){const y=[];return N(k.hasAttribute)&&k.hasAttribute(S)&&y.push(k),N(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${S}]`)),y}function B(k){const S=k.parentNode;if(!S||!S.children)return null;const y=[...S.children],u=y.indexOf(k),o=[y[u+1],y[u-1]];for(const r of o)if(r&&r.tagName==="SCRIPT"&&N(r.getAttribute)&&r.hasAttribute("data-lattice-config"))return r;return null}function H(k){const S=B(k);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function L(k){const S=k||(typeof document<"u"?document:null);if(!S)return[];const y=[];for(const u of U(S,"data-lattice-grid")){if(u.__lattice)continue;const o=H(u);y.push(u.tagName==="TABLE"?_(u,o):F(u,o))}return y}}),ve("packages/modules/htmx/controller.js",function(e,V){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return F}});const N=V("packages/core/src/internal/util.js").isFunction;function z(W,_){if(!W||!N(_))return 0;let U=0;for(const B of _(W))B.__lattice&&N(B.__lattice.destroy)&&(B.__lattice.destroy(),U+=1);return U}function F(W,_){return!W||!N(_)?[]:_(W)}}),ve("packages/modules/htmx/history.js",function(e,V){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return B}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/core/src/model/state.js"),F=z.serialiseState,W=z.restoreState;function _(H,L){const k=[];return H&&(N(H.hasAttribute)&&H.hasAttribute(L)&&k.push(H),N(H.querySelectorAll)&&k.push(...H.querySelectorAll(`[${L}]`))),k}function U(H,L){if(!H||!N(L))return 0;let k=0;for(const S of L(H))!S.__lattice||!N(S.setAttribute)||(S.setAttribute("data-lattice-state",F(S.__lattice)),k+=1);return k}function B(H,L){if(!H)return 0;const k=_(H,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of k)for(;y.firstChild;)y.removeChild(y.firstChild);k.length&&N(L)&&L(H);let S=0;for(const y of _(H,"data-lattice-state")){const u=N(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!u||!y.__lattice||(W(y.__lattice,u),S+=1)}return S}}),ve("packages/modules/htmx/rowmodel.js",function(e,V){"use strict";Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return L}});const Z=V("packages/dom/src/hydrate.js"),N=Z.coerceCell,z=Z.childTags,F=Z.firstChildTag,W=5e3;function _(k,S={}){const y=k.pagination.get(),u=S.limit??(y.pageSize||100);return{offset:S.offset??(y.page??0)*u,limit:u,sort:JSON.stringify(k.sort.get()),filters:JSON.stringify(k.filters.get())}}function U(k,S){let y;if(k.tagName==="TR")y=[k];else{const u=F(k,"tbody")||k;y=z(u,"tr").length?z(u,"tr"):z(k,"tr")}return y.map((u,o)=>{const r=z(u,"td"),n={__row:(typeof u.getAttribute=="function"?u.getAttribute("data-id"):null)||`row${o}`};return S.forEach((i,s)=>{n[i.field]=r[s]?N(String(r[s].textContent||"")):null}),n})}function B(k){const S=JSON.parse(k);return Array.isArray(S)?{rows:S,total:void 0}:{rows:S.rows||[],total:S.total}}function H(k){k<=W||console.warn(`lattice-grid/htmx: parsed ${k} rows from an HTML fragment, past the documented ${W}-row boundary for that path. Consider a JSON response for this size.`)}function L(k,S){if(/json/i.test(k.contentType||""))return B(k.text);const u=U(k.fragment,S);return H(u.length),{rows:u,total:void 0}}}),ve("packages/modules/htmx/oob.js",function(e,V){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isFunction,F=V("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(_,U={}){const B=U.doc||(typeof document<"u"?document:null);if(!B||!N(B.addEventListener))return()=>{};const H=L=>{const k=L.detail,S=k&&k.target,y=S&&N(S.getAttribute)?S.getAttribute("data-lattice-row"):null;if(!y||!k.fragment)return;const u=U.columns||_.columns.visible().map(r=>({field:r.field||r.id})),[o]=F(k.fragment,u);o&&(delete o.__row,_.rows.apply({update:[{...o,[_.get("rowKey")]:y}]})),k.shouldSwap=!1};return B.addEventListener("htmx:oobBeforeSwap",H),()=>B.removeEventListener("htmx:oobBeforeSwap",H)}}),ve("packages/modules/htmx/servermode.js",function(e,V){"use strict";Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return L}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/modules/htmx/rowmodel.js"),F=z.queryParams,W=z.ingestResponse,_="lattice:query-changed";function U(k,S){const y=k.createElement("tbody");if(N(k.createRange)){const u=k.createRange();u.selectNodeContents(y),y.appendChild(u.createContextualFragment(S))}return y}function B(k,S,y={}){const u=S.ownerDocument;let o=!1;const r=f=>{f.target!==S||!f.detail||!f.detail.parameters||Object.assign(f.detail.parameters,F(k,y))},t=f=>{f.target===S&&(o=!0)},n=f=>{if(o=!1,f.target!==S)return;const h=f.detail&&f.detail.xhr&&f.detail.xhr.status,g=h?`Could not load rows (server responded ${h}).`:"Could not load rows, the request failed to reach the server.";k.overlay.show("empty",g)},i=f=>{if(f.target!==S||(o=!1,f.detail&&(f.detail.shouldSwap=!1),!f.detail||!f.detail.xhr||f.detail.isError))return;const{xhr:h}=f.detail,g=N(h.getResponseHeader)&&h.getResponseHeader("Content-Type")||"",w=f.detail.serverResponse??h.responseText??"",p=y.columns||k.columns.visible().map(v=>({field:v.field||v.id})),m=/json/i.test(g)?null:U(u,w),{rows:b}=W({contentType:g,text:w,fragment:m},p);k.rows.load(b)},s=()=>{if(o&&N(S.dispatchEvent)){const h=u.defaultView&&u.defaultView.CustomEvent;S.dispatchEvent(h?new h("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const f=globalThis.htmx;f&&N(f.trigger)&&f.trigger(S,_)};u.addEventListener("htmx:configRequest",r),u.addEventListener("htmx:beforeRequest",t),u.addEventListener("htmx:beforeSwap",i),u.addEventListener("htmx:responseError",n),u.addEventListener("htmx:sendError",n);const c=k.on("sort:changed",s),d=k.on("filter:changed",s);return()=>{u.removeEventListener("htmx:configRequest",r),u.removeEventListener("htmx:beforeRequest",t),u.removeEventListener("htmx:beforeSwap",i),u.removeEventListener("htmx:responseError",n),u.removeEventListener("htmx:sendError",n),c(),d()}}const H="lattice:scroll-near-end";function L(k,S,y={}){const u=S.ownerDocument,o=y.threshold??20;let r=!1,t=!1;const n=l=>{l.target!==S||!l.detail||!l.detail.parameters||Object.assign(l.detail.parameters,F(k,{...y,offset:k.rows.count()}))},i=l=>{l.target===S&&(r=!0)},s=l=>{l.target===S&&(r=!1)},c=l=>{if(l.target!==S||(r=!1,l.detail&&(l.detail.shouldSwap=!1),!l.detail||!l.detail.xhr||l.detail.isError))return;const{xhr:a}=l.detail,O=N(a.getResponseHeader)&&a.getResponseHeader("Content-Type")||"",T=l.detail.serverResponse??a.responseText??"",A=y.columns||k.columns.visible().map(P=>({field:P.field||P.id})),M=/json/i.test(O)?null:U(u,T),{rows:C}=W({contentType:O,text:T,fragment:M},A);if(!C.length){t=!0;return}k.rows.apply({add:C})},d=()=>{t=!1},f=()=>{if(r||t)return;const l=globalThis.htmx;l&&N(l.trigger)&&l.trigger(S,H)};let h=!1;const g=()=>{h=!0},w=({last:l})=>{h&&(h=!1,(k.rows.count()===0||l>=k.rows.count()-1-o)&&f())};u.addEventListener("htmx:configRequest",n),u.addEventListener("htmx:beforeRequest",i),u.addEventListener("htmx:beforeSwap",c),u.addEventListener("htmx:responseError",s),u.addEventListener("htmx:sendError",s);const p=k.on("render:done",w),m=k.on("scroll",g),b=k.on("sort:changed",d),v=k.on("filter:changed",d);return()=>{u.removeEventListener("htmx:configRequest",n),u.removeEventListener("htmx:beforeRequest",i),u.removeEventListener("htmx:beforeSwap",c),u.removeEventListener("htmx:responseError",s),u.removeEventListener("htmx:sendError",s),p(),m(),b(),v()}}}),ve("packages/modules/htmx/index.js",function(e,V){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/createGrid.js"),F=z.gridElementsWithin,W=V("packages/dom/src/autoinit.js"),_=W.autoInit,U=V("packages/modules/htmx/controller.js"),B=U.destroyWithin,H=U.initWithin,L=V("packages/modules/htmx/history.js"),k=L.saveStateWithin,S=L.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return z.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return z.gridElementsWithin}});const y=V("packages/dom/src/hydrate.js");Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return y.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return y.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}});const u=V("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return u.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return u.restoreState}});const o=V("packages/core/src/index.js");Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return o.createHeadlessGrid}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return o.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return o.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return o.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return o.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return o.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return o.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return o.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return o.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return o.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return o.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return o.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return o.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return o.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return o.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return o.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return o.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return o.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return o.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return o.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return o.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return o.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return o.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return o.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return o.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return o.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return o.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return o.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return o.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return o.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return o.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return o.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return o.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return o.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return o.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return o.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return o.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return o.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return o.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return o.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return o.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return o.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return o.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return o.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return o.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return o.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return o.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return o.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return o.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return o.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return o.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return o.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return o.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return o.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return o.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return o.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return o.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return o.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return o.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return o.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return o.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return o.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return o.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return o.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return o.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return o.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return o.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return o.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return o.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return o.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return o.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return o.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return o.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return o.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return o.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return o.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return o.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return o.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return o.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return o.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return o.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return o.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return o.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return o.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return o.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return o.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return o.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return o.WINDOW_KINDS}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return o.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return o.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return o.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return o.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return o.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return o.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return o.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return o.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return o.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return o.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return o.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return o.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return o.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return o.createStreamSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return o.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return o.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return o.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return o.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return o.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return o.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return o.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return o.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return o.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return o.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return o.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return o.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return o.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return o.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return o.filtersToSql}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return o.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return o.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return o.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return o.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return o.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return o.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return o.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return o.STATE_VERSION}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return o.VERSION}});const r=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return r.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return r.toneOf}});const t=V("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return t.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return t.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return t.licenceState}}),Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return U.destroyWithin}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return U.initWithin}}),Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return L.saveStateWithin}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return L.restoreStateWithin}});const n=V("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return n.driveOobUpdates}});const i=V("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return i.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return i.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return i.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return i.SCROLL_NEAR_END_EVENT}});const s=V("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return s.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return s.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return s.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return s.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return s.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return s.HTML_ROW_WARNING_THRESHOLD}});function c(f){const h=f||(typeof document<"u"?document:null);if(!h||!N(h.addEventListener))return()=>{};const g=b=>B(b.target,F),w=b=>H(b.detail&&b.detail.elt||b.target,_),p=b=>{k(b.detail&&b.detail.historyElt||h,F)},m=b=>{b.detail&&b.detail.cacheMiss||S(h,_)};return h.addEventListener("htmx:beforeCleanupElement",g),h.addEventListener("htmx:load",w),h.addEventListener("htmx:beforeHistorySave",p),h.addEventListener("htmx:historyRestore",m),()=>{h.removeEventListener("htmx:beforeCleanupElement",g),h.removeEventListener("htmx:load",w),h.removeEventListener("htmx:beforeHistorySave",p),h.removeEventListener("htmx:historyRestore",m)}}c();const d=c});try{Cn("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.1";async function ae(){return le}const Q="1.71.1",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).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(/^./,J=>J.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=1,te=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"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class ie{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){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 f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=ae(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Y(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return g}}),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 U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),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 a}});const le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.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,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(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,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-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 m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`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,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[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 m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;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||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);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<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;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 m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`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]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={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)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);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 m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,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:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}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 m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}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 d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!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 m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#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 m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let g=0;g<M.length;g++){const e=M[g];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.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=ae(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&ae()-i<s);return this.#o+=ae()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(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,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`ingest.mixed.${a.id}`,`column "${a.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(m))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,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 l=a[n],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,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 l=a[n],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,g=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(M,i){const s=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(M).reduce((e,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="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 b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(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 l=Number(n);if(Number.isFinite(l))return l;const b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;z<f?(c=Math.sqrt(-2*Math.log(z)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):z<=1-f?(c=z-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-z)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),i=2/(2+M),s=4*i-2,u=[-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 f=0,c=0,t;for(let g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#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(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}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 D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}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(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.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"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),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 l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),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 ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=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"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).fail}),S=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 V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(r)(n[n.length-1])}s.kernel=!0;function u(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 f={sum:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,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"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("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 u.totalOf=="function"?u.totalOf:null,a=[];for(const g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=ie(i,c,f[t],u);return c}function ie(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function z(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 s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,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 ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var En=Cn("packages/modules/htmx/index.js");typeof module=="object"&&module.exports?module.exports=En:typeof define=="function"&&define.amd?define(function(){return En}):ir.LatticeGridHtmx=En})(typeof globalThis<"u"?globalThis:this);
|
|
55
55
|
|
|
56
56
|
//# sourceMappingURL=htmx.min.js.map
|