@toclocoinc/lattice-grid 1.74.0 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +44 -6
- package/docs/CHART-CODES.md +8 -0
- 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 +28 -2
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +2 -2
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +13 -1
- package/docs/api-detail.html +13 -4
- package/docs/warnings.json +36 -3
- package/lattice-grid.d.ts +37 -2
- 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 +2 -2
- package/modules/chart-calendar.esm.min.js.map +1 -1
- package/modules/chart-calendar.min.cjs +2 -2
- package/modules/chart-calendar.min.js +2 -2
- package/modules/chart-calendar.min.js.map +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +2 -2
- package/modules/chart-choropleth.esm.min.js.map +1 -1
- package/modules/chart-choropleth.min.cjs +2 -2
- package/modules/chart-choropleth.min.js +2 -2
- package/modules/chart-choropleth.min.js.map +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 +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +2 -2
- package/modules/chart-hexmap.esm.min.js.map +1 -1
- package/modules/chart-hexmap.min.cjs +2 -2
- package/modules/chart-hexmap.min.js +2 -2
- package/modules/chart-hexmap.min.js.map +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 +185 -178
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +185 -178
- package/modules/charts.min.js +185 -178
- 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/deckgl.d.ts +9 -3
- package/modules/deckgl.esm.min.js +18 -11
- package/modules/deckgl.esm.min.js.map +2 -2
- package/modules/deckgl.min.cjs +18 -11
- package/modules/deckgl.min.js +18 -11
- package/modules/deckgl.min.js.map +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 +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/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.esm.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, htmx module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
var rr=Object.create(null),ir=Object.create(null);function je(e,V){rr[e]=V}function Un(e){var V=ir[e];if(V)return V;var Z=Object.create(null);ir[e]=Z;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(Z,Un),Z}je("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const Z="1.74.0";async function M(){return Z}const I="1.74.0",N=new Set,W=2e3;function _(ee){if(N.add(ee),N.size>W){const re=N.values().next().value;re!==void 0&&N.delete(re)}}const H=[],B=500;function G(ee,re,se){H.push({key:ee,level:re,message:se.map(de=>typeof de=="string"?de:D(de)).join(" "),at:Date.now()}),H.length>B&&H.shift()}function D(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function v(){return H.map(ee=>({...ee}))}function k(ee,...re){N.has(ee)||(_(ee),G(ee,"warn",re),console.warn("[lattice]",...re))}function y(ee,...re){N.has(ee)||(_(ee),G(ee,"info",re),console.info("[lattice]",...re))}function c(){N.clear(),H.length=0}function o(ee,re){const se=new Error(`[lattice] ${ee}`);throw re!==void 0&&(se.cause=re),se}function n(ee,re){ee||o(re)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function a(ee){return typeof ee=="function"}function r(ee){return ee==null}function s(ee){return ee==null||ee===""}function u(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const l=new Map;function p(ee){let re=l.get(ee);if(re)return re;if(!ee.includes("."))re=se=>se?.[ee];else{const se=ee.split("."),de=se.length;re=ie=>{let oe=ie;for(let ue=0;ue<de;ue++){if(oe==null)return;oe=oe[se[ue]]}return oe}}return l.set(ee,re),re}const m=new Map;function b(ee){let re=m.get(ee);if(re)return re;if(!ee.includes("."))re=(se,de)=>{se!=null&&(se[ee]=de)};else{const se=ee.split("."),de=se.length-1;re=(ie,oe)=>{let ue=ie;for(let ce=0;ce<de;ce++){if(ue==null)return;const pe=se[ce];ue[pe]==null&&(ue[pe]={}),ue=ue[pe]}ue!=null&&(ue[se[de]]=oe)}}return m.set(ee,re),re}function g(ee,re){return p(re)(ee)}function f(ee,re,se){b(re)(ee,se)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).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(/^./,se=>se.toUpperCase()):""}const S={"&":"&","<":"<",">":">",'"':""","'":"'"};function h(ee){const re=ee==null?"":String(ee);return/[&<>"']/.test(re)?re.replace(/[&<>"']/g,se=>S[se]):re}function d(ee){return String(ee).replace(/\w\S*/g,re=>re[0].toUpperCase()+re.slice(1).toLowerCase())}function j(ee,re,se){if(ee!==void 0)return ee===!0?{enabled:!0,...se}:ee===!1?{enabled:!1}:i(ee)?ee:{[re]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,re){if(!i(ee))return i(re)?{...re}:re;if(!i(re))return re===void 0?ee:re;const se={...ee};for(const de of Object.keys(re)){if(O.has(de))continue;const ie=re[de];ie!==void 0&&(se[de]=i(ie)&&i(se[de])?T(se[de],ie):ie)}return se}function A(ee,re){if(!i(ee)||!i(re)||ee===re)return re;const se=Object.create(Object.getPrototypeOf(ee));return Object.assign(se,ee,re),se}class P{#e;#t=new Map;#n;constructor(re=256,se=null){this.#e=re,this.#n=se}get size(){return this.#t.size}get max(){return this.#e}set max(re){this.#e=re,this.#r()}has(re){return this.#t.has(re)}get(re){const se=this.#t;if(!se.has(re))return;const de=se.get(re);return se.delete(re),se.set(re,de),de}peek(re){return this.#t.get(re)}set(re,se){const de=this.#t;return de.has(re)&&de.delete(re),de.set(re,se),this.#r(),se}delete(re){const se=this.#t.get(re);return this.#t.delete(re)&&this.#n&&this.#n(se,re),se}clear(){if(this.#n)for(const[re,se]of this.#t)this.#n(se,re);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const re=this.#t;for(;re.size>this.#e;){const se=re.keys().next().value,de=re.get(se);re.delete(se),this.#n&&this.#n(de,se)}}}const L=new Map;function $(ee,re){const se=`${ee||""}|${re?JSON.stringify(re):""}`;let de=L.get(se);return de||(de=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...re}),L.set(se,de)),de}function U(ee,re){if(ee===re)return 0;if(ee==null)return 1;if(re==null)return-1;if(typeof ee=="number"&&typeof re=="number")return Number.isNaN(ee)?Number.isNaN(re)?0:1:Number.isNaN(re)||ee<re?-1:ee>re?1:0;const se=String(ee),de=String(re);return se<de?-1:se>de?1:0}function x(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(x()),16)}function z(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function q(ee){let re=null,se=null;const de=()=>{re=null;const oe=se;se=null,ee(...oe||[])},ie=(...oe)=>{se=oe,re===null&&(re=C(de))};return ie.cancel=()=>{z(re),re=null,se=null},ie.flush=()=>{re!==null&&(z(re),de())},ie}function Q(ee,re){let se=null,de=null;const ie=()=>{if(se=null,de===null)return;const ce=de;de=null,ee(...ce),oe()},oe=()=>{se=setTimeout(ie,re),typeof se?.unref=="function"&&se.unref()},ue=(...ce)=>{se===null?(ee(...ce),oe()):(de=ce,clearTimeout(se),oe())};return ue.flush=()=>{if(se!==null&&clearTimeout(se),se=null,de===null)return;const ce=de;de=null,ee(...ce)},ue.cancel=()=>{se!==null&&clearTimeout(se),se=null,de=null},ue.pending=()=>se!==null||de!==null,ue}function Y(ee,re=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:re}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),je("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return N}}),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 G}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),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 f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N=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 H(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),$=String(O??"").toLowerCase();return L<$?-1:L>$?1:0}function B(E){return E==null||E===""}function G(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return B(E);case"notBlank":return!B(E);case"true":return E===!0;case"false":return E===!1;default:break}if(B(E))return!1;switch(T){case"eq":return H(E,A)===0;case"ne":return H(E,A)!==0;case"gt":return H(E,A)>0;case"gte":return H(E,A)>=0;case"lt":return H(E,A)<0;case"lte":return H(E,A)<=0;case"between":return H(E,A)>=0&&H(E,P)<=0;case"outside":return H(E,A)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function D(E,O,T){const A=q=>{const Q=String(q).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,$]=A(E),[U,x,F]=A(O),C=Math.max(0,Math.min(1,T)),z=(q,Q)=>Math.round(q+(Q-q)*C);return`#${[z(P,U),z(L,x),z($,F)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(E){const O=[];for(const U of E||[]){if(U==null||U==="")continue;const x=U instanceof Date?U.getTime():Number(U);Number.isFinite(x)&&O.push(x)}if(!O.length)return null;O.sort((U,x)=>U-x);let T=0,A=0,P=0;for(const U of O){T++;const x=U-A;A+=x/T,P+=x*(U-A)}const L=k(O,.25),$=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:L,q3:$,iqr:$-L,sorted:O}}function k(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function c(E,O){const T=Number(E.value),A=P=>k(O.sorted,P);switch(E.op){case"topPercent":{const P=o(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=o(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function o(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:k(O.sorted,o(Number(E.low),5)),max:k(O.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:a(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=c(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??k(O.sorted,o(Number(E.low),5)),max:A??k(O.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function a(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(k(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=g[E.set];return O?O.length:3}function s(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function u(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function l(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function p(E,O){const T="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 A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const m=Object.freeze([l("#c0392b","down"),l("#e0a800","right"),l("#2e7d32","up")]),b=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),g=Object.freeze({arrows:m,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>p(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?s(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(s(p(L,A)));return P}const T=g[O];return T?T.map(s):(I(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),m.map(s))}function S(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",$=E.direction==="rtl"?"left":"right",U=F=>Math.max(0,Math.min(1,(F-O)/A))*100,x=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(B(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const z=U(C),q=Math.min(z,x),Q=Math.max(z,x),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${Y} ${q}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function h(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return $=>{if(B($))return null;const U=Number($);if(!Number.isFinite(U))return null;let x=0;for(const C of A)U>=C&&x++;const F=T[Math.min(x,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function d(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,$=[];for(let x=0;x<=L;x++)$.push(L?x/L:0);const U=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)I("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(U)&&P&&U>Math.min(T,A)&&U<Math.max(T,A)){const x=L/2,F=Math.max(0,Math.min(1,(U-T)/P));for(let C=0;C<=L;C++)$[C]=C<=x?x?C/x*F:F:F+(C-x)/(L-x)*(1-F)}else Number.isFinite(U)&&I("formatting.scale.mid.range",`a scale's "mid" (${U}) is outside its min..max range, so it was ignored.`);return x=>{const F=Number(x);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let z=0;for(;z<L-1&&C>$[z+1];)z++;const q=$[z+1]-$[z],Q=q>0?(C-$[z])/q:0;return{background:D(O[z],O[z+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:d(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:h(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const $=L?L.value:void 0;let U=null;for(const x of P){if(!x.enabled)continue;if(x.scale){const C=x.scale($);C&&(U={...U||{},...C});continue}if(!G($,x.when))continue;const F=M(x.style)?x.style(L):x.style;if(F&&(U={...U||{},...F}),x.stop)break}return U}}}),je("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const Z="num",M="str",I="ref",N="name",W="op",_="end",H=["<=",">=","<>","!="],B="+-*/^%(),<>=";class G extends Error{constructor(r,s){super(r),this.name="FormulaError",this.at=s}}function D(a){const r=[];let s=0;for(;s<a.length;){const u=a[s];if(u===" "||u===" "||u===`
|
|
6
|
+
var rr=Object.create(null),ir=Object.create(null);function je(e,V){rr[e]=V}function Un(e){var V=ir[e];if(V)return V;var Z=Object.create(null);ir[e]=Z;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(Z,Un),Z}je("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const Z="1.75.0";async function M(){return Z}const I="1.75.0",N=new Set,W=2e3;function _(ee){if(N.add(ee),N.size>W){const re=N.values().next().value;re!==void 0&&N.delete(re)}}const H=[],B=500;function G(ee,re,se){H.push({key:ee,level:re,message:se.map(de=>typeof de=="string"?de:D(de)).join(" "),at:Date.now()}),H.length>B&&H.shift()}function D(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function v(){return H.map(ee=>({...ee}))}function k(ee,...re){N.has(ee)||(_(ee),G(ee,"warn",re),console.warn("[lattice]",...re))}function y(ee,...re){N.has(ee)||(_(ee),G(ee,"info",re),console.info("[lattice]",...re))}function c(){N.clear(),H.length=0}function o(ee,re){const se=new Error(`[lattice] ${ee}`);throw re!==void 0&&(se.cause=re),se}function n(ee,re){ee||o(re)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function a(ee){return typeof ee=="function"}function r(ee){return ee==null}function s(ee){return ee==null||ee===""}function u(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const l=new Map;function p(ee){let re=l.get(ee);if(re)return re;if(!ee.includes("."))re=se=>se?.[ee];else{const se=ee.split("."),de=se.length;re=ie=>{let oe=ie;for(let ue=0;ue<de;ue++){if(oe==null)return;oe=oe[se[ue]]}return oe}}return l.set(ee,re),re}const m=new Map;function b(ee){let re=m.get(ee);if(re)return re;if(!ee.includes("."))re=(se,de)=>{se!=null&&(se[ee]=de)};else{const se=ee.split("."),de=se.length-1;re=(ie,oe)=>{let ue=ie;for(let ce=0;ce<de;ce++){if(ue==null)return;const pe=se[ce];ue[pe]==null&&(ue[pe]={}),ue=ue[pe]}ue!=null&&(ue[se[de]]=oe)}}return m.set(ee,re),re}function g(ee,re){return p(re)(ee)}function f(ee,re,se){b(re)(ee,se)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).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(/^./,se=>se.toUpperCase()):""}const S={"&":"&","<":"<",">":">",'"':""","'":"'"};function h(ee){const re=ee==null?"":String(ee);return/[&<>"']/.test(re)?re.replace(/[&<>"']/g,se=>S[se]):re}function d(ee){return String(ee).replace(/\w\S*/g,re=>re[0].toUpperCase()+re.slice(1).toLowerCase())}function j(ee,re,se){if(ee!==void 0)return ee===!0?{enabled:!0,...se}:ee===!1?{enabled:!1}:i(ee)?ee:{[re]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,re){if(!i(ee))return i(re)?{...re}:re;if(!i(re))return re===void 0?ee:re;const se={...ee};for(const de of Object.keys(re)){if(O.has(de))continue;const ie=re[de];ie!==void 0&&(se[de]=i(ie)&&i(se[de])?T(se[de],ie):ie)}return se}function A(ee,re){if(!i(ee)||!i(re)||ee===re)return re;const se=Object.create(Object.getPrototypeOf(ee));return Object.assign(se,ee,re),se}class P{#e;#t=new Map;#n;constructor(re=256,se=null){this.#e=re,this.#n=se}get size(){return this.#t.size}get max(){return this.#e}set max(re){this.#e=re,this.#r()}has(re){return this.#t.has(re)}get(re){const se=this.#t;if(!se.has(re))return;const de=se.get(re);return se.delete(re),se.set(re,de),de}peek(re){return this.#t.get(re)}set(re,se){const de=this.#t;return de.has(re)&&de.delete(re),de.set(re,se),this.#r(),se}delete(re){const se=this.#t.get(re);return this.#t.delete(re)&&this.#n&&this.#n(se,re),se}clear(){if(this.#n)for(const[re,se]of this.#t)this.#n(se,re);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const re=this.#t;for(;re.size>this.#e;){const se=re.keys().next().value,de=re.get(se);re.delete(se),this.#n&&this.#n(de,se)}}}const L=new Map;function $(ee,re){const se=`${ee||""}|${re?JSON.stringify(re):""}`;let de=L.get(se);return de||(de=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...re}),L.set(se,de)),de}function U(ee,re){if(ee===re)return 0;if(ee==null)return 1;if(re==null)return-1;if(typeof ee=="number"&&typeof re=="number")return Number.isNaN(ee)?Number.isNaN(re)?0:1:Number.isNaN(re)||ee<re?-1:ee>re?1:0;const se=String(ee),de=String(re);return se<de?-1:se>de?1:0}function x(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(x()),16)}function z(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function q(ee){let re=null,se=null;const de=()=>{re=null;const oe=se;se=null,ee(...oe||[])},ie=(...oe)=>{se=oe,re===null&&(re=C(de))};return ie.cancel=()=>{z(re),re=null,se=null},ie.flush=()=>{re!==null&&(z(re),de())},ie}function Q(ee,re){let se=null,de=null;const ie=()=>{if(se=null,de===null)return;const ce=de;de=null,ee(...ce),oe()},oe=()=>{se=setTimeout(ie,re),typeof se?.unref=="function"&&se.unref()},ue=(...ce)=>{se===null?(ee(...ce),oe()):(de=ce,clearTimeout(se),oe())};return ue.flush=()=>{if(se!==null&&clearTimeout(se),se=null,de===null)return;const ce=de;de=null,ee(...ce)},ue.cancel=()=>{se!==null&&clearTimeout(se),se=null,de=null},ue.pending=()=>se!==null||de!==null,ue}function Y(ee,re=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:re}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),je("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return N}}),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 G}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return k}}),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 f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N=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 H(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),$=String(O??"").toLowerCase();return L<$?-1:L>$?1:0}function B(E){return E==null||E===""}function G(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return B(E);case"notBlank":return!B(E);case"true":return E===!0;case"false":return E===!1;default:break}if(B(E))return!1;switch(T){case"eq":return H(E,A)===0;case"ne":return H(E,A)!==0;case"gt":return H(E,A)>0;case"gte":return H(E,A)>=0;case"lt":return H(E,A)<0;case"lte":return H(E,A)<=0;case"between":return H(E,A)>=0&&H(E,P)<=0;case"outside":return H(E,A)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function D(E,O,T){const A=q=>{const Q=String(q).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,$]=A(E),[U,x,F]=A(O),C=Math.max(0,Math.min(1,T)),z=(q,Q)=>Math.round(q+(Q-q)*C);return`#${[z(P,U),z(L,x),z($,F)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(E){const O=[];for(const U of E||[]){if(U==null||U==="")continue;const x=U instanceof Date?U.getTime():Number(U);Number.isFinite(x)&&O.push(x)}if(!O.length)return null;O.sort((U,x)=>U-x);let T=0,A=0,P=0;for(const U of O){T++;const x=U-A;A+=x/T,P+=x*(U-A)}const L=k(O,.25),$=k(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:k(O,.5),q1:L,q3:$,iqr:$-L,sorted:O}}function k(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function c(E,O){const T=Number(E.value),A=P=>k(O.sorted,P);switch(E.op){case"topPercent":{const P=o(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=o(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function o(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:k(O.sorted,o(Number(E.low),5)),max:k(O.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:a(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=c(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??k(O.sorted,o(Number(E.low),5)),max:A??k(O.sorted,o(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function a(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(k(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=g[E.set];return O?O.length:3}function s(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function u(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function l(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function p(E,O){const T="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 A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const m=Object.freeze([l("#c0392b","down"),l("#e0a800","right"),l("#2e7d32","up")]),b=Object.freeze([u("#d13438"),u("#f5a623"),u("#2e9e44")]),g=Object.freeze({arrows:m,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>p(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?s(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(s(p(L,A)));return P}const T=g[O];return T?T.map(s):(I(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),m.map(s))}function S(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",$=E.direction==="rtl"?"left":"right",U=F=>Math.max(0,Math.min(1,(F-O)/A))*100,x=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(B(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const z=U(C),q=Math.min(z,x),Q=Math.max(z,x),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${Y} ${q}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function h(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return $=>{if(B($))return null;const U=Number($);if(!Number.isFinite(U))return null;let x=0;for(const C of A)U>=C&&x++;const F=T[Math.min(x,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function d(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,$=[];for(let x=0;x<=L;x++)$.push(L?x/L:0);const U=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)I("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(U)&&P&&U>Math.min(T,A)&&U<Math.max(T,A)){const x=L/2,F=Math.max(0,Math.min(1,(U-T)/P));for(let C=0;C<=L;C++)$[C]=C<=x?x?C/x*F:F:F+(C-x)/(L-x)*(1-F)}else Number.isFinite(U)&&I("formatting.scale.mid.range",`a scale's "mid" (${U}) is outside its min..max range, so it was ignored.`);return x=>{const F=Number(x);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let z=0;for(;z<L-1&&C>$[z+1];)z++;const q=$[z+1]-$[z],Q=q>0?(C-$[z])/q:0;return{background:D(O[z],O[z+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:d(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:h(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const $=L?L.value:void 0;let U=null;for(const x of P){if(!x.enabled)continue;if(x.scale){const C=x.scale($);C&&(U={...U||{},...C});continue}if(!G($,x.when))continue;const F=M(x.style)?x.style(L):x.style;if(F&&(U={...U||{},...F}),x.stop)break}return U}}}),je("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const Z="num",M="str",I="ref",N="name",W="op",_="end",H=["<=",">=","<>","!="],B="+-*/^%(),<>=";class G extends Error{constructor(r,s){super(r),this.name="FormulaError",this.at=s}}function D(a){const r=[];let s=0;for(;s<a.length;){const u=a[s];if(u===" "||u===" "||u===`
|
|
7
7
|
`||u==="\r"){s++;continue}if(u>="0"&&u<="9"){s=k(a,s,r);continue}if(u==="."&&a[s+1]>="0"&&a[s+1]<="9"){s=k(a,s,r);continue}if(u==='"'||u==="'"){s=y(a,s,r);continue}if(u==="["){const p=a.indexOf("]",s+1);if(p<0)throw new G("a [column reference] was opened and never closed",s);r.push({kind:I,value:a.slice(s+1,p).trim(),at:s}),s=p+1;continue}if(v(u)){s=c(a,s,r);continue}const l=a.slice(s,s+2);if(H.includes(l)){r.push({kind:W,value:l==="!="?"<>":l,at:s}),s+=2;continue}if(B.includes(u)){r.push({kind:W,value:u,at:s}),s++;continue}throw new G(`unexpected character ${JSON.stringify(u)}`,s)}return r.push({kind:_,value:null,at:a.length}),r}function v(a){return/[A-Za-z_À-]/.test(a)}function k(a,r,s){let u=r,l=!1;for(;u<a.length;){const p=a[u];if(p>="0"&&p<="9"){u++;continue}if(p==="."&&!l){l=!0,u++;continue}if((p==="e"||p==="E")&&/[0-9+-]/.test(a[u+1]||"")){for(u+=2;u<a.length&&a[u]>="0"&&a[u]<="9";)u++;break}break}return s.push({kind:Z,value:Number(a.slice(r,u)),at:r}),u}function y(a,r,s){const u=a[r];let l=r+1,p="";for(;l<a.length;){if(a[l]===u){if(a[l+1]===u){p+=u,l+=2;continue}return s.push({kind:M,value:p,at:r}),l+1}p+=a[l],l++}throw new G("a string was opened and never closed",r)}function c(a,r,s){let u=r;for(;u<a.length&&/[A-Za-z0-9_.À-]/.test(a[u]);)u++;const l=a.slice(r,u);let p=u;for(;p<a.length&&a[p]===" ";)p++;return s.push({kind:a[p]==="("?N:I,value:l,at:r}),u}const o={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function n(a){const r=String(a??"").replace(/^\s*=/,"");if(!r.trim())throw new G("the formula is empty");const s=D(r);let u=0;const l=()=>s[u],p=()=>s[u++],m=d=>{const j=l();if(j.kind!==W||j.value!==d)throw new G(`expected ${JSON.stringify(d)}`,j.at);u++},b=d=>{let j=g();for(;;){const E=l();if(E.kind!==W)break;const O=o[E.value];if(!O||O<d)break;u++;const T=b(E.value==="^"?O:O+1);j={kind:"bin",op:E.value,left:j,right:T}}return j},g=()=>{const d=l();return d.kind===W&&(d.value==="-"||d.value==="+")?(u++,{kind:"unary",op:d.value,arg:g()}):f()},f=()=>{let d=w();for(;l().kind===W&&l().value==="%";)u++,d={kind:"unary",op:"%",arg:d};return d},w=()=>{const d=p();if(d.kind===Z)return{kind:"num",value:d.value};if(d.kind===M)return{kind:"str",value:d.value};if(d.kind===I)return{kind:"ref",name:d.value};if(d.kind===N){m("(");const j=[];if(!(l().kind===W&&l().value===")"))for(;;){if(j.push(b(1)),l().kind===W&&l().value===","){u++;continue}break}return m(")"),{kind:"call",name:String(d.value).toUpperCase(),args:j}}if(d.kind===W&&d.value==="("){const j=b(1);return m(")"),j}throw d.kind===_?new G("the formula ends unexpectedly",d.at):new G(`unexpected ${JSON.stringify(d.value)}`,d.at)},S=b(1),h=l();if(h.kind!==_)throw new G(`unexpected ${JSON.stringify(h.value)}: is an operator missing?`,h.at);return S}function t(a){const r=new Set,s=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){r.add(String(u.name));return}if(u.kind==="bin"){s(u.left),s(u.right);return}if(u.kind==="unary"){s(u.arg);return}if(u.kind==="call")for(const l of u.args)s(l)}};return s(a),[...r]}function i(a){return typeof a=="string"&&/^\s*=/.test(a)&&a.trim()!=="="}}),je("packages/core/src/formula/evaluate.js",function(e,V){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return k}});const M=V("packages/core/src/formula/parse.js").FormulaError;function I(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const c=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(c))throw new M(`${JSON.stringify(y)} is not a number`);return c}function N(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 c=String(y).trim().toLowerCase();return c==="false"||c==="no"||c==="0"?!1:c!==""}function _(y){const c=[];for(const o of y){if(Array.isArray(o)){for(const n of o)n!=null&&n!==""&&c.push(I(n));continue}o==null||o===""||c.push(I(o))}return c}function H(y,c){const o=10**c,n=y*o;return Math.sign(n)*Math.round(Math.abs(n)+Number.EPSILON*Math.abs(n))/o}function B(y,c){if(!y.length)return 0;const o=y.slice().sort((a,r)=>a-r),n=(o.length-1)*Math.min(1,Math.max(0,c)),t=Math.floor(n),i=Math.ceil(n);return t===i?o[t]:o[t]+(n-t)*(o[i]-o[t])}function G(y,c){let o=0,n=0,t=0;for(const a of y){o++;const r=a-n;n+=r/o,t+=r*(a-n)}const i=c?o-1:o;return i>0?Math.sqrt(t/i):0}const D={SUM:y=>_(y).reduce((c,o)=>c+o,0),AVERAGE:y=>{const c=_(y);return c.length?c.reduce((o,n)=>o+n,0)/c.length:0},MIN:y=>{const c=_(y);return c.length?Math.min(...c):0},MAX:y=>{const c=_(y);return c.length?Math.max(...c):0},COUNT:y=>_(y).length,PRODUCT:y=>_(y).reduce((c,o)=>c*o,1),ROUND:y=>H(I(y[0]),y.length>1?I(y[1]):0),ROUNDDOWN:y=>{const c=10**(y.length>1?I(y[1]):0),o=I(y[0])*c;return(o<0?Math.ceil(o):Math.floor(o))/c},ROUNDUP:y=>{const c=10**(y.length>1?I(y[1]):0),o=I(y[0])*c;return(o<0?Math.floor(o):Math.ceil(o))/c},ABS:y=>Math.abs(I(y[0])),FLOOR:y=>Math.floor(I(y[0])),CEILING:y=>Math.ceil(I(y[0])),SQRT:y=>Math.sqrt(I(y[0])),POWER:y=>I(y[0])**I(y[1]),MOD:y=>{const c=I(y[1]);if(c===0)throw new M("MOD by zero");return(I(y[0])%c+c)%c},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(c=>c!=null&&c!=="")??null,CONCAT:y=>y.map(N).join(""),LEN:y=>N(y[0]).length,UPPER:y=>N(y[0]).toUpperCase(),LOWER:y=>N(y[0]).toLowerCase(),TRIM:y=>N(y[0]).trim(),LEFT:y=>N(y[0]).slice(0,y.length>1?I(y[1]):1),RIGHT:y=>{const c=y.length>1?I(y[1]):1;return c<=0?"":N(y[0]).slice(-c)},MEDIAN:y=>B(_(y),.5),PERCENTILE:y=>{const c=I(y[y.length-1]);return B(_(y.slice(0,-1)),c>1?c/100:c)},QUARTILE1:y=>B(_(y),.25),QUARTILE3:y=>B(_(y),.75),STDEV:y=>G(_(y),!0),STDEVP:y=>G(_(y),!1),VAR:y=>{const c=G(_(y),!0);return c*c},VARP:y=>{const c=G(_(y),!1);return c*c},COUNTDISTINCT:y=>{const c=new Set;for(const o of y){const n=Array.isArray(o)?o:[o];for(const t of n)t!=null&&t!==""&&c.add(t)}return c.size},IQR:y=>{const c=_(y);return B(c,.75)-B(c,.25)}};D.AVG=D.AVERAGE,D.CEIL=D.CEILING,D.POW=D.POWER,D.STDEVS=D.STDEV,D.PERCENTILEINC=D.PERCENTILE;function v(y,c){const o=Number(y),n=Number(c);if(y!==null&&y!==""&&c!==null&&c!==""&&Number.isFinite(o)&&Number.isFinite(n))return o<n?-1:o>n?1:0;const i=N(y).toLowerCase(),a=N(c).toLowerCase();return i<a?-1:i>a?1:0}function k(y,c={}){const o=typeof c.lookup=="function"?c.lookup:null,n=c.functions?{...D,...c.functions}:D,t=i=>{switch(i.kind){case"num":return i.value;case"str":return i.value;case"ref":{if(!o)throw new M(`there is no column called ${JSON.stringify(i.name)} here`);const a=o(String(i.name));if(a===void 0)throw new M(`there is no column called ${JSON.stringify(i.name)}`);return a}case"unary":{if(i.op==="%")return I(t(i.arg))/100;const a=I(t(i.arg));return i.op==="-"?-a:a}case"bin":{const a=i.op;if(a==="=")return v(t(i.left),t(i.right))===0;if(a==="<>")return v(t(i.left),t(i.right))!==0;if(a==="<")return v(t(i.left),t(i.right))<0;if(a==="<=")return v(t(i.left),t(i.right))<=0;if(a===">")return v(t(i.left),t(i.right))>0;if(a===">=")return v(t(i.left),t(i.right))>=0;const r=I(t(i.left)),s=I(t(i.right));if(a==="+")return r+s;if(a==="-")return r-s;if(a==="*")return r*s;if(a==="^")return r**s;if(a==="/"){if(s===0)throw new M("division by zero");return r/s}throw new M(`unknown operator ${JSON.stringify(a)}`)}case"call":{const a=n[i.name];if(typeof a!="function")throw new M(`there is no function called ${i.name}`);return a(i.args.map(t),c)}default:throw new M("the formula could not be read")}};return t(y)}}),je("packages/core/src/formula/index.js",function(e,V){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return N}}),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 G}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return v}});const Z=V("packages/core/src/formula/parse.js"),M=Z.parseFormula,I=Z.referencesOf,N=Z.looksLikeFormula,W=Z.FormulaError,_=Z.tokenise,H=V("packages/core/src/formula/evaluate.js"),B=H.evaluateAst,G=H.FUNCTIONS;function D(k){const{grid:y,row:c,data:o}=k||{},n=s=>String(s).toLowerCase().replace(/[\s_-]/g,""),t=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],i=y&&y.permissions,a=i&&typeof i.isReadable=="function"?s=>i.isReadable(s):()=>!0,r=new Set;for(const s of t)a(s)||(r.add(n(s.id)),s.field&&r.add(n(s.field)),s.title&&r.add(n(s.title)));return s=>{const u=n(s);if(r.has(u))throw new W(`"${s}" cannot be read`);for(const l of t)if(n(l.id)===u||l.field&&n(l.field)===u||l.title&&n(l.title)===u)return c&&y.rows&&typeof y.rows.value=="function"?y.rows.value(c.key,l.id):o?o[l.field||l.id]:void 0;if(o&&typeof o=="object"){for(const l of Object.keys(o))if(n(l)===u){if(!a(l))throw new W(`"${s}" cannot be read`);return o[l]}}}}function v(k,y={}){try{const c=M(k);return{ok:!0,value:B(c,{lookup:D(y),functions:y.formulaFunctions}),references:I(c)}}catch(c){return{ok:!1,error:c instanceof W?c.message:"the formula could not be read",at:c instanceof W?c.at:void 0}}}}),je("packages/core/src/defaults.js",function(e,V){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return B}});const Z=V("packages/core/src/internal/util.js"),M=Z.isObject,I=Z.merge,N=Z.warnOnce;let W=null;function _(G){if(Array.isArray(G))return G.map(_);if(!M(G)||Object.getPrototypeOf(G)!==Object.prototype&&Object.getPrototypeOf(G)!==null)return G;const D={};for(const[v,k]of Object.entries(G))D[v]=_(k);return D}function H(G){return G===void 0?_(W??{}):G===null?(W=null,{}):M(G)?(W=_(G),_(W)):(N("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(G)?"an array":typeof G}. The call was ignored and the defaults are unchanged.`),_(W??{}))}function B(G){return W===null?G:I(_(W),G)}}),je("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 I}});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","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),M=new Set(Z);function I(N){return N==="*"||M.has(N)}}),je("packages/core/src/events/bus.js",function(e,V){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.uid,N=Z.DEV,_=V("packages/core/src/events/names.js").isKnownEvent,H="*";function B(o,n){!N||_(n)||M(`bus.unknown:${n}`,`${o}('${n}') 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 G=new Set(["api","user","init","ai"]),D=new WeakMap;function v(o){let n=D.get(o);return n||(n=I("h"),D.set(o,n)),n}function k(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(o){if(!o||typeof o!="object")return{};const n={};for(const[t,i]of Object.entries(o))t!=="grid"&&(i==null?n[t]=String(i):Array.isArray(i)?n[t]=`[${i.length}]`:typeof i=="object"?n[t]=i.key?`row ${i.key}`:"{…}":typeof i=="function"?n[t]="[function]":n[t]=String(i).slice(0,60));return n}class c{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(n=null){this.#i=n}attach(n){this.#i=n}get grid(){return this.#i}get destroyed(){return this.#s}on(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`on('${n}') needs a function; ignored.`),()=>{};B("on",n);let i=this.#e.get(n);return i||(i=[],this.#e.set(n,i)),i.push(t),()=>this.off(n,t)}once(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`once('${n}') needs a function; ignored.`),()=>{};B("once",n);const i=a=>{this.off(n,t),t(a)};return this.#o.set(t,i),this.on(n,i)}off(n,t){if(t===void 0){this.#e.delete(n);return}const i=this.#e.get(n);if(!i)return;const a=this.#o.get(t),r=a&&i.includes(a)?a:t,s=i.indexOf(r);s>=0&&i.splice(s,1),a&&r===a&&this.#o.delete(t),i.length===0&&this.#e.delete(n)}count(n){const t=this.#e.get(n),i=n===H?null:this.#e.get(H);return(t?t.length:0)+(i?i.length:0)}#a(n,t,i,a,r){this.#n.push({type:n,origin:t,listeners:(a?a.length:0)+(r?r.length:0),payload:y(i),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(n,t){this.#t=!!n,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),n||(this.#n=[])}eventLog(){return this.#n.map(n=>({...n}))}clearEventLog(){this.#n=[]}counts(){const n={};for(const[t,i]of this.#e)n[t]=i.length;return n}emit(n,t,i){const a=i??(t&&t.origin),r=G.has(a)?a:"api",s={...t||null,type:n,origin:r,grid:this.#i};if(this.#s)return s;const u=this.#e.get(n),l=n===H?void 0:this.#e.get(H);if(this.#t&&this.#a(n,r,t,u,l),!u&&!l)return s;const p=this.#t?k():0;this.#l++;try{u&&this.#u(u.slice(),s,n),l&&this.#u(l.slice(),s,H)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=k()-p)}return s}emitBefore(n,t,i){const a=i??(t&&t.origin),r=G.has(a)?a:"user";let s=!1,u=null;const l=w=>{s=!0,w!=null&&u===null&&(u=String(w))},p={...t||null,type:n,origin:r,grid:this.#i,get defaultPrevented(){return s},get reason(){return u},preventDefault(w){l(w)}};if(this.#s)return!0;const m=this.#e.get(n);this.#t&&this.#a(n,r,t,m,void 0);const b=m?m.slice():[];if(b.length===0)return!0;const g=()=>(s&&u===null&&(u="prevented"),s&&t&&typeof t=="object"&&(t.reason=u),!s),f=[];for(const w of b)try{const S=w(p);S&&typeof S.then=="function"?f.push(S):S===!1&&l("prevented")}catch(S){l("error"),M(`bus.beforeThrow:${n}:${v(w)}`,`a '${n}' before-handler threw; the action was cancelled.`,S)}return f.length===0?g():Promise.allSettled(f).then(w=>{for(const S of w)S.status==="rejected"?(l("error"),M(`bus.beforeReject:${n}`,`a '${n}' before-handler rejected; the action was cancelled.`,S.reason)):S.value===!1&&l("prevented");return g()})}#u(n,t,i){for(let a=0;a<n.length;a++)try{n[a](t)}catch(r){M(`bus.throw:${i}:${v(n[a])}`,`a '${i}' handler threw; other handlers were unaffected.`,r)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),je("packages/core/src/registry/licence.js",function(e,V){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return j}});const M=V("packages/core/src/internal/util.js").warnOnce,I="lattice-grid",N=1,W="LG1",_=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",G=(()=>{const E=new Int16Array(128).fill(-1);for(let O=0;O<B.length;O++)E[B.charCodeAt(O)]=O;return E[43]=62,E[47]=63,E})();function D(E){if(typeof E!="string")return null;let O="";for(let U=0;U<E.length;U++){const x=E.charCodeAt(U);if(x!==61){if(x>127||G[x]<0)return null;O+=E[U]}}const T=O.length;if(T%4===1)return null;const A=new Uint8Array(Math.floor(T*3/4));let P=0,L=0,$=0;for(let U=0;U<T;U++)P=P<<6|G[O.charCodeAt(U)],L+=6,L>=8&&(L-=8,A[$++]=P>>L&255);return $===A.length?A:A.subarray(0,$)}function v(E){let O="",T=0;for(;T+2<E.length;T+=3){const P=E[T]<<16|E[T+1]<<8|E[T+2];O+=B[P>>18&63]+B[P>>12&63]+B[P>>6&63]+B[P&63]}const A=E.length-T;if(A===1){const P=E[T]<<16;O+=B[P>>18&63]+B[P>>12&63]}else if(A===2){const P=E[T]<<16|E[T+1]<<8;O+=B[P>>18&63]+B[P>>12&63]+B[P>>6&63]}return O}function k(E){const O=new Uint8Array(E.length);for(let T=0;T<E.length;T++)O[T]=E.charCodeAt(T)&127;return O}function y(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let O="";for(let T=0;T<E.length;T++)O+=String.fromCharCode(E[T]);return O}function c(E){const O={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...O,reason:"missing"};const T=E.trim(),A=T.split(".");if(A.length!==3)return O;const[P,L,$]=A;if(P!==W)return{...O,reason:"prefix"};const U=D(L),x=D($);if(!U||!x)return O;let F;try{F=JSON.parse(y(U))}catch{return O}return F===null||typeof F!="object"?O:{ok:!0,reason:null,product:typeof F.p=="string"?F.p:null,issuedTo:typeof F.t=="string"?F.t:null,expires:typeof F.e=="string"?F.e:null,features:Array.isArray(F.f)?F.f.slice():[],deployments:Array.isArray(F.d)?F.d.slice():[],version:typeof F.v=="number"?F.v:0,message:k(L),signature:x,raw:T}}function o(E,O){if(!E)return!1;const T=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(T)?!0:O>T}let n=null,t=null,i=null;function a(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function r(E){if(n&&t===E)return n;const O=a();if(!O)return null;const T=D(E);if(!T)return null;try{const A=await O.importKey("raw",T,{name:"Ed25519"},!1,["verify"]);return n=A,t=E,A}catch{return null}}async function s(){return i!==null||(i=await r(H)!==null),i}async function u(E,O={}){const T=O.warn!==!1,A=O.product||I,P=O.publicKey||H,L=O.now??Date.now(),$=c(E);if(!$.ok){const q=$.reason==="missing"?"missing":"malformed";return T&&M(`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 U={product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0};if($.product!==A)return T&&M("licence.product",`licence key is for '${$.product}', not '${A}'. The grid will render with a watermark.`),{valid:!1,...U,reason:"product"};if(o($.expires,L))return T&&M("licence.expired",`licence expired on ${$.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...U,reason:"expired"};const x=O.host??p(),F=$.deployments||[];if(F.length&&x&&!l(x)&&!m(x,F))return T&&M("licence.domain",`licence key is not valid for ${x}; it covers ${F.join(", ")}. The grid will render with a watermark.`),{valid:!1,...U,reason:"domain"};const C=await r(P);if(!C){const q=!!$.signature&&$.signature.length===_;return T&&M("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,...U,reason:"unverified"}:{valid:!1,...U,reason:"signature"}}let z=!1;try{z=await a().verify({name:"Ed25519"},C,$.signature,$.message)}catch{z=!1}return z?{valid:!0,...U}:(T&&M("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...U,reason:"signature"})}function l(E){const O=String(E??p()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!O||O==="localhost"||O.endsWith(".localhost")||O==="::1"||O==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(O)}function p(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function m(E,O){const T=b(E);return!T||!Array.isArray(O)?!1:O.some(A=>{const P=b(A);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const L=P.slice(2);return T===L||T.endsWith(`.${L}`)}return T===P})}function b(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class g{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(O={}){this.#o=O}set(O){this.#e=typeof O=="string"?O.trim():"";const T=c(this.#e);return this.#t=T.ok?{valid:!o(T.expires,Date.now())&&T.product===(this.#o.product||I),product:T.product||void 0,issuedTo:T.issuedTo||void 0,expires:T.expires||void 0,reason:"pending"}:{valid:!1,reason:T.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const O=this.#e;return this.#n=u(O,this.#o).then(T=>{if(this.#e===O){this.#t=T;for(const A of this.#i)A(T)}return T}),this.#n}onSettled(O){return this.#i.add(O),()=>this.#i.delete(O)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!l(this.#r)}setHost(O){this.#r=O}state(){return this.#t.valid?"licensed":l(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const f=new g;function w(E){return f.set(E)}function S(){return f.info()}function h(){return f.watermark()}function d(){return f.state()}function j(){return f}}),je("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 G}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return i}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isFunction,N=Z.DEV,W=V("packages/core/src/registry/licence.js"),_=W.LicenceHolder,H=W.sharedLicence,B=["renderer","editor","filter","dataType","totalFn","pipe","component"],G=["all","header","body","totals","panels"];class D{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(r={}){for(const s of B)this.#t.set(s,new Map);this.#o=r.holder||H(),this.#s=r.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),r.licence&&this.setLicence(r.licence)}registerModules(r,s={}){s.licence&&this.setLicence(s.licence),s.grid!==void 0&&(this.#s=s.grid);const u=Array.isArray(r)?r:[r],l=[];for(const p of u){if(!p||typeof p!="object"||typeof p.name!="string"||!p.name){M("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(p.name)){N&&this.#c(this.#e.get(p.name),p);continue}if(!I(p.install)){M(`registry.module.install:${p.name}`,`module '${p.name}' has no install() and was ignored.`);continue}const m={registry:this,grid:this.#s};try{p.install(m)}catch(b){M(`registry.module.throw:${p.name}`,`module '${p.name}' threw during install; it was not registered.`,b);continue}this.#e.set(p.name,p);for(const b of v(p))this.#n.add(b);l.push(p.name),this.#d({reason:"module",name:p.name,capabilities:this.capabilities(),regions:c(p)})}return l}unregisterModule(r){const s=this.#e.get(r);if(!s)return!1;if(I(s.uninstall))try{s.uninstall({registry:this,grid:this.#s})}catch(u){M(`registry.module.uninstall:${r}`,`module '${r}' threw during uninstall.`,u)}return this.#e.delete(r),this.#u(),this.#d({reason:"unmodule",name:r,capabilities:this.capabilities(),regions:c(s)}),!0}modules(){return[...this.#e.values()]}has(r){return this.#e.has(r)}#u(){this.#n.clear();for(const r of this.#e.values())for(const s of v(r))this.#n.add(s)}#c(r,s){!r||r===s||k(r,s)||M(`registry.module.reconfigure:${s.name}`,`module '${s.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(r){return this.#n.has(r)}onChange(r){return I(r)?(this.#r.add(r),this.#a.set(r,this.#s),()=>{this.#r.delete(r),this.#a.delete(r)}):()=>{}}#d(r){for(const s of[...this.#r])try{s(r)}catch(u){M("registry.onChange.throw","a registry change handler threw.",u)}}register(r,s,u){const l=this.#t.get(r);if(!l){M(`registry.kind:${r}`,`unknown registry kind '${r}'; expected one of ${B.join(", ")}.`);return}if(!s||typeof s!="string"){M(`registry.name:${r}`,`register('${r}', ...) needs a name.`);return}l.has(s)&&l.get(s)!==u&&M(`registry.replace:${r}:${s}`,`'${s}' was already registered as a ${r} and has been replaced.`),l.set(s,u),this.#d({reason:"register",name:s,kind:r,capabilities:this.capabilities(),regions:o(r)})}registerAll(r,s){if(s)for(const u of Object.keys(s))this.register(r,u,s[u])}get(r,s){const u=this.#t.get(r);return u?u.get(s):void 0}names(r){const s=this.#t.get(r);return s?[...s.keys()]:[]}#h(r,s){const u=this.#t.get(r).get(s);return u!==void 0?u:this.#t.get("component").get(s)}renderer(r){return this.#h("renderer",r)}editor(r){return this.#h("editor",r)}filter(r){return this.#h("filter",r)}dataType(r){return this.get("dataType",r)}totalFn(r){return this.get("totalFn",r)}pipe(r){return this.get("pipe",r)}setLicence(r){return this.#o.set(r)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(r){r!=null&&(this.#l.add(r),this.#s=r)}detach(r){if(r!=null){this.#l.delete(r);for(const[s,u]of[...this.#a])u===r&&(this.#r.delete(s),this.#a.delete(s));if(this.#s===r){const s=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=s}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(r){if(r!=null){this.detach(r);return}for(const s of[...this.#e.keys()])this.unregisterModule(s);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function v(a){const r=a.capabilities,s=Array.isArray(r)?r.filter(u=>typeof u=="string"):[];return[a.name,...s]}function k(a,r){return a.install!==r.install||a.uninstall!==r.uninstall||(a.version||"")!==(r.version||"")?!1:y(v(a),v(r))&&y(c(a),c(r))}function y(a,r){const s=new Set(a),u=new Set(r);if(s.size!==u.size)return!1;for(const l of s)if(!u.has(l))return!1;return!0}function c(a){const r=a.regions;return!Array.isArray(r)||r.length===0?["all"]:r.filter(s=>G.includes(s))}function o(a){switch(a){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const n=new D;function t(){return n}function i(a,r={}){return n.registerModules(a,r)}}),je("packages/core/src/format/number.js",function(e,V){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return I}});const M=V("packages/core/src/internal/util.js").isNil;function I(N,W){const _=N||{},H=_.locale||W||void 0,B=_.style||"decimal",G=typeof _.scale=="number"?_.scale:1,D=_.nullDisplay??"",v=_.zeroDisplay,k=_.prefix||"",y=_.suffix||"",c=_.negative||"minus",o=_.signed===!0,n={style:B,notation:_.notation||"standard"};B==="currency"&&(n.currency=_.currency||"USD",_.currencyDisplay&&(n.currencyDisplay=_.currencyDisplay)),typeof _.decimals=="number"?(n.minimumFractionDigits=_.decimals,n.maximumFractionDigits=_.decimals):(typeof _.minDecimals=="number"&&(n.minimumFractionDigits=_.minDecimals),typeof _.maxDecimals=="number"&&(n.maximumFractionDigits=_.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),_.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=_.compactDisplay||"short");const t=new Intl.NumberFormat(H,n),i=typeof _.thousandsSeparator=="string"?_.thousandsSeparator:null,a=typeof _.decimalSeparator=="string"?_.decimalSeparator:null;let r=",",s=".";if(i||a)for(const g of t.formatToParts(12345.6))g.type==="group"?r=g.value:g.type==="decimal"&&(s=g.value);const u=g=>{let f=g;return i&&(f=f.split(r).join("")),a&&(f=f.split(s).join("")),i&&(f=f.split("").join(i)),a&&(f=f.split("").join(a)),f},l=!!(i||a),p=k!==""&&B==="currency",m=g=>{let f;if(p){const w=t.formatToParts(g);let S=!1;f="";for(const h of w)f+=h.value,!S&&h.type==="currency"&&(f+=k,S=!0);S||(f=k+f)}else f=k+t.format(g);return l&&(f=u(f)),f+y},b=g=>{if(M(g)||g==="")return D;const f=typeof g=="number"?g:Number(g);if(Number.isNaN(f))return D;const w=G===1?f:f*G;return w===0&&v!==void 0?v:w<0?c==="parentheses"?`(${m(-w)})`:c==="suffix"?`${m(-w)}-`:m(w):o&&w>0?`+${m(w)}`:m(w)};return b.negativeClass=_.negativeClass||null,b.spec=_,b}}),je("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 H}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.warnOnce,N=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(i){const a=[];let r=0,s="";const u=()=>{s&&(a.push({token:null,text:s}),s="")};for(;r<i.length;){const l=i[r];if(l==="'"){if(i[r+1]==="'"){s+="'",r+=2;continue}const m=i.indexOf("'",r+1);if(m===-1){s+=i.slice(r+1),r=i.length;continue}s+=i.slice(r+1,m),r=m+1;continue}const p=N.find(m=>i.startsWith(m,r));if(p){u(),a.push({token:p,text:p}),r+=p.length;continue}/[A-Za-z]/.test(l)&&I(`date.pattern.token:${l}`,`the date pattern "${i}" contains '${l}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${N.join(" ")}.`),s+=l,r+=1}return u(),a}const _=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function H(i){if(M(i)||i==="")return null;if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isNaN(i)?null:new Date(i);if(typeof i=="string"){const a=_.exec(i.trim());if(a){const[,s,u,l,p="0",m="0",b="0"]=a;return new Date(+s,+u-1,+l,+p,+m,+b)}const r=new Date(i);return Number.isNaN(r.getTime())?null:r}return null}function B(i,a){return String(i).padStart(a,"0")}function G(i){if(!i)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const a=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),r={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const u={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const l of a.formatToParts(s))switch(l.type){case"year":u.year=Number(l.value);break;case"month":u.month=Number(l.value);break;case"day":u.day=Number(l.value);break;case"hour":u.hour=Number(l.value)%24;break;case"minute":u.minute=Number(l.value);break;case"second":u.second=Number(l.value);break;case"weekday":u.weekday=r[l.value]??0;break;default:break}return u}}function D(i,a,r){const s=W(i),u=G(r),l=new Set(s.filter(f=>f.token).map(f=>f.token)),p=l.has("MMM")?new Intl.DateTimeFormat(a,{month:"short",timeZone:r}):null,m=l.has("MMMM")?new Intl.DateTimeFormat(a,{month:"long",timeZone:r}):null,b=l.has("EEE")?new Intl.DateTimeFormat(a,{weekday:"short",timeZone:r}):null,g=l.has("EEEE")?new Intl.DateTimeFormat(a,{weekday:"long",timeZone:r}):null;return f=>{const w=u(f);let S="";for(const h of s){if(!h.token){S+=h.text;continue}switch(h.token){case"yyyy":S+=B(w.year,4);break;case"yy":S+=B(w.year%100,2);break;case"MMMM":S+=m.format(f);break;case"MMM":S+=p.format(f);break;case"MM":S+=B(w.month,2);break;case"M":S+=String(w.month);break;case"dd":S+=B(w.day,2);break;case"d":S+=String(w.day);break;case"EEEE":S+=g.format(f);break;case"EEE":S+=b.format(f);break;case"HH":S+=B(w.hour,2);break;case"H":S+=String(w.hour);break;case"hh":S+=B(w.hour%12===0?12:w.hour%12,2);break;case"h":S+=String(w.hour%12===0?12:w.hour%12);break;case"mm":S+=B(w.minute,2);break;case"m":S+=String(w.minute);break;case"ss":S+=B(w.second,2);break;case"s":S+=String(w.second);break;case"SSS":S+=B(w.ms,3);break;case"a":S+=w.hour<12?"AM":"PM";break;default:S+=h.text;break}}return S}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function k(i,a){const r=i||{},s=r.locale||a||void 0,u=r.nullDisplay??"",l=r.timeZone;let p;if(r.pattern)p=D(r.pattern,s,l);else if(r.dateStyle||r.timeStyle){const w={timeZone:l};r.dateStyle&&(w.dateStyle=r.dateStyle),r.timeStyle&&(w.timeStyle=r.timeStyle);const S=new Intl.DateTimeFormat(s,w);p=h=>S.format(h)}else{const w=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:l});p=S=>w.format(S)}const m=r.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,g=(typeof r.relative=="object"&&r.relative?r.relative.threshold??7:7)*24*36e5,f=(w,S)=>{const h=H(w);if(!h)return u;if(m){const d=S&&typeof S.now=="number"?S.now:Date.now(),j=h.getTime()-d;if(Math.abs(j)<g){for(const[E,O]of v)if(Math.abs(j)>=O||E==="second")return m.format(Math.round(j/O),E)}}return p(h)};return f.spec=r,f}function y(i){if(M(i)||i==="")return null;if(typeof i=="string"){const s=/^(\d{4}-\d{2}-\d{2})/.exec(i.trim());if(s)return s[1];const u=H(i);return u?y(u):null}const a=H(i);if(!a)return null;const r=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${r(a.getMonth()+1)}-${r(a.getDate())}`}function c(i,a){if(M(i)||i==="")return null;if(typeof i=="string"){const s=i.trim();if(o.test(s)){const p=H(s);return p?n(p,a):null}const u=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(s);if(u){const[,p,m,b,g]=u;return`${p}T${m}:${b}${g&&g!=="00"?`:${g}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(s))return`${s}T00:00`;const l=H(s);return l?c(l):null}const r=H(i);return r?n(r,a):null}const o=/(?:Z|[+-]\d{2}:?\d{2})$/i;function n(i,a){const r=p=>String(p).padStart(2,"0");if(a)try{const p=new Intl.DateTimeFormat("en-CA",{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(i).reduce((g,f)=>(f.type!=="literal"&&(g[f.type]=f.value),g),{}),m=p.hour==="24"?"00":p.hour,b=Number(p.second);return`${p.year}-${p.month}-${p.day}T${m}:${p.minute}`+(b?`:${p.second}`:"")}catch{}const s=`${i.getFullYear()}-${r(i.getMonth()+1)}-${r(i.getDate())}`,u=i.getSeconds(),l=`${r(i.getHours())}:${r(i.getMinutes())}${u?`:${r(u)}`:""}`;return`${s}T${l}`}function t(i,a){const r=M(i)||i===""?null:String(i),s=M(a)||a===""?null:String(a);return r===null?s===null?0:1:s===null||r<s?-1:r>s?1:0}}),je("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 M=V("packages/core/src/internal/util.js").isNil,I={true:"☑",false:"☐",null:""},N={true:"◉",false:"◯",null:""};function W(H){if(M(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const B=String(H).trim().toLowerCase();return B==="true"||B==="yes"||B==="y"||B==="1"?!0:B==="false"||B==="no"||B==="n"||B==="0"?!1:null}function _(H,B){const G=H||{},D=G.display||"text",v=G.trueLabel??"Yes",k=G.falseLabel??"No",y=G.nullLabel??"";let c=v,o=k;const n=y;D==="checkbox"?(c=I.true,o=I.false):D==="switch"?(c=N.true,o=N.false):D==="icon"&&(c=G.trueIcon??v,o=G.falseIcon??k);const t=i=>{const a=W(i);return a===null?n:a?c:o};return t.display=D,t.labels={true:v,false:k,null:y},t.locale=B,t.spec=G,t}}),je("packages/core/src/format/text.js",function(e,V){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return N}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.titleCase;function N(W,_){const H=W||{},B=H.locale||_||void 0,G=H.nullDisplay??"",D=H.emptyDisplay??"",v=H.transform||"none",k=typeof H.truncate=="number"?{chars:H.truncate}:H.truncate||null,y=k?k.chars:0,c=k?k.ellipsis??"…":"",o=t=>{switch(v){case"upper":return B?t.toLocaleUpperCase(B):t.toUpperCase();case"lower":return B?t.toLocaleLowerCase(B):t.toLowerCase();case"title":return I(t);default:return t}},n=t=>{if(M(t))return G;let i=typeof t=="string"?t:String(t);return i===""?D:(v!=="none"&&(i=o(i)),y>0&&i.length>y&&(i=i.slice(0,y)+c),i)};return n.spec=H,n}}),je("packages/core/src/format/mask.js",function(e,V){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return _}});const Z=new Set(["0","#","?",",","."]),M="\0";function I(B){const G=[];let D="",v=!1;for(let k=0;k<B.length;k++){const y=B[k];if(y==="\\"){D+=y+(B[k+1]??""),k+=1;continue}if(y==='"'){v=!v,D+=y;continue}if(y===";"&&!v){G.push(D),D="";continue}D+=y}return G.push(D),G}function N(B){let G="",D="",v="",k=1,y=!1,c=!1;const o=p=>{c?D+=p:G+=p};for(let p=0;p<B.length;p++){const m=B[p];if(m==="\\"){o(B[p+1]??""),p+=1;continue}if(m==='"'){const b=B.indexOf('"',p+1);o(b===-1?B.slice(p+1):B.slice(p+1,b)),p=b===-1?B.length:b;continue}if(m==="%"){k*=100,o("%");continue}if(m==="@"){y=!0,o("\0");continue}if(Z.has(m)){v+=m,c=!0;continue}o(m)}let n=-1;for(let p=v.length-1;p>=0;p--){const m=v[p];if(m==="0"||m==="#"||m==="?"){n=p;break}}let t=!1,i="";for(let p=0;p<v.length;p++){const m=v[p];if(m===","){p>n?k/=1e3:t=!0;continue}i+=m}const a=i.indexOf("."),r=a===-1?i:i.slice(0,a),s=a===-1?"":i.slice(a+1);let u=0;for(const p of r)p==="0"&&(u+=1);let l=0;for(const p of s)p==="0"&&(l+=1);return{prefix:G,suffix:D,minInt:u,minDec:l,maxDec:s.length,grouping:t,scale:k,hasNumber:n!==-1,isText:y}}function W(B,G){const D=new Intl.NumberFormat(G,{minimumIntegerDigits:Math.max(B.minInt,1),minimumFractionDigits:B.minDec,maximumFractionDigits:Math.max(B.maxDec,B.minDec),useGrouping:B.grouping}),{prefix:v,suffix:k,scale:y,hasNumber:c}=B;return o=>{if(!c)return v+k;const n=y===1?o:o*y;return v+D.format(n)+k}}function _(B,G){const v=I(String(B)).map(N),k=v.map(i=>W(i,G)),y=0,c=v.length>1?1:-1,o=v.length>2?2:-1,n=v.length>3?3:-1,t=i=>{if(i==null||i==="")return"";if(typeof i!="number"||Number.isNaN(i)){const a=Number(i);if(Number.isNaN(a))return n===-1?String(i):(v[n].prefix+v[n].suffix).split("\0").join(String(i));i=a}return i===0&&o!==-1?k[o](0):i<0&&c!==-1?k[c](-i):k[y](i)};return t.spec={mask:B},{format:t,ooxml:H(String(B))}}function H(B){return B.trim()}}),je("packages/core/src/format/shorthand.js",function(e,V){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const Z=["currency","number","percent","date","boolean","text","relative"],M=/[#0?@;"\\]/,I=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function N(B){return typeof B!="string"||B===""||_(B)?!1:M.test(B)}function W(B){return typeof B!="string"||B===""||_(B)?!1:I.test(B)}function _(B){const G=B.indexOf(":"),D=G===-1?B:B.slice(0,G);return Z.includes(D)?D:null}function H(B){const G=_(B);if(!G)return null;const D=B.indexOf(":"),v=D===-1?"":B.slice(D+1),k=v===""?[]:v.split(":");switch(G){case"currency":{const y={type:"number",style:"currency",currency:k[0]||"USD"};return k[1]!==void 0&&k[1]!==""&&(y.decimals=Number(k[1])),y}case"number":{const y={type:"number",style:"decimal"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"percent":{const y={type:"number",style:"percent"};return k[0]!==void 0&&k[0]!==""&&(y.decimals=Number(k[0])),y}case"date":return{type:"date",pattern:v||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=v.split("/"),c={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(c.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(c.falseLabel=y[1]),y[2]!==void 0&&(c.nullLabel=y[2]),c}case"text":{const y={type:"text"};return k[0]&&(y.transform=k[0]),k[1]!==void 0&&k[1]!==""&&(y.truncate=Number(k[1])),y}default:return null}}}),je("packages/core/src/format/index.js",function(e,V){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return f}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.isObject,N=Z.warnOnce,W=V("packages/core/src/format/number.js"),_=W.compileNumber,H=V("packages/core/src/format/date.js"),B=H.compileDate,G=H.scanPattern,D=V("packages/core/src/format/boolean.js"),v=D.compileBoolean,k=V("packages/core/src/format/text.js"),y=k.compileText,c=V("packages/core/src/format/mask.js"),o=c.compileMask,n=V("packages/core/src/format/shorthand.js"),t=n.parseShorthand,i=n.looksLikeMask,a=n.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return H.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return H.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return H.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return H.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return D.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return D.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return k.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return c.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return c.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return c.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return n.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return n.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return n.looksLikeDatePattern}});const r=new Set(["decimal","currency","percent","unit"]),s=new Set(["type","locale"]),u={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])};function l(d,j,E){const O=u[j],T=E?`"${E}"`:"with no id";for(const A of d){if(s.has(A)||O.has(A))continue;const P=Object.keys(u).find(L=>L!==j&&u[L].has(A));P?N(`format:inapplicable:${E||""}:${A}`,`column ${T} has format key "${A}", which applies to a ${P} column, not the ${j} column it was applied to; it is ignored.`):N(`format:unknown:${E||""}:${A}`,`column ${T} has an unrecognised format key "${A}" for its ${j} format; it is ignored.`)}}function p(d){if(d.type==="number"||d.type==="date"||d.type==="boolean"||d.type==="text")return!0;const j=r.has(String(d.style));return!!(d.pattern||d.dateStyle||d.timeStyle||d.relative||d.timeZone||d.trueLabel||d.falseLabel||d.display||d.trueIcon||d.falseIcon||d.transform||d.truncate||d.emptyDisplay||j||d.currency||d.decimals!==void 0||d.minDecimals!==void 0||d.maxDecimals!==void 0||d.notation||d.negative||d.scale!==void 0||d.prefix||d.suffix||d.zeroDisplay!==void 0)}function m(d,j){if(d.type==="number"||d.type==="date"||d.type==="boolean"||d.type==="text")return d.type;if(d.pattern||d.dateStyle||d.timeStyle||d.relative||d.timeZone)return"date";if(d.trueLabel||d.falseLabel||d.display||d.trueIcon||d.falseIcon)return"boolean";if(d.transform||d.truncate||d.emptyDisplay)return"text";if(d.style||d.currency||d.decimals!==void 0||d.minDecimals!==void 0||d.maxDecimals!==void 0||d.notation||d.negative||d.scale!==void 0||d.prefix||d.suffix||d.zeroDisplay!==void 0)return"number";const E=j&&j.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function b(d,j=null,E=void 0,O=void 0,T=void 0){if(d==null||d==="")return null;const A=I(d)?Object.keys(d):null;if(typeof d=="function"){const $=(U,x)=>String(d({...x||{},value:U,locale:E})??"");return $.ooxml=j&&j.excel||"General",$}if(typeof d=="string"){if(i(d)){const{format:U,ooxml:x}=o(d,E);return U.ooxml=x,U}const $=t(d)||(a(d)?{type:"date",pattern:d}:null);return $?b($,j,E,O,T):(N(`format:${d}`,`unrecognised format string "${d}"; the value will be stringified`),null)}if(!I(d))return N("format:shape","format must be a spec object or a string; ignoring",d),null;if(j&&M(j.format)&&!p(d)||j&&M(j.format)&&Array.isArray(j.formatPatterns)&&d.type===void 0)return null;const P=m(d,j);P==="date"&&O&&d.timeZone===void 0&&(d={...d,timeZone:O}),l(A||Object.keys(d),P,T);let L;switch(P){case"number":L=_(d,E);break;case"date":L=B(d,E);break;case"boolean":L=v(d,E);break;default:L=y(d,E);break}return L.ooxml=f(d,P,E,j),L.kind=P,L}const g={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 f(d,j,E=void 0,O=null){if(j==="date"){if(d.pattern){let $="";for(const U of G(d.pattern))$+=U.token?g[U.token]??U.text:U.text;return $}return O&&O.excel||"yyyy-mm-dd"}if(j==="boolean")return"General";if(j==="text")return"@";if(d.notation==="compact"||d.notation==="scientific")return"General";const T=typeof d.decimals=="number"?d.decimals:typeof d.minDecimals=="number"?d.minDecimals:d.style==="currency"?2:0;let P=`${d.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,L="";return d.style==="currency"&&(L+=w(h(d.currency||"USD",E))),d.prefix&&(L+=w(d.prefix)),P=L+P,d.style==="percent"&&(P=`${P}%`),d.suffix&&(P+=w(d.suffix)),d.negative==="parentheses"?`${P};(${P})`:d.negative==="suffix"?`${P};${P}-`:P}function w(d){return`"${String(d).split('"').join("")}"`}const S=new Map;function h(d,j){const E=`${d}|${j||""}`;let O=S.get(E);if(O!==void 0)return O;O=d;try{const A=new Intl.NumberFormat(j,{style:"currency",currency:d}).formatToParts(0).find(P=>P.type==="currency");A&&(O=A.value)}catch{}return S.set(E,O),O}}),je("packages/core/src/columns/types/temporal.js",function(e,V){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return nt}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.isFunction,N=V("packages/core/src/format/date.js"),W=N.toDate,_=N.compilePattern,H=N.compileDate,B=N.toIsoDateTime,G=N.compareIso,D=864e5,v=Object.freeze({}),k=1e3,y=60*k,c=60*y,o=24*c,n=7*o,t=new WeakMap;function i(Pe,Ge){const He=Pe&&Pe.locale||"",Ye=Pe&&Pe.column;if(!Ye)return He?{locale:He}:v;const st=t.get(Ye);if(st&&st.locale===He)return st.bag;const ht=Ye.typeOptions||Ye[Ge]||(a(Ye.format)?Ye.format:null),bt={...ht||v,locale:ht&&ht.locale||He||void 0};return t.set(Ye,{locale:He,bag:bt}),bt}function a(Pe){return Pe!==null&&typeof Pe=="object"&&!Array.isArray(Pe)&&!(Pe instanceof Date)}function r(Pe,Ge){const He=Pe===null||Number.isNaN(Pe)?null:Pe,Ye=Ge===null||Number.isNaN(Ge)?null:Ge;return He===null?Ye===null?0:1:Ye===null||He<Ye?-1:He>Ye?1:0}const s=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function l(Pe,Ge,He,Ye){return!(Pe>=0&&Pe<=23)||!(Ge>=0&&Ge<=59)||!(He>=0&&He<=59)||!(Ye>=0&&Ye<=999)?null:Pe*c+Ge*y+He*k+Ye}function p(Pe){if(M(Pe))return null;const Ge=String(Pe).trim();if(Ge==="")return null;const He=u.exec(Ge);if(He){const Dt=He[1];if(Dt.length===5)return null;const It=Dt.length===3?1:2;return l(Number(Dt.slice(0,It)),Number(Dt.slice(It,It+2)),Number(Dt.slice(It+2,It+4)||0),0)}const Ye=s.exec(Ge);if(!Ye)return null;let st=Number(Ye[1]);const ht=Number(Ye[2]||0),bt=Number(Ye[3]||0),At=Ye[4]?Number(Ye[4].padEnd(3,"0")):0,Tt=Ye[5]?Ye[5][0].toLowerCase():null;if(Tt){if(st<1||st>12)return null;st=st%12,Tt==="p"&&(st+=12)}return l(st,ht,bt,At)}function m(Pe){return M(Pe)||Pe===""?null:typeof Pe=="number"?Number.isFinite(Pe)?(Pe%o+o)%o:null:Pe instanceof Date?Number.isNaN(Pe.getTime())?null:Pe.getHours()*c+Pe.getMinutes()*y+Pe.getSeconds()*k+Pe.getMilliseconds():p(Pe)}const b=new Map;function g(Pe){const Ge=Pe.pattern||"",He=Pe.timeStyle||(Pe.seconds?"medium":"short"),Ye=`${Pe.locale||""}|${Ge}|${He}`;let st=b.get(Ye);if(st)return st;if(Ge)st=_(Ge,Pe.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(Pe.locale||void 0,{timeStyle:He,timeZone:"UTC"});st=bt=>ht.format(bt)}return b.set(Ye,st),st}function f(Pe,Ge){const He=Ge||v;if(Pe==null||typeof Pe!="number"||!Number.isFinite(Pe))return He.nullDisplay??"";const Ye=(Pe%o+o)%o;return g(He)(new Date(Ye))}function w(Pe){return Pe instanceof Date?!Number.isNaN(Pe.getTime()):typeof Pe=="number"?Number.isFinite(Pe)&&Pe>=0&&Pe<o:typeof Pe!="string"||!Pe.includes(":")?!1:p(Pe)!==null}function S(Pe){const Ge=m(Pe);return Ge==null?"":f(Ge,{pattern:Ge%k===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const h=new Map;function d(Pe){const Ge=Pe||"";let He=h.get(Ge);return He||(He=new Intl.DateTimeFormat("en-GB",{timeZone:Pe||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),h.set(Ge,He)),He}function j(Pe,Ge){const He={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ye of d(Ge).formatToParts(new Date(Pe)))Ye.type==="year"?He.year=Number(Ye.value):Ye.type==="month"?He.month=Number(Ye.value):Ye.type==="day"?He.day=Number(Ye.value):Ye.type==="hour"?He.hour=Number(Ye.value)%24:Ye.type==="minute"?He.minute=Number(Ye.value):Ye.type==="second"&&(He.second=Number(Ye.value));return He}function E(Pe,Ge){const He=j(Pe,Ge);return Date.UTC(He.year,He.month-1,He.day,He.hour,He.minute,He.second,0)-Math.floor(Pe/1e3)*1e3}function O(Pe,Ge){const He=Pe.hour||0,Ye=Pe.minute||0,st=Pe.second||0,ht=Pe.ms||0;if(!Ge)return new Date(Pe.year,Pe.month-1,Pe.day,He,Ye,st,ht).getTime();const bt=Date.UTC(Pe.year,Pe.month-1,Pe.day,He,Ye,st,ht);let At=bt-E(bt,Ge);return At=bt-E(At,Ge),At}const T=/(?:Z|[+-]\d{2}:?\d{2})$/i,A=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Pe,Ge){if(M(Pe))return null;const He=String(Pe).trim();if(He==="")return null;const Ye=Ge&&Ge.timeZone||void 0;if(!T.test(He)){const st=A.exec(He);if(st){const ht=(st[4]||"").trim(),bt=ht===""?0:p(ht);if(bt===null)return null;const At=O({year:Number(st[1]),month:Number(st[2]),day:Number(st[3]),hour:Math.floor(bt/c),minute:Math.floor(bt/y)%60,second:Math.floor(bt/k)%60,ms:bt%k},Ye);return Number.isNaN(At)?null:new Date(At)}}return W(He)}function L(Pe){if(typeof Pe=="number")return Number.isFinite(Pe)?Pe:null;const Ge=W(Pe);return Ge?Ge.getTime():null}const $=new Map;function U(Pe){const Ge=[Pe.locale||"",Pe.pattern||"",Pe.dateStyle||"",Pe.timeStyle||"",Pe.timeZone||"",Pe.seconds?"1":""].join("|");let He=$.get(Ge);if(He)return He;const Ye=Pe.pattern?{type:"date",pattern:Pe.pattern,timeZone:Pe.timeZone}:{type:"date",dateStyle:Pe.dateStyle||"medium",timeStyle:Pe.timeStyle||(Pe.seconds?"medium":"short"),timeZone:Pe.timeZone};return He=H(Ye,Pe.locale||void 0),$.set(Ge,He),He}function x(Pe,Ge){const He=Ge||v,Ye=L(Pe);return Ye==null?He.nullDisplay??"":U(He)(Ye)}function F(Pe){return Pe instanceof Date?!Number.isNaN(Pe.getTime()):typeof Pe!="string"||!A.test(Pe.trim())?!1:P(Pe)!==null}const C=Object.freeze([{key:"w",ms:n,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:c,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:k,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"]}]),z=new Map;for(const Pe of C)for(const Ge of Pe.names)z.set(Ge,Pe);const q=Object.freeze(C.filter(Pe=>Pe.key!=="w")),Q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function te(Pe){const Ge=Pe&&Pe.defaultUnit?z.get(String(Pe.defaultUnit).toLowerCase()):null;return Ge?Ge.ms:y}function ee(Pe){return(Pe&&Pe.defaultUnit?z.get(String(Pe.defaultUnit).toLowerCase()):null)||z.get("m")}function re(Pe,Ge){if(M(Pe))return null;let He=String(Pe).trim().toLowerCase();if(He==="")return null;let Ye=1;if(He[0]==="-"?(Ye=-1,He=He.slice(1).trim()):He[0]==="+"&&(He=He.slice(1).trim()),He==="")return null;const st=J.exec(He);if(st){const Tt=st[3]!==void 0,Dt=Number(st[1])*c+Number(st[2])*y+(Tt?Number(st[3])*k:0)+(st[4]?Number(st[4].padEnd(3,"0")):0);return Ye*Dt}if(Y.test(He))return Math.round(Ye*Number(He)*te(Ge||v));let ht=He,bt=0,At=0;for(;ht!=="";){const Tt=Q.exec(ht);if(!Tt)return null;const Dt=z.get(Tt[2]);if(!Dt)return null;bt+=Number(Tt[1])*Dt.ms,ht=ht.slice(Tt[0].length),At++}return At===0?null:Math.round(Ye*bt)}function se(Pe){return M(Pe)||Pe===""?null:typeof Pe=="number"?Number.isFinite(Pe)?Pe:null:re(Pe)}const de=new Map;function ie(Pe,Ge,He){const Ye=`${He||""}|${Ge.intl}`;let st=de.get(Ye);if(st===void 0){try{st=new Intl.NumberFormat(He||void 0,{style:"unit",unit:Ge.intl,unitDisplay:"long"})}catch{st=null}de.set(Ye,st)}return st?st.format(Pe):`${Pe} ${Pe===1?Ge.long[0]:Ge.long[1]}`}function oe(Pe,Ge){return String(Pe).padStart(Ge,"0")}function ue(Pe,Ge){const He=Ge||v;if(Pe==null||typeof Pe!="number"||!Number.isFinite(Pe))return He.nullDisplay??"";const Ye=He.style||"short",st=Pe<0;let ht=Math.round(Math.abs(Pe));const bt=st?"-":"";if(ht===0&&He.zeroDisplay!=null)return He.zeroDisplay;if(Ye==="clock"){const It=Math.floor(ht/c),Gt=Math.floor(ht/y)%60,Yt=Math.floor(ht/k)%60;return`${bt}${oe(It,2)}:${oe(Gt,2)}:${oe(Yt,2)}`}if(ht===0){const It=ee(He);return Ye==="long"?ie(0,It,He.locale):`0${It.key}`}const At=He.weeks===!0?C:q,Tt=typeof He.maxUnits=="number"&&He.maxUnits>0?He.maxUnits:He.maxUnits===void 0?2:1/0,Dt=[];for(const It of At){if(Dt.length>=Tt)break;const Gt=Math.floor(ht/It.ms);Gt!==0&&(ht-=Gt*It.ms,Dt.push(Ye==="long"?ie(Gt,It,He.locale):`${Gt}${It.key}`))}return bt+Dt.join(" ")}function ce(Pe){if(typeof Pe!="string")return!1;const Ge=Pe.trim();return Ge===""||J.test(Ge)||!/[a-z]/i.test(Ge)?!1:re(Ge)!==null}const pe=Date.UTC(1899,11,30),Me=new Map;function $e(Pe,Ge){const He=Pe||"";let Ye=Me.get(He);Ye||(Ye=new Intl.DateTimeFormat("en-GB",{timeZone:Pe||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Me.set(He,Ye));const st=typeof Ge=="number"?Ge:Date.now();for(const ht of Ye.formatToParts(new Date(st)))if(ht.type==="timeZoneName")return ht.value;return""}function Ae(Pe){if(Pe)return Pe;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(Pe,Ge){const He=Ae(Pe),Ye=$e(Pe,Ge);return Ye?`${He} (${Ye})`:He}function ge(Pe,Ge){if(Pe&&Pe.timeZone)return Pe.timeZone;const He=Ge&&Ge.grid;return(He&&I(He.get)?He.get("timeZone"):void 0)||void 0}function Ee(Pe,Ge){const He=Ge||v,Ye=L(Pe);if(Ye==null)return He.nullDisplay??"";const st=U(He)(Ye);if(!He.showOrigin)return st;const ht=He.originZone;return ht?ht===(He.timeZone||Ae(He.timeZone))?st:`${st} (${ke(ht,Ye)})`:`${st} (no origin recorded)`}function De(Pe,Ge,He,Ye){if(Ge==="instant"||!Ge)return Pe;const st=j(Pe,He);if(Ge==="month")return O({year:st.year,month:st.month,day:1},He);if(Ge==="week"){const ht=Ye>=1&&Ye<=7?Ye:1,At=((new Date(Date.UTC(st.year,st.month-1,st.day)).getUTCDay()+6)%7+1-ht+7)%7,Tt=new Date(Date.UTC(st.year,st.month-1,st.day-At));return O({year:Tt.getUTCFullYear(),month:Tt.getUTCMonth()+1,day:Tt.getUTCDate()},He)}return O({year:st.year,month:st.month,day:st.day},He)}function ze(Pe,Ge){const He=Pe&&Pe.group,Ye=He&&He.granularity||"day";if(Ye==="instant")return null;const st=He&&He.weekStart;return ht=>typeof ht=="number"?De(ht,Ye,Ge,st):ht}const qe={time:{base:"number",storage:"float64",matches:w,format:Pe=>f(m(Pe.value),i(Pe,"time")),parse:Pe=>p(Pe.text),compare:(Pe,Ge)=>r(m(Pe),m(Ge)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Pe=>{const Ge=m(Pe);return Ge===null?null:Ge/D},toStorage:Pe=>m(Pe),toClipboard:S,fromClipboard:p},datetime:{base:"dateString",storage:"dictionary",matches:F,format:Pe=>x(Pe.value,i(Pe,"datetime")),parse:Pe=>B(P(Pe.text,i(Pe,"datetime"))??Pe.text),compare:G,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Pe,Ge)=>B(Pe,Ge&&Ge.timeZone),toClipboard:Pe=>M(Pe)?"":String(Pe),fromClipboard:Pe=>B(Pe)},duration:{base:"number",storage:"float64",matches:ce,format:Pe=>ue(se(Pe.value),i(Pe,"duration")),parse:Pe=>re(Pe.text,i(Pe,"duration")),compare:(Pe,Ge)=>r(se(Pe),se(Ge)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Pe=>{const Ge=se(Pe);return Ge===null?null:Ge/D},toStorage:Pe=>se(Pe),toClipboard:Pe=>ue(se(Pe),{style:"short",maxUnits:-1}),fromClipboard:Pe=>re(Pe)},timestamp:{base:"number",storage:"float64",format:Pe=>{const Ge=i(Pe,"timestamp");return Ee(Pe.value,{...Ge,timeZone:ge(Ge,Pe)})},parse:Pe=>{const Ge=i(Pe,"timestamp"),He=P(Pe.text,{timeZone:ge(Ge,Pe)});return He?He.getTime():null},compare:(Pe,Ge)=>r(L(Pe),L(Ge)),groupProjector:(Pe,Ge)=>ze(Pe,Ge),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Pe,Ge)=>{const He=L(Pe);if(He==null)return null;const Ye=j(He,Ge&&Ge.timeZone||void 0);return(Date.UTC(Ye.year,Ye.month-1,Ye.day,Ye.hour,Ye.minute,Ye.second)-pe)/D},toStorage:Pe=>L(Pe),toClipboard:Pe=>{const Ge=L(Pe);return Ge==null?"":new Date(Ge).toISOString()},fromClipboard:Pe=>L(Pe)}},Xe=["datetime","time","duration"],nt=qe}),je("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 H}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.Lru,N=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function _(L){if(M(L))return null;if(typeof L=="string")return H(L);const $=Number(L);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>N?null:Math.trunc($)>>>0:null}function H(L){if(M(L))return null;const $=String(L).trim();if($==="")return null;const U=W.exec($);if(!U)return null;let x=0;for(let F=1;F<=4;F++){const C=U[F];if(C.length>1&&C.charCodeAt(0)===48)return null;const z=Number(C);if(z>255)return null;x=x*256+z}return x}function B(L){const $=_(L);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function G(L){return typeof L=="string"&&H(L)!==null}function D(L,$){const U=_(L),x=_($);return U===null?x===null?0:1:x===null||U<x?-1:U>x?1:0}const v=64,k=N*v+32,y=/^(?:0|[1-9]\d?)$/;function c(L,$){return L*v+$}function o(L){if(M(L))return null;if(typeof L=="string"){const x=n(L);return x===null?null:o(x)}if(typeof L=="object"){const x=_(L.address),F=Number(L.prefix);return x===null||!Number.isInteger(F)||F<0||F>32?null:{address:x,prefix:F}}const $=Number(L);if(!Number.isInteger($)||$<0||$>k)return null;const U=$%v;return U>32?null:{address:($-U)/v,prefix:U}}function n(L){if(M(L))return null;const $=String(L).trim();if($==="")return null;const U=$.indexOf("/");if(U<0)return null;const x=H($.slice(0,U));if(x===null)return null;const F=$.slice(U+1).trim();if(!y.test(F))return null;const C=Number(F);return C>32?null:c(x,C)}function t(L){const $=o(L);return $?`${B($.address)}/${$.prefix}`:""}function i(L){return typeof L=="string"&&n(L)!==null}function a(L,$){const U=o(L),x=o($);return U?x?U.address!==x.address?U.address<x.address?-1:1:U.prefix-x.prefix:-1:x?1:0}function r(L){return L===0?0:4294967295<<32-L>>>0}function s(L){const $=o(L);return $?($.address&r($.prefix))>>>0:null}function u(L){const $=o(L);return $?($.address&r($.prefix)|~r($.prefix)>>>0)>>>0:null}function l(L){const $=o(L);return $?2**(32-$.prefix):null}function p(L){const $=o(L);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function m(L,$){const U=o(L);if(!U)return!1;const x=_($);if(x===null)return!1;const F=r(U.prefix);return(x&F)>>>0===(U.address&F)>>>0}function b(L,$){const U=s(L),x=s($);return U===null||x===null?!1:U<=u($)&&x<=u(L)}const g=/^[0-9a-fA-F]{1,4}$/,f=new I(512);function w(L){if(M(L))return null;let $=String(L).trim();if($==="")return null;const U=$.indexOf("%");if(U>=0&&($=$.slice(0,U)),$==="")return null;if($.indexOf(".")>=0){const Q=$.lastIndexOf(":");if(Q<0)return null;const Y=H($.slice(Q+1));if(Y===null)return null;$=`${$.slice(0,Q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const x=$.split("::");if(x.length>2)return null;const F=S(x[0]);if(F===null)return null;if(x.length===1)return F.length===8?F:null;const C=S(x[1]);if(C===null)return null;const z=8-F.length-C.length;if(z<1)return null;const q=F.slice();for(let Q=0;Q<z;Q++)q.push(0);for(const Q of C)q.push(Q);return q}function S(L){if(L==="")return[];const $=[];for(const U of L.split(":")){if(!g.test(U))return null;$.push(parseInt(U,16))}return $}function h(L){if(typeof L!="string")return w(L);if(f.has(L))return f.get(L);const $=w(L);return f.set(L,$),$}function d(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${B((L[6]<<16|L[7])>>>0)}`;let $=-1,U=0,x=-1,F=0;for(let q=0;q<8;q++)L[q]===0?(x<0?(x=q,F=1):F++,F>U&&(U=F,$=x)):(x=-1,F=0);if(U<2)return L.map(q=>q.toString(16)).join(":");const C=L.slice(0,$).map(q=>q.toString(16)).join(":"),z=L.slice($+U).map(q=>q.toString(16)).join(":");return`${C}::${z}`}function j(L){const $=w(L);return $===null?null:d($)}function E(L){return j(L)??""}function O(L){return typeof L=="string"&&L.indexOf(":")>=0&&w(L)!==null}function T(L,$){const U=h(L),x=h($);if(!U)return x?1:0;if(!x)return-1;for(let F=0;F<8;F++)if(U[F]!==x[F])return U[F]<x[F]?-1:1;return 0}const A=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:G,parse:L=>H(L.text),compare:D,format:L=>B(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>_(L),toClipboard:L=>B(L),fromClipboard:L=>H(L)},cidr:{base:"number",storage:"float64",matches:i,parse:L=>n(L.text),compare:a,format:L=>t(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const $=o(L);return $===null?null:c($.address,$.prefix)},toClipboard:L=>t(L),fromClipboard:L=>n(L)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:L=>j(L.text),compare:T,format:L=>E(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>j(L),toClipboard:L=>E(L),fromClipboard:L=>j(L)}}),P=A}),je("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 M}});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.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.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"}),M=Object.freeze(Object.keys(Z))}),je("packages/core/src/i18n/format.js",function(e,V){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return k}});const M=V("packages/core/src/internal/util.js").isFunction,I=/\{(\w+)\}/g,N=new Map,W=new Map;function _(y){const c=y||"";if(N.has(c))return N.get(c);let o=null;try{o=new Intl.PluralRules(y||void 0)}catch{o=null}return N.set(c,o),o}function H(y,c,o="conjunction"){const n=Array.isArray(y)?y.filter(a=>a!=null&&a!==""):[];if(n.length===0)return"";if(n.length===1)return String(n[0]);const t=`${c||""}|${o}`;let i=W.get(t);if(i===void 0){try{i=new Intl.ListFormat(c||void 0,{style:"long",type:o})}catch{i=null}W.set(t,i)}return i?i.format(n.map(String)):n.map(String).join(", ")}function B(y,c){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(c||void 0,{maximumFractionDigits:20}):"":String(y)}function G(y,c,o){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const n=c&&typeof c.count=="number"?c.count:null;if(n===null)return y.other??"";const t=_(o),i=t?t.select(n):n===1?"one":"other";return y[i]??y.other??""}function D(y,c={},o){const n=G(y,c,o);return n?n.replace(I,(t,i)=>Object.prototype.hasOwnProperty.call(c,i)?B(c[i],o):t):""}function v(y,c,o="en-GB"){return typeof y=="string"&&y?y:typeof c=="string"&&c?c:o}function k(y,c){const o=y?y[c]:void 0;return o==null||M(o)?c:o}}),je("packages/core/src/i18n/index.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return n}});const Z=V("packages/core/src/i18n/catalogue.js"),M=Z.EN_GB,I=Z.MESSAGE_KEYS,N=V("packages/core/src/i18n/format.js"),W=N.formatMessage,_=N.formatList,H=N.lookup,B=N.resolveLocale,G=V("packages/core/src/internal/util.js"),D=G.isFunction,v=G.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 N.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return N.resolveLocale}});const k="en-GB";class y{#e=k;#t=M;constructor(i={}){this.configure(i)}configure(i={}){this.#e=B(i.locale,i.declared,k);const a=i.messages;if(!a||typeof a!="object"){this.#t=M;return}const r=Object.keys(a).filter(s=>!(s in M));r.length&&v(`i18n:unknown:${r[0]}`,`message keys not in the catalogue and so ignored: ${r.slice(0,5).join(", ")}${r.length>5?`, and ${r.length-5} more`:""}`),this.#t={...M,...a}}get locale(){return this.#e}t(i,a){return W(H(this.#t,i),a||{},this.#e)}list(i,a){return _(i,this.#e,a)}number(i,a){const r=Number(i);return Number.isFinite(r)?r.toLocaleString(this.#e,a||{maximumFractionDigits:20}):""}}const c=new y;function o(t){return t instanceof y?t:new y(t||{})}function n(t){const i=t&&typeof t=="object"?t:{},a=I.filter(s=>{const u=i[s];return u==null||u===""||D(u)}),r=Object.keys(i).filter(s=>!(s in M));return{missing:a,unknown:r}}}),je("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 H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return v}}),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 n}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.isObject,W=V("packages/core/src/i18n/index.js").defaultMessages,_=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,i){const a=i||{},r=a.emptyDisplay??_.emptyDisplay;if(M(t)||t==="")return r;const u=[...typeof a.char=="string"&&a.char!==""?a.char:_.char][0]||_.char,l=a.fixedLength??_.fixedLength,p=Number.isFinite(a.length)&&Number(a.length)>0?Math.floor(Number(a.length)):_.length,m=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let b=0;if(m!==null){const g=Number.isFinite(a.lastVisible)?Math.floor(Number(a.lastVisible)):_.lastVisible,f=[...m];if(b=g>0&&g<f.length?g:0,b>0){const w=f.slice(f.length-b).join(""),S=Math.max(1,(l?p:f.length)-b);return u.repeat(S)+w}return u.repeat(l?p:Math.max(1,f.length))}return u.repeat(p)}const B=48;function G(t){try{const i=JSON.stringify(t);return i===void 0?null:i}catch{return null}}function D(t,i){if(M(t))return"";const a=Number.isFinite(i&&i.inlineLimit)?Number(i.inlineLimit):B;if(typeof t=="string")return t.length>a?`${t.slice(0,a-1)}…`:t;if(typeof t!="object")return String(t);const r=G(t);if(r!==null&&r.length<=a)return r;if(Array.isArray(t)){const u=t.length;return`[${W.t("count.items",{count:u})}]`}const s=Object.keys(t).length;return`{${W.t("count.keys",{count:s})}}`}function v(t,i){if(t==null)return"null";const a=typeof t;if(a==="number"||a==="boolean"||a==="bigint")return String(t);if(a==="string")return JSON.stringify(t);if(a!=="object")return JSON.stringify(String(t));const r=i||new WeakSet;return r.has(t)?'"[circular]"':(r.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(l=>v(l,r)).join(",")}]`:`{${Object.keys(t).sort().map(l=>`${JSON.stringify(l)}:${v(t[l],r)}`).join(",")}}`)}function k(t,i){if(M(t))return M(i)?0:1;if(M(i))return-1;const a=v(t),r=v(i);return a<r?-1:a>r?1:0}function y(t){if(M(t))return null;const i=String(t);if(i.trim()==="")return null;try{return JSON.parse(i)}catch{return i}}function c(t){const i=t&&t.cell&&t.cell.props;return I(i)?i:{}}const o=Object.freeze({json:{base:"object",storage:"object",format:t=>D(t&&t.value,c(t&&t.column)),parse:t=>y(t&&t.text),compare:k,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(M(t))return"";if(typeof t=="string")return t;try{const i=JSON.stringify(t,null,2);return i===void 0?String(t):i}catch{return String(t)}},fromClipboard:t=>y(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,c(t&&t.column)),parse:t=>{const i=t&&t.text;return M(i)||String(i)===""?null:String(i)},compare:(t,i)=>{const a=M(t)||t==="",r=M(i)||i==="";return a===r?0:a?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>M(t)||String(t)===""?null:String(t)}}),n=o}),je("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 D}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.warnOnce;function N(F,C,z,q){return Object.freeze({symbol:F,factor:C,aliases:Object.freeze(z||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(F,C,z,q){return N(F,C,z,q)}const _=Object.freeze({data:Object.freeze([N("B",1,["byte","bytes"]),N("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),N("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),N("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),N("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),N("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),N("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),N("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),N("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),N("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([N("bps",1,["bit","bits","bit/s","b/s"]),N("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),N("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),N("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),N("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([N("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),N("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),N("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),N("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),N("in",.0254,["inch","inches"],{auto:!1}),N("ft",.3048,["foot","feet"],{auto:!1}),N("yd",.9144,["yard","yards"],{auto:!1}),N("m",1,["metre","metres","meter","meters"]),N("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),N("mi",1609.344,["mile","miles"],{auto:!1}),N("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([N("mg",.001,["milligram","milligrams"]),N("g",1,["gram","grams"]),N("oz",28.349523125,["ounce","ounces"],{auto:!1}),N("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),N("kg",1e3,["kilogram","kilograms"]),N("st",6350.29318,["stone"],{auto:!1}),N("t",1e6,["tonne","tonnes","ton"],{auto:!1}),N("ton (US)",907184.74,["ton","shortton"],{auto:!1}),N("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([N("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),N("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),N("ms",.001,["msec","msecs","millisecond","milliseconds"]),N("s",1,["sec","secs","second","seconds"]),N("m",60,["min","mins","minute","minutes"]),N("h",3600,["hr","hrs","hour","hours"]),N("d",86400,["day","days"])]),speed:Object.freeze([N("mm/s",.001,["millimetre/s","millimeter/s"]),N("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),N("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),N("mph",.44704,["mile/h","miles/h"],{auto:!1}),N("kn",1852/3600,["knot","knots"],{auto:!1}),N("m/s",1,["metre/s","meter/s","mps"]),N("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([N("mm/s²",.001,["mm/s2"]),N("ft/s²",.3048,["ft/s2"],{auto:!1}),N("m/s²",1,["m/s2","metre/s2","meter/s2"]),N("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([N("mm²",1e-6,["mm2"]),N("cm²",1e-4,["cm2"]),N("in²",64516e-8,["in2","sqin"],{auto:!1}),N("ft²",.09290304,["ft2","sqft"],{auto:!1}),N("yd²",.83612736,["yd2","sqyd"],{auto:!1}),N("m²",1,["m2","sqm"]),N("ha",1e4,["hectare","hectares"],{auto:!1}),N("ac",4046.8564224,["acre","acres"],{auto:!1}),N("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([N("µL",1e-6,["ul","microlitre","microliter"]),N("mL",.001,["millilitre","milliliter"]),N("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),N("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),N("L",1,["litre","litres","liter","liters"]),N("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),N("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),N("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),N("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([N("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),N("J",1,["joule","joules"]),N("cal",4.184,["calorie","calories"],{auto:!1}),N("kJ",1e3,["kilojoule","kilojoules"]),N("BTU",1055.05585262,["btu"],{auto:!1}),N("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),N("MJ",1e6,["megajoule","megajoules"]),N("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),N("GJ",1e9,["gigajoule","gigajoules"]),N("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([N("mW",.001,["milliwatt","milliwatts"]),N("W",1,["watt","watts"]),N("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),N("kW",1e3,["kilowatt","kilowatts"]),N("hp",745.6998715822702,["horsepower"],{auto:!1}),N("MW",1e6,["megawatt","megawatts"]),N("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([N("mN",.001,["millinewton","millinewtons"]),N("N",1,["newton","newtons"]),N("lbf",4.4482216152605,["poundforce"],{auto:!1}),N("kgf",9.80665,["kilogramforce"],{auto:!1}),N("kN",1e3,["kilonewton","kilonewtons"]),N("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([N("Pa",1,["pascal","pascals"]),N("mbar",100,["millibar"],{auto:!1}),N("inH₂O",249.0889,["inh2o"],{auto:!1}),N("mmHg",133.322387415,["torr"],{auto:!1}),N("kPa",1e3,["kilopascal","kilopascals"]),N("inHg",3386.388640341,["inhg"],{auto:!1}),N("psi",6894.757293168361,["lbf/in2"],{auto:!1}),N("bar",1e5,[],{auto:!1}),N("atm",101325,["atmosphere","atmospheres"],{auto:!1}),N("MPa",1e6,["megapascal","megapascals"]),N("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([N("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),N("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),N("kN·m",1e3,["knm","kn.m"],{auto:!1}),N("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([N("kg/m³",1,["kg/m3"]),N("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),N("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),N("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([N("L/min",1/6e4,["lpm","l/min"],{auto:!1}),N("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),N("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),N("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),N("cfm",.0004719474432,["ft3/min"],{auto:!1}),N("L/s",.001,["lps","l/s"],{auto:!1}),N("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([N("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),N("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),N("mrad",.001,["milliradian","milliradians"],{auto:!1}),N("mil",Math.PI/3200,["nato-mil"],{auto:!1}),N("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),N("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),N("rad",1,["radian","radians"]),N("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([N("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),N("rad/s",1,["radps","radians/s"]),N("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),N("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([N("ppt",1e-12,["partspertrillion"],{auto:!1}),N("ppb",1e-9,["partsperbillion"]),N("ppm",1e-6,["partspermillion"]),N("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),N("‰",.001,["permille","permil"],{auto:!1}),N("%",.01,["pct","percent"]),N("×",1,["x","ratio","times"])]),molarity:Object.freeze([N("pM",1e-12,["picomolar","picomolarity"]),N("nM",1e-9,["nanomolar","nanomolarity"]),N("µM",1e-6,["um-molar","micromolar","micromolarity"]),N("mM",.001,["millimolar","millimolarity"]),N("M",1,["molar","mol/l","mol/L","molarity"]),N("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([N("mg/s",1e-6,["milligrams/s"]),N("g/s",.001,["grams/s"]),N("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),N("kg/s",1,["kilograms/s","kgps"]),N("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),N("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),N("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([N("µPa·s",1e-6,["upas","micropascalsecond"]),N("cP",.001,["centipoise"],{auto:!1}),N("mPa·s",.001,["mpas","millipascalsecond"]),N("P",.1,["poise"],{auto:!1}),N("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([N("cSt",1e-6,["centistokes","centistoke"]),N("mm²/s",1e-6,["mm2/s"],{auto:!1}),N("St",1e-4,["stokes","stoke"],{auto:!1}),N("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([N("mW/(m·K)",.001,["mw/mk"]),N("W/(m·K)",1,["w/mk","wmk"]),N("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),N("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([N("J/(kg·K)",1,["j/kgk","jkgk"]),N("kJ/(kg·K)",1e3,["kj/kgk"]),N("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([N("nSv/h",1e-9,["nsvh"]),N("µSv/h",1e-6,["usv/h","usvh"]),N("mSv/h",.001,["msvh"]),N("Sv/h",1,["svh"]),N("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),H=Symbol("ambiguous"),B=new Map,G=new Map;function D(F,C){const z=String(F||"").trim();if(!z)throw new Error("[lattice] a unit system needs a name");if(_[z]||G.has(z))throw new Error(`[lattice] unit system "${z}" already exists`);const q=[...C||[]];if(!q.length)throw new Error(`[lattice] unit system "${z}" has no units`);if(!q.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${z}" has no base unit (none with factor 1)`);const Q=new Set;for(const Y of q){if(Q.has(Y.symbol))throw new Error(`[lattice] unit system "${z}" declares "${Y.symbol}" twice`);Q.add(Y.symbol)}return G.set(z,Object.freeze(q)),B.delete(z),z}function v(){return[...Object.keys(_),...G.keys()]}function k(F){const C=y(F);return C?C.units:[]}function y(F){const C=String(F||""),z=B.get(C);if(z!==void 0)return z;const q=_[C]||G.get(C);if(!q)return B.set(C,null),null;const Q=Object.freeze([...q].sort((re,se)=>re.factor-se.factor)),Y=new Map,J=new Map,te=(re,se)=>{const de=Y.get(re);de===void 0?Y.set(re,se):de!==se&&Y.set(re,H)};for(const re of Q){te(re.symbol.toLowerCase(),re);for(const se of re.aliases)te(se.toLowerCase(),re);if(re.prefix){const se=J.get(re.prefix)||[];se.push(re),J.set(re.prefix,se)}}const ee={units:Q,byToken:Y,byPrefix:J,decimal:Q.filter(re=>!re.binary&&re.auto),binary:Q.some(re=>re.binary)?Q.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return B.set(C,ee),ee}function c(F,C){return C&&F.binary||F.decimal}function o(F,C){const z=y(F);if(!z||M(C))return null;const q=z.units.find(Y=>Y.symbol===String(C));if(q)return q;const Q=z.byToken.get(String(C).trim().toLowerCase());return Q&&Q!==H?Q:null}const n=new WeakMap;function t(F){const C=F||{};if(typeof C=="object"&&C!==null){const Y=n.get(C);if(Y!==void 0)return Y}const z=C.system||"data",q=y(z);let Q=null;if(!q)I(`unit:system:${z}`,`unknown unit system "${z}"; known systems are ${v().join(", ")}`);else{let Y=C.unit?o(z,C.unit):null;Y||(C.unit&&I(`unit:unit:${z}:${C.unit}`,`unknown unit "${C.unit}" in system "${z}"; falling back to ${q.units[0].symbol}`),Y=q.units.find(J=>J.factor===1)||q.units[0]),Q={index:q,base:Y,binary:C.binary===!0}}return typeof C=="object"&&C!==null&&n.set(C,Q),Q}const i=new WeakMap;function a(F,C){if(!F||!C||!Array.isArray(F.compound)||F.compound.length===0)return null;const z=i.get(F);if(z!==void 0)return z;const q=new Set,Q=[];for(const J of F.compound){const te=o(F.system||"data",J);if(!te){I(`unit:compound:${F.system}:${J}`,`unknown compound unit "${J}" in system "${F.system||"data"}"; ignoring it`);continue}q.has(te.symbol)||(q.add(te.symbol),Q.push(te))}Q.sort((J,te)=>te.factor-J.factor);const Y=Q.length>=2?Q:null;return i.set(F,Y),Y}function r(F,C,z){return C===z||C.factor===z.factor?F:F*C.factor/z.factor}const s=new Map;function u(F){const C=F||"",z=s.get(C);if(z)return z;const q={group:",",decimal:"."};try{for(const Q of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))Q.type==="group"?q.group=Q.value:Q.type==="decimal"&&(q.decimal=Q.value)}catch{}return s.set(C,q),q}const l=/[\s ]/g,p=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,m=/^[^\d+\-(.,\s]+\s*/,b=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function g(F,C){const{group:z,decimal:q}=u(C);let Q=String(F).replace(l,"");if(Q==="")return null;const Y=q?Q.indexOf(q):-1;if(z&&z!==q){if(Y>=0&&Q.indexOf(z,Y+q.length)>=0)return null;Q=Q.split(z).join("")}if(q&&q!=="."&&(Q=Q.split(q).join(".")),!b.test(Q))return null;const J=Number(Q);return Number.isFinite(J)?J:null}function f(F,C,z){const q=String(F).trim().replace(/\.$/,"");if(q==="")return null;const Q=C.units.find(se=>se.symbol===q);if(Q)return Q;const Y=q.toLowerCase(),J=C.byToken.get(Y);if(J===H)return null;if(J)return J;const te=C.byPrefix.get(Y);if(!te||!te.length)return null;const ee=c(C,z),re=te.filter(se=>ee.includes(se));return re.length===1?re[0]:null}function w(F,C,z,q){let Q=F,Y=0,J=!1,te=!1;for(;Q!=="";){const ee=p.exec(Q)[0];if(ee==="")return null;const re=g(ee,q&&q.locale);if(re===null)return null;Q=Q.slice(ee.length).trim();const se=Q.search(/[+-]?[\d]/),de=(se>=0?Q.slice(0,se):Q).trim();if(Q=se>=0?Q.slice(se).trim():"",de===""){if(J)return null;te=!0,Y+=r(re,z[0],C.base)}else{const ie=f(de,C.index,C.binary);if(!ie)return null;Y+=r(re,ie,C.base)}if(J=!0,te&&Q!=="")return null}return J?Y:null}function S(F,C){if(M(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const z=t(C);if(!z)return null;let q=String(F).trim();if(q==="")return null;let Q=!1;q.startsWith("(")&&q.endsWith(")")&&(Q=!0,q=q.slice(1,-1).trim());const Y=a(C,z);if(Y){q.startsWith("-")&&(Q=!0,q=q.slice(1).trim());const oe=w(q,z,Y,C);return oe===null?null:Q?-oe:oe}let J=null;const te=m.exec(q);if(te&&te[0]){const oe=f(te[0].trim(),z.index,z.binary);oe&&(J=oe,q=q.slice(te[0].length).trim())}const ee=p.exec(q)[0],re=g(ee,C&&C.locale);if(re===null)return null;const se=q.slice(ee.length).trim();if(J&&se!=="")return null;const de=J||(se===""?z.base:f(se,z.index,z.binary));if(!de)return null;const ie=r(re,de,z.base);return Q?-ie:ie}const h=new Map;function d(F,C,z,q){const Q=`${F||""}|${C}|${z}|${q?1:0}`;let Y=h.get(Q);return Y||(Y=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:C,maximumFractionDigits:z,useGrouping:q}),h.set(Q,Y)),Y}function j(F,C){if(!Number.isFinite(F)||F===0)return Math.max(0,C-1);const z=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,C-1-z))}function E(F,C){if(!Number.isFinite(F)||F===0)return F;const z=Math.ceil(Math.log10(Math.abs(F))),q=10**(C-z);return Math.round(F*q)/q}function O(F,C,z){if(!z||z===C.base.symbol)return C.base;if(z!=="auto")return T(C,z);if(F===0||!Number.isFinite(F))return C.base;const q=Math.abs(F)*C.base.factor,Q=c(C.index,C.binary);let Y=Q[0];for(const ee of Q)q>=ee.factor&&(Y=ee);if(q>=Y.factor)return Y;let J=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<=q&&ee.factor>(J===Y?0:J.factor)&&(J=ee);if(J!==Y)return J;let te=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<te.factor&&(te=ee);return te.factor<C.base.factor?te:C.base}function T(F,C){const z=F.index.units.find(Q=>Q.symbol===C);if(z)return z;const q=F.index.byToken.get(String(C).toLowerCase());return q&&q!==H?q:(I(`unit:display:${C}`,`unknown display unit "${C}"; rendering in ${F.base.symbol}`),F.base)}function A(F,C,z,q){const Q=F<0;let Y=Math.abs(F)*C.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,te=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),ee=q.space??" ",re=[];for(let de=0;de<z.length;de++){const ie=z[de],oe=de===z.length-1;let ue=oe?Y/ie.factor:Math.floor(Y/ie.factor);if(Y-=ue*ie.factor,oe){const pe=10**te;ue=Math.round(ue*pe)/pe+0}const ce=oe?d(q.locale,J,te,q.group!==!1):d(q.locale,0,0,q.group!==!1);re.push(`${ce.format(ue)}${ee}${ie.symbol}`)}const se=re.join(" ");return Q?`-${se}`:se}function P(F,C){const z=C||{},q=z.nullDisplay??"";if(M(F)||F==="")return q;const Q=typeof F=="number"?F:Number(F);if(!Number.isFinite(Q))return q;const Y=t(z);if(!Y)return String(Q);const J=a(z,Y);if(J)return A(Q,Y,J,z);const te=typeof z.significantFigures=="number"&&z.significantFigures>0?z.significantFigures:0,ee=te?E(Q,te):Q,re=O(ee,Y,z.display),se=r(ee,Y.base,re);let de=typeof z.decimals=="number"?z.decimals:z.minDecimals??0,ie=typeof z.decimals=="number"?z.decimals:z.maxDecimals??Math.max(de,2);te&&(de=j(se,te),ie=de);const oe=d(z.locale,de,ie,z.group!==!1).format(se),ue=z.space??" ";return z.placement==="prefix"?`${re.symbol}${z.space??""}${oe}`:`${oe}${ue}${re.symbol}`}function L(F,C){const z=M(F)||Number.isNaN(F)?null:Number(F),q=M(C)||Number.isNaN(C)?null:Number(C);return z===null||Number.isNaN(z)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||z<q?-1:z>q?1:0}function $(F){const C=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${C}`:"#,##0.##"}" ${F.symbol}"`}function U(F){const C={system:"data",...F||{}},z=t(C),q=z?z.base.symbol:String(C.unit||""),Q=Object.freeze({...C,unit:q}),Y=Object.freeze({...Q,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Q.locale||"",Q]]),te=ee=>{const re=ee||"";let se=J.get(re);return se||(se=Object.freeze({...Q,locale:ee||void 0}),J.set(re,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:Q,format:ee=>P(ee.value,ee.locale?te(ee.locale):Q),parse:ee=>S(ee.text,ee.locale?te(ee.locale):Q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:C.total||"sum"},...C.totals?{totals:C.totals}:{},excel:C.excel||$({decimals:C.decimals,symbol:q}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?S(ee,Q):M(ee)?null:S(String(ee),Q),toClipboard:ee=>P(ee,Y),fromClipboard:ee=>S(ee,Q)}}const x=U}),je("packages/core/src/columns/types/engineering.js",function(e,V){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const M=V("packages/core/src/internal/util.js").isNil,N=V("packages/core/src/columns/types/unit.js").createUnitType;function W(B){const G=2*Math.PI/B;return D=>{let v=0,k=0,y=0;for(const o of D||[]){if(M(o))continue;const n=Number(o);Number.isFinite(n)&&(v+=Math.cos(n*G),k+=Math.sin(n*G),y+=1)}return!y||Math.hypot(v,k)/y<1e-12?null:(Math.atan2(k,v)/G%B+B)%B}}function _(B){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(B)}}}const H=Object.freeze({metres:N({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:N({system:"length",unit:"mm",maxDecimals:2}),kilometres:N({system:"length",unit:"km",maxDecimals:3}),grams:N({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:N({system:"mass",unit:"kg",maxDecimals:3}),tonnes:N({system:"mass",unit:"t",maxDecimals:3}),seconds:N({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:N({system:"duration",unit:"ms",maxDecimals:3}),hours:N({system:"duration",unit:"h",maxDecimals:2}),speed:N({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:N({system:"speed",unit:"km/h",maxDecimals:1}),mph:N({system:"speed",unit:"mph",maxDecimals:1}),knots:N({system:"speed",unit:"kn",maxDecimals:1}),acceleration:N({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:N({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:N({system:"area",unit:"ha",maxDecimals:4}),volume:N({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:N({system:"volume",unit:"m³",maxDecimals:3}),energy:N({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:N({system:"energy",unit:"kWh",maxDecimals:2}),power:N({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:N({system:"power",unit:"kW",maxDecimals:2}),force:N({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:N({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:N({system:"pressure",unit:"bar",maxDecimals:3}),psi:N({system:"pressure",unit:"psi",maxDecimals:1}),torque:N({system:"torque",unit:"N·m",maxDecimals:2}),density:N({system:"density",unit:"kg/m³",maxDecimals:2}),flow:N({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:N({system:"flow",unit:"L/min",maxDecimals:1}),radians:N({system:"angle",unit:"rad",maxDecimals:4,totals:_(2*Math.PI)}),degrees:N({system:"angle",unit:"°",maxDecimals:2,totals:_(360)}),rpm:N({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:N({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:N({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:N({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:N({system:"fraction",unit:"bp",maxDecimals:1}),molarity:N({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:N({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:N({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:N({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:N({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:N({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:N({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:N({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),je("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 H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/core/src/columns/types/unit.js"),M=Z.defineUnit,I=Z.registerUnitSystem,N=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 H(k){const y=String(k.base),c=new Set([...k.prefixes||_,""]),o=[];for(const n of W){if(!c.has(n.symbol))continue;const t=`${n.symbol}${y}`,i=[];if(k.name){i.push(`${n.name}${k.name}`,`${n.name}${k.name}s`);const a=n.name.slice(-1);if(a&&k.name.startsWith(a)){const r=`${n.name.slice(0,-1)}${k.name}`;i.push(r,`${r}s`)}}n.symbol==="µ"&&i.push(`u${y}`),n.factor===1&&k.aliases&&i.push(...k.aliases),o.push(M(t,n.factor,i))}for(const n of k.extra||[])o.push(n);return o}function B(k,y){const c=H(y);return I(k,c)}function G(k,y,c){return B(k,y),N({system:k,unit:y.base,display:"auto",maxDecimals:3,...c||{}})}const D=Object.freeze({voltage:G("voltage",{base:"V",name:"volt"}),current:G("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:G("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:G("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:G("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:G("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[M("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),M("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:G("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:G("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[M("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:G("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:G("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:G("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:G("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:G("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:G("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:G("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[M("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:G("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),v=G}),je("packages/core/src/columns/types/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return N}}),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 v}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const M=V("packages/core/src/internal/util.js").isNil,I=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 N(o){if(M(o))return null;const n=String(o).trim();if(n==="")return null;for(const[i,a]of Object.entries(I))if(n===i||n===a.symbol)return{key:i,scale:a};const t=n.toLowerCase();for(const[i,a]of Object.entries(I))if(a.aliases.includes(t))return{key:i,scale:a};return null}function W(o,n,t){const i=N(n),a=N(t);return!i||!a||!Number.isFinite(Number(o))?null:i.key===a.key?Number(o):a.scale.fromKelvin(i.scale.toKelvin(Number(o)))}const _=new Map;function H(o,n,t){const i=`${o||""}|${n}|${t}`;let a=_.get(i);return a||(a=new Intl.NumberFormat(o||void 0,{minimumFractionDigits:n,maximumFractionDigits:t}),_.set(i,a)),a}function B(o,n){const t=n||{},i=t.nullDisplay??"";if(M(o)||o==="")return i;const a=Number(o);if(!Number.isFinite(a))return i;const r=N(t.scale||"C");if(!r)return String(a);const s=N(t.display||t.scale||"C")||r,u=s.key===r.key?a:s.scale.fromKelvin(r.scale.toKelvin(a)),l=typeof t.decimals=="number"?t.decimals:null,p=l??t.minDecimals??0,m=l??t.maxDecimals??1;return`${H(t.locale,p,m).format(u)}${t.space??" "}${s.scale.symbol}`}const G=/^[+-]?[\d\s., ]*\d/;function D(o,n){const t=String(o).trim();if(t==="")return null;const i=new Intl.NumberFormat(n||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",a=i===","?".":",",r=t.split(a).join("").split(/[\s ]/).join("").replace(i,"."),s=Number(r);return Number.isFinite(s)?s:null}function v(o,n){if(M(o))return null;const t=n||{},i=N(t.scale||"C");if(!i)return null;if(typeof o=="number")return Number.isFinite(o)?o:null;let a=String(o).trim();if(a==="")return null;let r=!1;a.startsWith("(")&&a.endsWith(")")&&(r=!0,a=a.slice(1,-1).trim());const s=G.exec(a);if(!s)return null;const u=D(s[0],t.locale);if(u===null)return null;const l=a.slice(s[0].length).trim();if(l==="")return r?-u:u;const p=N(l);if(!p)return null;const m=p.key===i.key?u:i.scale.fromKelvin(p.scale.toKelvin(u));return r?-m:m}function k(o){const n=Object.freeze({scale:"C",...o||{}}),i=(N(n.scale)||N("C")).scale.symbol,a=Object.freeze({...n,display:n.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),r=new Map([[n.locale||"",n]]),s=u=>{const l=u||"";let p=r.get(l);return p||(p=Object.freeze({...n,locale:u||void 0}),r.set(l,p)),p};return{base:"number",extends:"number",storage:"float64",temperatureConfig:n,format:u=>B(u.value,u.locale?s(u.locale):n),parse:u=>v(u.text,u.locale?s(u.locale):n),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:n.excel||`#,##0${typeof n.decimals=="number"&&n.decimals>0?`.${"0".repeat(n.decimals)}`:".#"}" ${i}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?v(u,n):M(u)?null:v(String(u),n),toClipboard:u=>B(u,a),fromClipboard:u=>v(u,n)}}const y=Object.freeze({celsius:k({scale:"C"}),fahrenheit:k({scale:"F"}),kelvin:k({scale:"K"})}),c=k}),je("packages/core/src/columns/types/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const Z=V("packages/core/src/internal/util.js"),M=Z.isNil,I=Z.warnOnce,N=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"}),H=Object.freeze({2:4,8:3,16:2}),B=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),G=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),D=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),v=/[\s\u00a0\u202f_,']/g,k=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),c=new WeakSet,o=new WeakMap,n=new Map,t=new WeakMap,i=new WeakMap,a=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 r(P){if(P==null)return 16;const L=typeof P=="string"?P.toLowerCase():P,$=N[L];return $||(I(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function s(P,L){return Math.ceil(P/W[L])}function u(P,L){if(!P)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**P-1};const $=2**(P-1);return{min:-$,max:$-1}}function l(P){return G[P]||"hexadecimal"}function p(P){if(typeof P=="string"){const L=a[P];return L||I(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(a).join(", ")}`),{...L||{}}}if(P&&typeof P.preset=="string"){const L=a[P.preset];return L||I(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(a).join(", ")}`),{...L||{},...P}}return P||{}}function m(P){const L=p(P),$=r(L.radix),U=W[$];let x=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ee=Number(L.bitWidth);y.includes(ee)?x=ee:I(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=L.signed!==!1;!F&&x===null&&(I("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),x=32);const C=L.prefix===void 0||L.prefix===!0?_[$]:L.prefix===!1?"":String(L.prefix);let z=0;L.pad===!0?z=x?s(x,$):0:typeof L.pad=="number"&&L.pad>0&&(z=Math.floor(L.pad));let q=0;L.group===!0?q=H[$]:typeof L.group=="number"&&L.group>0&&(q=Math.floor(L.group));const Q=u(x,F),Y=typeof L.min=="number"?Math.max(Q.min,L.min):Q.min,J=typeof L.max=="number"?Math.min(Q.max,L.max):Q.max,te=Object.freeze({radix:$,bits:U,prefix:C,uppercase:L.uppercase!==!1,pad:z,group:q,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:x,signed:F,min:Y,max:J<Y?Y:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:l($)});return c.add(te),te}function b(P){if(P&&c.has(P))return P;if(typeof P=="string"){let L=n.get(P);return L||(L=m(P),n.set(P,L)),L}if(P&&typeof P=="object"){let L=o.get(P);return L||(L=m(P),o.set(P,L)),L}return b("hex")}function g(P){return P<0?-Math.round(-P):Math.round(P)}function f(P,L,$){if(L<=0||P.length<=L)return P;const U=P.length%L||L,x=[P.slice(0,U)];for(let F=U;F<P.length;F+=L)x.push(P.slice(F,F+L));return x.join($)}function w(P){const L=b(P),{radix:$,prefix:U,uppercase:x,pad:F,group:C,groupSeparator:z,signed:q,bitWidth:Q,nullDisplay:Y}=L,J=Q?2**Q:0,te=ee=>{if(M(ee)||ee==="")return Y;const re=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(re))return Y;const se=g(re);let de="",ie=se;se<0&&(q?(de="-",ie=-se):ie=(se%J+J)%J);let oe=ie.toString($);return oe=x?oe.toUpperCase():oe.toLowerCase(),F>0&&oe.length<F&&(oe=oe.padStart(F,"0")),C>0&&(oe=f(oe,C,z)),de+U+oe};return te.options=L,te}function S(P,L){const $=b(L);let U=t.get($);return U||(U=w($),t.set($,U)),U(P)}function h(P){const L=b(P),{radix:$,groupSeparator:U,signed:x,min:F,max:C}=L,z=B[$],q=Q=>{if(M(Q))return{ok:!0,value:null,reason:"blank"};let Y=String(Q);if(U&&U!==""&&(Y=Y.split(U).join("")),Y=Y.replace(v,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[re,se]of D){const de=re.exec(Y);if(!de)continue;const ie=Y.slice(de[0].length);if(ie==="")break;if(!B[se].test(ie))return{ok:!1,value:null,reason:"digits"};te=parseInt(ie,se);break}if(te===null)if(z.test(Y))te=parseInt(Y,$);else if(k.test(Y))te=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const ee=g(J?-te:te);return!x&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<F||ee>C?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return q.options=L,q}function d(P,L){const $=b(L);let U=i.get($);return U||(U=h($),i.set($,U)),U(P)}function j(P,L){const $=d(P,L);return $.ok?$.value:null}function E(P,L){const $=M(P)||Number.isNaN(P)?null:Number(P),U=M(L)||Number.isNaN(L)?null:Number(L);return $===null?U===null?0:1:U===null||$<U?-1:$>U?1:0}function O(P){const L=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&L?"int32":"float64"}function T(P){const L=m(P),$=w(L),U=h(L);return{base:"number",extends:"number",storage:O(L),matches:null,format:x=>$(x.value),parse:x=>{const F=U(x.text);return F.ok?F.value:null},compare:E,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:x=>$(x),fromClipboard:x=>{const F=U(x);return F.ok?F.value:null},radix:L,formatValue:$,parseText:U}}const A=T}),je("packages/core/src/columns/types/aggregable.js",function(e,V){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const M=V("packages/core/src/internal/util.js").isNil;function I(D){const v=[];for(const k of D||[]){if(M(k))continue;const y=Number(k);Number.isFinite(y)&&v.push(y)}return v}function N(D){return v=>{const k=I(v);if(!k.length)return null;let y=0;for(const c of k)y+=10**(c/D);return D*Math.log10(y)}}function W(D){return v=>{const k=I(v);if(!k.length)return null;let y=0;for(const c of k)y+=10**(c/D);return D*Math.log10(y/k.length)}}function _(D,v){const k=v&&v.column,c=(k&&k.typeOptions||{}).weight,o=v&&v.valueAt;if(!c||typeof o!="function")return null;let n=0,t=0;for(let i=0;i<D.length;i++){if(M(D[i]))continue;const a=Number(D[i]);if(!Number.isFinite(a))continue;const r=o(c,i);if(M(r))continue;const s=Number(r);!Number.isFinite(s)||s<=0||(n+=a*s,t+=s)}return t===0?null:n/t}function H(D={}){const v=D.factor===20?20:10,k=typeof D.suffix=="string"?D.suffix:"",y=Number.isInteger(D.decimals)?D.decimals:1;return{base:"number",storage:"float64",name:D.name||"logarithmic",format:c=>{const o=c&&c.value;return M(o)||!Number.isFinite(Number(o))?"":`${Number(o).toFixed(y)}${k}`},parse:c=>{const o=String((c&&c.text)??"").replace(k,"").trim();if(!o)return null;const n=Number(o);return Number.isFinite(n)?n:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:N(v),avg:W(v)}}}}function B(D={}){const v=Number.isInteger(D.decimals)?D.decimals:1,k=D.percent===!0;return{base:"number",storage:"float64",name:D.name||"ratio",format:y=>{const c=y&&y.value;return M(c)||!Number.isFinite(Number(c))?"":k?`${Number(c).toFixed(v)}%`:Number(c).toFixed(v)},parse:y=>{const c=String((y&&y.text)??"").replace("%","").trim();if(!c)return null;const o=Number(c);return Number.isFinite(o)?o:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:_}}}}const G=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:B({name:"ratio"}),percentRate:B({name:"percentRate",percent:!0})})}),je("packages/core/src/columns/types/currency.js",function(e,V){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const M=V("packages/core/src/internal/util.js").isNil,I="⚠ no rate";function N(u){if(M(u))return null;const l=String(u).trim().toUpperCase();return l===""?null:l}function W(u){if(M(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const l=Number(u.amount),p=N(u.code);return!p||!Number.isFinite(l)?null:{amount:l,code:p}}if(Array.isArray(u)&&u.length===2){const l=Number(u[0]),p=N(u[1]);return!p||!Number.isFinite(l)?null:{amount:l,code:p}}return null}const _=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),B=/[+-]?[\d\s., ]*\d/;function G(u,l){const p=String(u).trim();if(p==="")return null;const m=new Intl.NumberFormat(l||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",b=m===","?".":",",g=p.split(b).join("").split(/[\s ]/).join("").replace(m,"."),f=Number(g);return Number.isFinite(f)?f:null}function D(u,l){const p=l||{},m=N(p.code);if(M(u))return null;const b=W(u);if(b)return b;if(typeof u=="number")return Number.isFinite(u)&&m?{amount:u,code:m}:null;let g=String(u).trim();if(g==="")return null;let f=!1;g.startsWith("(")&&g.endsWith(")")&&(f=!0,g=g.slice(1,-1).trim());let w=null;for(const[O,T]of Object.entries(_)){if(g.startsWith(O)){w=T,g=g.slice(O.length).trim();break}if(g.endsWith(O)){w=T,g=g.slice(0,-O.length).trim();break}}const S=B.exec(g);if(!S)return null;const h=G(S[0],p.locale);if(h===null)return null;const d=(g.slice(0,S.index)+" "+g.slice(S.index+S[0].length)).trim();!w&&d!==""&&(w=N(d));const j=w||m;return j?{amount:f?-h:h,code:j}:null}function v(u,l){if(typeof u=="function")return(p,m)=>{if(p===m)return 1;const b=u(p,m);return typeof b=="number"&&Number.isFinite(b)&&b>0?b:null};if(u&&typeof u=="object"){const p=u;return(m,b)=>{if(m===b)return 1;const g=Number(p[m]),f=Number(p[b]);return!Number.isFinite(g)||!Number.isFinite(f)||g<=0||f<=0?null:f/g}}return(p,m)=>p===m?1:null}function k(u,l,p){if(!u)return null;if(u.code===l)return u.amount;const m=p(u.code,l);return m===null?null:u.amount*m}const y=new Map;function c(u,l,p){const m=`${u||""}|${l}|${p??""}`;let b=y.get(m);if(!b){const g={style:"currency",currency:l};typeof p=="number"&&(g.minimumFractionDigits=p,g.maximumFractionDigits=p);try{b={fmt:new Intl.NumberFormat(u||void 0,g),currency:!0}}catch{b={fmt:new Intl.NumberFormat(u||void 0,typeof p=="number"?{minimumFractionDigits:p,maximumFractionDigits:p}:{}),currency:!1}}y.set(m,b)}return b}function o(u,l){const p=l||{},m=p.nullDisplay??"",b=W(u);if(!b)return m;const g=N(p.display)||b.code;let f=b.amount,w=b.code;if(g!==b.code){const d=p.rateFn||v(p.rates,p.rateBase),j=k(b,g,d);if(j===null)return`${p.missingRate??I} ${b.code}→${g}`;f=j,w=g}const{fmt:S,currency:h}=c(p.locale,w,p.decimals);return h?S.format(f):`${S.format(f)} ${w}`}function n(u){const l=W(u);return l?`${l.amount} ${l.code}`:""}function t(u){const l=u||{},p=N(l.display),m=l.rateFn||v(l.rates,l.rateBase);return(b,g)=>{const f=W(b),w=W(g);if(!f&&!w)return 0;if(!f)return 1;if(!w)return-1;if(p){const S=k(f,p,m),h=k(w,p,m);if(S!==null&&h!==null)return S===h?0:S<h?-1:1}return f.code===w.code?f.amount===w.amount?0:f.amount<w.amount?-1:1:f.code<w.code?-1:1}}function i(u){const l=u||{},p=(b,g)=>{const f=[];for(const j of b||[]){const E=W(j);E&&f.push(E)}if(!f.length)return null;if(new Set(f.map(j=>j.code)).size===1){const j=f[0].code;return{amount:g(f.map(E=>E.amount)),code:j}}const S=N(l.display);if(!S)return`${l.missingRate??I}: mixed currencies, no display currency set`;const h=l.rateFn||v(l.rates,l.rateBase),d=[];for(const j of f){const E=k(j,S,h);if(E===null)return`${l.missingRate??I}: ${j.code}→${S}`;d.push(E)}return{amount:g(d),code:S}},m=b=>b.reduce((g,f)=>g+f,0);return{sum:b=>p(b,m),avg:b=>p(b,g=>m(g)/g.length),min:b=>p(b,g=>Math.min(...g)),max:b=>p(b,g=>Math.max(...g))}}function a(u){const l=Object.freeze({code:"USD",...u||{}}),p=v(l.rates,l.rateBase),m=Object.freeze({...l,rateFn:p}),b=i(m),g=t(m),f=new Map([[l.locale||"",m]]),w=d=>{const j=d||"";let E=f.get(j);return E||(E=Object.freeze({...m,locale:d||void 0}),f.set(j,E)),E},S=H[N(l.display||l.code)]||"",h=typeof l.decimals=="number"&&l.decimals>0?`.${"0".repeat(l.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:m,format:d=>o(d.value,d.locale?w(d.locale):m),parse:d=>D(d.text,d.locale?w(d.locale):m),compare:g,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:b},excel:l.excel||(S?`"${S}"#,##0${h}`:`#,##0${h}`),toStorage:d=>{const j=W(d);return j||(typeof d=="string"||typeof d=="number"?D(d,m):null)},toClipboard:d=>n(d),fromClipboard:d=>D(d,m)}}const r=Object.freeze({currency:a({code:"USD"}),usd:a({code:"USD"}),eur:a({code:"EUR"}),gbp:a({code:"GBP"}),jpy:a({code:"JPY",decimals:0})}),s=a}),je("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 G}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const Z=V("packages/core/src/columns/types/temporal.js"),M=Z.TEMPORAL_TYPES,I=V("packages/core/src/columns/types/network.js"),N=I.NETWORK_TYPES,W=V("packages/core/src/columns/types/structured.js"),_=W.STRUCTURED_TYPES,H=V("packages/core/src/columns/types/unit.js"),B=H.createUnitType,G=H.UNIT_SYSTEMS,D=H.parseUnit,v=H.formatUnit,k=H.registerUnitSystem,y=H.unitSystemNames,c=H.unitsOf,o=H.defineUnit,n=V("packages/core/src/columns/types/engineering.js"),t=n.ENGINEERING_TYPES,i=V("packages/core/src/columns/types/si.js"),a=i.SI_TYPES,r=i.createSiType,s=i.createSiSystem,u=i.siUnits,l=i.SI_PREFIXES,p=V("packages/core/src/columns/types/temperature.js"),m=p.TEMPERATURE_TYPES,b=p.createTemperatureType,g=p.convertTemperature,f=p.formatTemperature,w=p.parseTemperature,S=p.TEMPERATURE_SCALES,h=V("packages/core/src/columns/types/radix.js"),d=h.createRadixType,j=h.RADIX_PRESETS,E=h.parseRadix,O=h.formatRadix,T=V("packages/core/src/columns/types/aggregable.js"),A=T.AGGREGABLE_TYPES,P=V("packages/core/src/columns/types/currency.js"),L=P.CURRENCY_TYPES,$=P.createCurrencyType,U=P.parseMoney,x=P.formatMoney,F=P.convertMoney,C=P.toMoney,z=P.rateFunction,q=P.moneyComparator,Q=P.normaliseCode,Y=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return n.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return n.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return p.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return p.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return p.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return p.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return p.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return p.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return p.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 I.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 T.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return T.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return T.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 I.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return I.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return I.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return I.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return I.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return I.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return I.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return I.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return I.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return I.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return I.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({...M,...N,..._,...A,hex:d(j.hex),hex8:d(j.hex8),hex16:d(j.hex16),hex32:d(j.hex32),binary:d(j.binary),binary8:d(j.binary8),octal:d(j.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,...a,...m,...L});{const te=new Set;for(const ee of[M,N,_,A,t,a,m,L])for(const re of Object.keys(ee)){if(te.has(re))throw new Error(`[lattice] data type "${re}" is declared twice`);te.add(re)}}}),je("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 G}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return i}});const Z=V("packages/core/src/internal/util.js"),M=Z.collator,I=Z.defaultCompare,N=Z.warnOnce;function W(a){const r=new Uint32Array(a);for(let s=0;s<a;s++)r[s]=s;return r}function _(a,r){if(r&&typeof r.count=="number")return r.count;if(!a)return 0;if(typeof a.count=="number")return a.count;if(typeof a.length=="number")return a.length;const s=a.values;return a.kind==="multi"&&a.offsets?Math.max(0,a.offsets.length-1):s?a.kind==="bitset"?typeof s.size=="number"?s.size:a.presence&&typeof a.presence.size=="number"?a.presence.size:(N(`count:${a.id}`,`column "${a.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:a.presence&&typeof a.presence.size=="number"?a.presence.size:0}const H=new WeakMap;function B(a){const r=a.constructor;if(!r)return"unknown";const s=H.get(r);if(s)return s;let u="unknown";try{let l=null;typeof r.from=="function"?l=r.from([!1,!0]):(l=new r(8),l.set(1));const p=l&&l.words;p&&p.length&&(p[0]===2?u="lsb":p[0]===64&&(u="msb"))}catch{u="unknown"}return H.set(r,u),u}function G(a){if(!a)return()=>0;const r=a instanceof Uint8Array?a:a.words;if(r instanceof Uint8Array){const s=a instanceof Uint8Array?"lsb":B(a);if(s==="lsb")return u=>r[u>>>3]>>>(u&7)&1;if(s==="msb")return u=>r[u>>>3]>>>7-(u&7)&1}return typeof a.get=="function"?s=>a.get(s)?1:0:()=>0}function D(a){return!a||!a.presence?null:G(a.presence)}function v(a){return a?typeof a.size=="number"?a.size:typeof a.values=="function"?a.values().length:0:0}function k(a,r){return a?typeof a.valueOf=="function"?a.valueOf(r):typeof a.values=="function"?a.values()[r]:null:null}function y(a,r){const s=a.offsets,u=a.values;if(!s||!u)return[];const l=s[r],p=s[r+1];if(!(p>l))return[];const m=a.dict,b=new Array(p-l);for(let g=l;g<p;g++)b[g-l]=m?k(m,u[g]):u[g];return b}function c(a){if(!a)return()=>{};const r=a.values,s=D(a),u=a.kind;if(u==="dictionary"){const l=a.dict;return s?p=>s(p)?k(l,r[p]):null:p=>k(l,r[p])}if(u==="bitset"){const l=G(r);return s?p=>s(p)?l(p)===1:null:p=>l(p)===1}if(u==="multi")return s?l=>s(l)?y(a,l):null:l=>y(a,l);if(!r&&typeof a.get=="function"){const l=a.get.bind(a);return p=>{const m=l(p);return m===void 0?null:m}}return s?l=>{if(!s(l))return null;const p=r[l];return p===void 0?null:p}:l=>{const p=r[l];return p===void 0?null:p}}function o(a,r){if(a<r)return-1;if(a>r)return 1;if(a===r){const l=Object.is(a,-0),p=Object.is(r,-0);return l===p?0:l?-1:1}const s=Number.isNaN(a),u=Number.isNaN(r);return s&&u?0:s?1:-1}function n(a){const r=M(a);return(s,u)=>{if(s===u)return 0;const l=typeof s,p=typeof u;if(l==="string"&&p==="string")return r.compare(s,u);if(l==="number"&&p==="number")return o(s,u);if(l==="boolean"&&p==="boolean")return s===u?0:s?1:-1;if(s instanceof Date||u instanceof Date){const m=s instanceof Date?s.getTime():Number(s),b=u instanceof Date?u.getTime():Number(u);return o(m,b)}return I(s,u)}}function t(a,r){if(a&&typeof a.ranks=="function")return a.ranks(r);const s=a&&typeof a.values=="function"?a.values():[],u=s.length,l=n(r),p=new Array(u);for(let b=0;b<u;b++)p[b]=b;p.sort((b,g)=>l(s[b],s[g])||b-g);const m=new Uint32Array(u);for(let b=0;b<u;b++)m[p[b]]=b;return m}function i(a){return a==null||typeof a=="number"&&Number.isNaN(a)}}),je("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 f}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Q}});const Z=V("packages/core/src/internal/util.js"),M=Z.isBlank,I=Z.toArray,N=Z.warnOnce,_=V("packages/core/src/format/date.js").toIsoDate,H=V("packages/core/src/compute/handle.js"),B=H.bitReader,G=H.dictSize,D=H.dictValue,v=H.presenceReader,k=H.valueComparator,y=H.valueReader,c=/^\d{4}-\d{2}-\d{2}$/,o="\0null\0";function n(Y,J){const te=Y&&Y.pool;if(te){const ee=te.mask||te.acquireMask||te.acquire||te.take;if(typeof ee=="function"){const re=ee.call(te,J);if(re&&re.length>=J)return re}}return new Uint8Array(J)}function t(Y,J){const te=Y&&Y.pool;if(!te||!J)return;const ee=te.release||te.releaseMask||te.free||te.recycle;typeof ee=="function"&&ee.call(te,J)}function i(Y,J,te){return Y.fill(te,0,J),Y}function a(Y){return Y==null||typeof Y=="number"&&Number.isNaN(Y)}function r(Y,J){if(Y==null)return Y;if(J==="number")return typeof Y=="number"?Y:Number(Y);if(J==="date"||J==="dateString"){const te=_(Y);return te===null?s(Y):te}return J==="boolean"?typeof Y=="boolean"?Y:Y==="true"||Y===1?!0:Y==="false"||Y===0?!1:!!Y:Y}function s(Y){return Y instanceof Date?Y.getTime():typeof Y=="number"?Y:Date.parse(String(Y))}function u(Y){return typeof Y=="number"?Y:Y instanceof Date?Y.getTime():Y==null||Y===""?NaN:Number(Y)}function l(Y,J){const te=typeof Y=="string"?Y:String(Y);return J?te:te.toLowerCase()}function p(Y,J){return Y==null?o:typeof Y=="string"?J?Y:Y.toLowerCase():Y instanceof Date?Y.getTime():Y}function m(Y,J,te){const ee=new Set;for(const re of I(Y)){const se=r(re,te);ee.add(p(se,J)),typeof se=="string"&&se!==""&&Number.isFinite(Number(se))?ee.add(Number(se)):typeof se=="number"&&Number.isFinite(se)&&ee.add(p(String(se),J))}return ee}function b(Y,J,te){if(Y==null||J===null||J===void 0)return Y==null&&J==null;const ee=typeof Y,re=typeof J;return ee==="string"&&re==="string"?te?Y===J:Y.toLowerCase()===J.toLowerCase():Y instanceof Date||J instanceof Date?s(Y)===s(J):ee==="number"&&re==="number"?Y===J||Number.isNaN(Y)&&Number.isNaN(J):ee==="number"&&re==="string"?Y===Number(J):ee==="string"&&re==="number"?Number(Y)===J:ee==="boolean"||re==="boolean"?Y===J:Array.isArray(Y)&&Array.isArray(J)?Y.length===J.length&&Y.every((se,de)=>b(se,J[de],te)):Y===J}function g(Y,J){try{if(Y instanceof RegExp){const te=Y.flags.replace(/[gy]/g,"");return new RegExp(Y.source,J||te.includes("i")?te:`${te}i`)}return new RegExp(String(Y),J?"":"i")}catch(te){return N(`regex:${String(Y)}`,`filter operator "matches" received an invalid pattern: ${String(Y)}`,te),null}}function f(Y,J){const te=w(Y,J),ee=Y&&Y.type;return ee!=="date"&&ee!=="dateString"?te:re=>te(typeof re=="string"&&c.test(re)?re:_(re)??re)}function w(Y,J){const te=Y&&Y.op,ee=!!(Y&&Y.caseSensitive),re=Y&&Y.type,se=k(J),de=ie=>oe=>!ie(oe);switch(te){case"eq":{const ie=r(Y.value,re);return oe=>b(oe,ie,ee)}case"ne":{const ie=r(Y.value,re);return oe=>!b(oe,ie,ee)}case"lt":case"lte":case"gt":case"gte":{const ie=r(Y.value,re);if(a(ie))return()=>!1;const oe=te==="lt"?-1:te==="lte"?0:te==="gt"?1:2;return ue=>{if(a(ue))return!1;const ce=se(ue,ie);return oe===-1?ce<0:oe===0?ce<=0:oe===1?ce>0:ce>=0}}case"between":case"notBetween":{const ie=I(Y.value),oe=r(ie[0],re),ue=r(ie[1],re),ce=Y.bounds||"[]",pe=ce.charAt(0)!=="(",Me=ce.charAt(1)!==")";if(a(oe)||a(ue))return te==="between"?()=>!1:()=>!0;const $e=Ae=>{if(a(Ae))return!1;const ke=se(Ae,oe),ge=se(Ae,ue);return(pe?ke>=0:ke>0)&&(Me?ge<=0:ge<0)};return te==="between"?$e:de($e)}case"in":case"notIn":{const ie=m(Y.value,ee,re),oe=ue=>ie.has(p(ue,ee));return te==="in"?oe:de(oe)}case"contains":case"notContains":{const ie=l(r(Y.value,re),ee),oe=ue=>ue==null?!1:l(ue,ee).includes(ie);return te==="contains"?oe:de(oe)}case"startsWith":{const ie=l(r(Y.value,re),ee);return oe=>oe==null?!1:l(oe,ee).startsWith(ie)}case"endsWith":{const ie=l(r(Y.value,re),ee);return oe=>oe==null?!1:l(oe,ee).endsWith(ie)}case"matches":{const ie=g(Y.value,ee);return ie?oe=>oe==null?!1:ie.test(String(oe)):()=>!1}case"blank":return ie=>M(ie)||Array.isArray(ie)&&ie.length===0;case"notBlank":return ie=>!(M(ie)||Array.isArray(ie)&&ie.length===0);case"containsAny":case"containsNone":{const ie=m(Y.value,ee,re),oe=ue=>{const ce=ue==null?[]:I(ue);for(let pe=0;pe<ce.length;pe++)if(ie.has(p(ce[pe],ee)))return!0;return!1};return te==="containsAny"?oe:de(oe)}case"containsAll":{const ie=I(Y.value).map(oe=>p(r(oe,re),ee));return oe=>{const ue=oe==null?[]:I(oe);if(ie.length===0)return!0;const ce=new Set(ue.map(pe=>p(pe,ee)));for(let pe=0;pe<ie.length;pe++)if(!ce.has(ie[pe]))return!1;return!0}}default:{const ie=Q(te);return ie?ie.compile(Y.value):(N(`op:${String(te)}`,`unknown filter operator "${String(te)}"; the condition is refused rather than matching every row`),()=>!1)}}}function S(Y,J,te){return f(J,te)(Y)}const h=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),d=new Set(["containsAny","containsAll","containsNone"]);function j(Y,J,te){const ee=Y&&Y.op,re=h[ee]||ee,se=f({...Y,op:re,type:J.type},te),de=J.items,ie=oe=>{const ue=de(oe);if(!ue)return!1;for(let ce=0;ce<ue.length;ce++)if(se(ue[ce]))return!0;return!1};return h[ee]?oe=>!ie(oe):ie}function E(Y,J,te,ee){const re=v(Y);if(re){const ie=J?1:0;for(let oe=0;oe<ee;oe++)te[oe]=re(oe)===ie?1:0;return te}const se=Y.kind;if(se==="float64"||se==="int32"||se==="bitset")return i(te,ee,J?1:0);const de=y(Y);for(let ie=0;ie<ee;ie++){const oe=de(ie),ue=M(oe)||Array.isArray(oe)&&oe.length===0;te[ie]=ue===J?0:1}return te}function O(Y,J,te,ee){const re=Y.dict,se=G(re),de=new Uint8Array(se);for(let ce=0;ce<se;ce++)de[ce]=J(D(re,ce))?1:0;const ie=Y.values,oe=v(Y);if(!oe){for(let ce=0;ce<ee;ce++)te[ce]=de[ie[ce]];return te}const ue=J(null)?1:0;for(let ce=0;ce<ee;ce++)te[ce]=oe(ce)===1?de[ie[ce]]:ue;return te}function T(Y,J,te,ee){const re=B(Y.values),se=J(!0)?1:0,de=J(!1)?1:0,ie=v(Y);if(!ie){for(let ue=0;ue<ee;ue++)te[ue]=re(ue)===1?se:de;return te}const oe=J(null)?1:0;for(let ue=0;ue<ee;ue++)te[ue]=ie(ue)===0?oe:re(ue)===1?se:de;return te}function A(Y,J,te,ee,re){const se=Y.values,de=J.type,ie=J.op;let oe=!0;switch(ie){case"eq":case"ne":{const ce=u(r(J.value,de)),pe=typeof J.value=="number"&&Number.isNaN(J.value),Me=ie==="ne"?1:0;if(pe)for(let $e=0;$e<re;$e++)ee[$e]=(Number.isNaN(se[$e])?1:0)^Me;else for(let $e=0;$e<re;$e++)ee[$e]=(se[$e]===ce?1:0)^Me;break}case"lt":{const ce=u(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]<ce?1:0;break}case"lte":{const ce=u(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]<=ce?1:0;break}case"gt":{const ce=u(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]>ce?1:0;break}case"gte":{const ce=u(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]>=ce?1:0;break}case"between":case"notBetween":{const ce=I(J.value),pe=u(r(ce[0],de)),Me=u(r(ce[1],de)),$e=J.bounds||"[]",Ae=$e.charAt(0)!=="(",ke=$e.charAt(1)!==")",ge=ie==="notBetween"?1:0;if(Ae&&ke)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>=pe&se[Ee]<=Me?1:0)^ge;else if(Ae)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>=pe&se[Ee]<Me?1:0)^ge;else if(ke)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>pe&se[Ee]<=Me?1:0)^ge;else for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>pe&se[Ee]<Me?1:0)^ge;break}case"in":case"notIn":{const ce=new Set;for(const Me of I(J.value)){const $e=u(r(Me,de));Number.isNaN($e)||ce.add($e)}const pe=ie==="notIn"?1:0;for(let Me=0;Me<re;Me++)ee[Me]=(ce.has(se[Me])?1:0)^pe;break}default:oe=!1;break}if(!oe)return!1;const ue=v(Y);if(ue){const ce=te(null)?1:0;for(let pe=0;pe<re;pe++)ue(pe)===0&&(ee[pe]=ce)}return!0}function P(Y,J,te,ee){const re=y(Y);for(let se=0;se<ee;se++)te[se]=J(re(se))?1:0;return te}function L(Y,J,te){const ee=J.count|0,re=te||n(J,ee);if(!Y)return i(re,ee,1);const se=typeof J.handle=="function"?J.handle(Y.col):void 0,de=typeof J.custom=="function"?J.custom:null;if(!se){if(de){for(let ce=0;ce<ee;ce++)re[ce]=de(Y,ce)?1:0;return re}return N(`filter:col:${String(Y.col)}`,`filter references unknown column "${String(Y.col)}"; the condition is refused rather than matching every row`),i(re,ee,0)}const ie=Y.op;if(ie==="blank"||ie==="notBlank")return E(se,ie==="notBlank",re,ee);const oe=typeof J.itemwise=="function"?J.itemwise(Y.col):null;if(oe&&!Q(ie)&&!d.has(ie))return P(se,j(Y,oe,J.locale),re,ee);const ue=f(Y,J.locale);switch(se.kind){case"dictionary":return O(se,ue,re,ee);case"bitset":return T(se,ue,re,ee);case"float64":case"int32":return A(se,Y,ue,re,ee)?re:P(se,ue,re,ee);default:return P(se,ue,re,ee)}}function $(Y,J,te){if(!Y)return i(n(J,te),te,1);if(Array.isArray(Y.conditions)){const ee=Y.conditions.filter(de=>de!=null),re=Y.op==="or"?"or":Y.op==="not"?"not":"and";if(ee.length===0)return i(n(J,te),te,1);const se=$(ee[0],J,te);for(let de=1;de<ee.length;de++){const ie=$(ee[de],J,te);if(re==="or")for(let oe=0;oe<te;oe++)se[oe]|=ie[oe];else for(let oe=0;oe<te;oe++)se[oe]&=ie[oe];t(J,ie)}if(re==="not")for(let de=0;de<te;de++)se[de]^=1;return se}return L(Y,J,n(J,te))}function U(Y,J){return $(Y,J,J.count|0)}function x(Y,J){if(!Y||!J)return Y||null;const te=Y;if(Array.isArray(te.conditions)){if((te.op==="or"?"or":te.op==="not"?"not":"and")!=="and")return F(te,J)?null:Y;const re=[];for(const se of te.conditions){const de=x(se,J);de&&re.push(de)}return re.length?{...te,op:"and",conditions:re}:null}return te.col===J?null:Y}function F(Y,J){if(!Y||typeof Y!="object")return!1;const te=Y;if(te.col===J)return!0;if(Array.isArray(te.conditions)){for(const ee of te.conditions)if(F(ee,J))return!0}return!1}function C(Y,J,te){if(te&&te.length>=J){let de=0;for(let ie=0;ie<J;ie++)Y[ie]&&(te[de++]=ie);return te.subarray(0,de)}let ee=0;for(let de=0;de<J;de++)ee+=Y[de]?1:0;const re=new Uint32Array(ee);let se=0;for(let de=0;de<J;de++)Y[de]&&(re[se++]=de);return re}const z=new Map;function q(Y){if(!(!Y||typeof Y!="object"))for(const[J,te]of Object.entries(Y))te&&typeof te.compile=="function"&&z.set(J,te)}function Q(Y){return typeof Y=="string"?z.get(Y):void 0}}),je("packages/core/src/columns/datatypes.js",function(e,V){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return E}}),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 P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const Z=V("packages/core/src/internal/util.js"),M=Z.collator,I=Z.defaultCompare,N=Z.isNil,W=Z.isObject,_=Z.isFunction,H=Z.fail,B=Z.titleCase,G=V("packages/core/src/format/date.js"),D=G.toDate,v=G.toIsoDate,k=G.compareIso,c=V("packages/core/src/format/boolean.js").toTriState,n=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=V("packages/core/src/formula/index.js"),i=t.evaluateFormula,a=t.looksLikeFormula,s=V("packages/core/src/compute/filter.js").declareOperators,u=/^\d{4}-\d{2}-\d{2}$/;function l($){return $.getHours()===0&&$.getMinutes()===0&&$.getSeconds()===0&&$.getMilliseconds()===0}const p=new Map;function m($){const U=$||"",x=p.get(U);if(x)return x;const F={group:",",decimal:"."};try{for(const C of new Intl.NumberFormat($||void 0).formatToParts(12345.6))C.type==="group"?F.group=C.value:C.type==="decimal"&&(F.decimal=C.value)}catch{}return p.set(U,F),F}const b=/\d\s*[*/^]\s*[\d.(]/;function g($,U){if(N($))return null;let x=String($).trim();if(x===""||x.startsWith("=")||b.test(x))return null;let F=1;x.startsWith("(")&&x.endsWith(")")&&(F=-1,x=x.slice(1,-1));const C=x.endsWith("%"),{group:z,decimal:q}=m(U);if(x=x.replace(/[\s\u00a0\u202f\u2009']/g,""),z&&z!=="."&&z!==","&&(x=x.split(z).join("")),x=x.replace(/[^0-9eE+\-.,]/g,""),q===","?x=x.split(".").join("").replace(",","."):x=x.split(",").join(""),x===""||x==="-"||x==="+")return null;const Q=Number(x);return Number.isNaN(Q)?null:F*(C?Q/100:Q)}function f($,U){const x=N($)||Number.isNaN($)?null:Number($),F=N(U)||Number.isNaN(U)?null:Number(U);return x===null?F===null?0:1:F===null||x<F?-1:x>F?1:0}function w($,U){const x=c($),F=c(U);return x===null?F===null?0:1:F===null?-1:x===F?0:x?1:-1}function S($,U){const x=D($),F=D(U);if(!x)return F?1:0;if(!F)return-1;const C=x.getTime(),z=F.getTime();return C<z?-1:C>z?1:0}const h=new Map;function d($){const U=D($.value);if(!U)return"";const x=$.locale||"";let F=h.get(x);return F||(F=new Intl.DateTimeFormat($.locale||void 0,{dateStyle:"medium"}),h.set(x,F)),F.format(U)}const j={boolean:{base:"boolean",storage:"bitset",matches:$=>typeof $=="boolean",parse:$=>c($.text),compare:w,format:$=>c($.value)===null?"":c($.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:$=>c($)===null?"":String(c($)),fromClipboard:$=>c($)},number:{base:"number",storage:"float64",matches:$=>typeof $=="number"&&!Number.isNaN($),parse:$=>{if(a($.text)){const U=i($.text,$);if(!U.ok)return null;const x=Number(U.value);return Number.isFinite(x)?x:null}return g($.text,$.locale)},compare:f,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:$=>N($)?"":String($),fromClipboard:($,U)=>g($,U&&U.locale)},date:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&u.test($)&&!Number.isNaN(Date.parse($))||$ instanceof Date&&!Number.isNaN($.getTime())&&l($),parse:$=>v($.text),compare:k,format:d,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>N($)?"":String($),fromClipboard:$=>v($)},dateString:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&u.test($)&&!Number.isNaN(Date.parse($)),parse:$=>v($.text),compare:k,format:d,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>N($)?"":String($),fromClipboard:$=>v($)},text:{base:"text",storage:"dictionary",matches:$=>typeof $=="string",parse:$=>$.text===""?null:String($.text),compare:($,U)=>N($)?N(U)?0:1:N(U)?-1:M().compare(String($),String(U)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:$=>N($)?"":String($),fromClipboard:$=>$},image:{base:"text",storage:"dictionary",parse:$=>$.text===""||$.text==null?null:String($.text).trim(),compare:($,U)=>N($)?N(U)?0:1:N(U)?-1:M().compare(String($),String(U)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:$=>N($)?"":String($),fromClipboard:$=>$},lookup:{base:"text",storage:"dictionary",parse:$=>{if($.text===""||$.text==null)return null;const U=$.column&&$.column.lookup,x=U&&_(U.options)?U.options():null;if(!x)return $.text;const F=String($.text),C=x.find(Q=>String(Q.id)===F);if(C)return C.id;const z=F.trim().toLowerCase(),q=x.find(Q=>String(Q.label).toLowerCase()===z);return q?q.id:$.text},compare:I,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:$=>N($)?"":String($),fromClipboard:$=>$},object:{base:"object",storage:"object",matches:$=>$!==null&&typeof $=="object"&&!($ instanceof Date),parse:$=>{try{return $.text===""?null:JSON.parse($.text)}catch{return $.text}},compare:($,U)=>I($,U),format:$=>{const U=$.value;if(N(U))return"";if(typeof U=="string")return U;try{return JSON.stringify(U)}catch{return String(U)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:$=>N($)?"":typeof $=="string"?$:JSON.stringify($),fromClipboard:$=>$}},E=["boolean","number","date","dateString","datetime","text","object"];function O($,U,x,F){const C=x.get($);if(C)return C;F.includes($)&&H(`circular data type extends chain: ${[...F,$].join(" → ")}`);const z=U[$];z||H(`unknown data type "${$}"`);let q=null;z.extends&&(q=O(z.extends,U,x,[...F,$]));const Q={...q||{},...z,name:$,defaults:{...q&&q.defaults||{},...z.defaults||{}}};return Q.base||(Q.base=q&&q.base||"text"),Q.storage||(Q.storage=q&&q.storage||"object"),x.set($,Q),Q}function T($,U){const x={...j,...n};if(U&&typeof U.dataType=="function"&&typeof U.names=="function")for(const C of U.names("dataType")){const z=U.dataType(C);z&&(x[C]=z)}if(W($))for(const[C,z]of Object.entries($))x[C]=z;const F=new Map;for(const C of E)O(C,x,F,[]);O("lookup",x,F,[]);for(const C of Object.keys(x))O(C,x,F,[]);for(const C of F.values())s(C.operators);return F}function A($,U){if($.base==="text"&&(!$.compare||$.compare===j.text.compare)){const x=M(U);return(F,C)=>N(F)?N(C)?0:1:N(C)?-1:x.compare(String(F),String(C))}return $.compare||I}function P($,U){return U?$.multiStorage||"multi":$.storage||"object"}function L($){return B(String($).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),je("packages/core/src/columns/infer.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return N}}),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"),M=Z.infoOnce,I=Z.isNil,N=100;function W(H,B,G={}){const D=G.sampleSize??N,v=[];for(let k=0;k<H.length&&v.length<D;k++){const y=H[k];I(y)||typeof y=="number"&&Number.isNaN(y)||v.push(y)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[k,y]of B){if(typeof y.matches!="function")continue;let c=!0;for(let o=0;o<v.length;o++)if(!y.matches(v[o])){c=!1;break}if(c)return{type:k,unanimous:!0,sampled:v.length}}return G.quiet||M(`infer:${G.colId||"?"}`,`column "${G.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:v.length}}function _(H,B,G,D,v={}){const k=v.sampleSize??N,y=[];for(let c=0;c<B.length&&y.length<k;c++){const o=G(B[c]);I(o)||typeof o=="number"&&Number.isNaN(o)||y.push(o)}return W(y,D,{...v,colId:H}).type}}),je("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 H}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return D}});const Z=V("packages/core/src/internal/util.js"),M=Z.DEV,I=Z.fail,N=Z.isFunction,W=Z.warnOnce,_="*";function H(v){const k=v.value||{};if(!N(k.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const c=k.pure!==!1;return k.deps===_?{computed:!0,wholeRow:!0,deps:[],pure:c}:Array.isArray(k.deps)?{computed:!0,wholeRow:!1,deps:k.deps.slice(),pure:c}:(W(`deps:missing:${v.id}`,`computed column "${v.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:c})}function B(v){const k=new Map;for(const p of v)k.set(p.id,p);const y=new Map,c=new Map,o=new Set,n=new Set,t=new Set,i=new Set;for(const p of v){const m=H(p);if(!m.computed){y.set(p.id,[]);continue}n.add(p.id),(m.pure?t:i).add(p.id),m.wholeRow&&o.add(p.id);const b=[],g=[];for(const f of m.deps)(k.has(f)?b:g).push(f);y.set(p.id,b),g.length&&c.set(p.id,g)}for(const p of t)for(const m of y.get(p))i.has(m)&&I(`pure computed column "${p}" depends on impure column "${m}". Mark it \`value.pure: false\` or make the dependency pure.`);const a=[],r=new Map,s=[],u=p=>{const m=r.get(p);if(m!=="done"){if(m==="open"){const b=s.indexOf(p);I(`circular column dependency: ${[...s.slice(b),p].join(" → ")}`)}r.set(p,"open"),s.push(p);for(const b of y.get(p)||[])k.has(b)&&u(b);s.pop(),r.set(p,"done"),a.push(p)}};for(const p of v)u(p.id);const l=new Map;for(const p of v)l.set(p.id,[]);for(const p of v)for(const m of y.get(p.id)||[]){const b=l.get(m);b&&!b.includes(p.id)&&b.push(p.id)}if(o.size)for(const p of v){if(n.has(p.id))continue;const m=l.get(p.id);for(const b of o)m.includes(b)||m.push(b)}return{order:a,dependents:l,pure:t,impure:i,computed:n,deps:y,wholeRow:o,external:c,index:k}}function G(v,k){const y=Array.isArray(k)?k:[k],c=new Set,o=[...y];for(;o.length;){const n=o.shift();for(const t of v.dependents.get(n)||[])c.has(t)||(c.add(t),o.push(t))}for(const n of y)c.delete(n);return v.order.filter(n=>c.has(n))}function D(v,k,y){if(!M)return v;const c=k instanceof Set?k:new Set(k);return new Proxy(v,{get(o,n){return typeof n=="string"&&!c.has(n)&&!Object.hasOwn(o,n)&&W(`undeclared:${y}:${n}`,`computed column "${y}" read undeclared dependency "${n}". Add it to \`value.deps\` or the value will go stale.`),o[n]}})}}),je("packages/core/src/columns/lookup.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),M=Z.collator,I=Z.defaultCompare,N=Z.isFunction,W=Z.isNil,_=Z.warnOnce,H=", ",B="";function G(c,o,n,t){if(c===null||typeof c!="object")return{id:c,label:c==null?"":String(c)};const i=c[o],a=c[n],r={id:i,label:a==null?String(i??""):String(a)};c.disabled&&(r.disabled=!0),c.variant&&(r.variant=c.variant),c.icon&&(r.icon=c.icon);const s=t?c[t]:c.group;return s!==void 0&&(r.group=s),r}function D(c,o,n=0,t=[],i=[]){for(const a of c||[]){const r=a&&typeof a=="object"?a[o]:null;if(i.push({raw:a,depth:n,path:t}),Array.isArray(r)&&r.length){const s=String(a&&typeof a=="object"?a.label??a.name??a.id??"":a);D(r,o,n+1,[...t,s],i)}}return i}class v{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;constructor(o,n={}){this.#e=o||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=M(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??H}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(o){this.#n=o,this.#c=M(o)}#d(o){const n=this.#e,t=n.valueKey||"id",i=n.labelKey||"label",a=n.childrenKey||"children";this.#o=D(o,a).map(r=>{const s=G(r.raw,t,i,n.groupKey);return r.depth&&(s.depth=r.depth,s.path=r.path),s}),this.#i=new Map,this.#s=new Map,this.#o.forEach((r,s)=>{this.#i.set(r.id,r),this.#s.set(r.id,s)}),this.#a="ready",this.#l+=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(!N(o))return _(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let n;try{n=o()}catch(t){return this.#a="error",_(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!n||!N(n.then)?(this.#d(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#a="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,n){const t=this.#e;if(!N(t.search)){const r=String(o||"").toLowerCase();return Promise.resolve(r===""?this.#o:this.#o.filter(s=>s.label.toLowerCase().includes(r)))}const i=t.valueKey||"id",a=t.labelKey||"label";return Promise.resolve(t.search(o,n)).then(r=>(r||[]).map(s=>G(s,i,a,t.groupKey)))}option(o){return this.#i.get(o)}has(o){return this.#i.has(o)}label(o){if(W(o)||o==="")return"";const n=this.#i.get(o);if(n)return n.label;if(this.#a==="loading"||this.#a==="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 N(t)?String(t(o)??""):typeof t=="string"?t:String(o)}text(o){if(this.multiple){const n=k(o);return n.length===0?"":n.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,i)=>I(t.id,i.id));const n=this.#c;return this.#o.slice().sort((t,i)=>n.compare(t.label,i.label))}comparator(){const o=this.sortBy,n=this.multiple,t=this.#c,i=this.#s;if(n&&o==="count")return(r,s)=>k(r).length-k(s).length;const a=n?r=>k(r)[0]:r=>r;return o==="value"?(r,s)=>I(a(r),a(s)):o==="optionOrder"?(r,s)=>{const u=i.has(a(r))?i.get(a(r)):Number.MAX_SAFE_INTEGER,l=i.has(a(s))?i.get(a(s)):Number.MAX_SAFE_INTEGER;return u-l}:(r,s)=>{const u=a(r),l=a(s);return W(u)?W(l)?0:1:W(l)?-1:t.compare(this.label(u),this.label(l))}}groupKey(o){return this.multiple?k(o).map(t=>String(t)).sort().join(B):W(o)?"":String(o)}countValues(o){return this.multiple?k(o).length:W(o)?0:1}contains(o,n,t){const i=this.multiple?k(o):W(o)?[]:[o],a=Array.isArray(n)?n:[n];switch(t){case"containsAll":return a.every(r=>i.includes(r));case"containsNone":return!a.some(r=>i.includes(r));default:return a.some(r=>i.includes(r))}}exportText(o,n="label"){return n==="value"?this.multiple?k(o).join(this.separator):W(o)?"":String(o):this.text(o)}exportColumns(){const o=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:t=>o?k(t).includes(n.id):t===n.id}))}}function k(c){return Array.isArray(c)?c:W(c)||c===""?[]:[c]}function y(c,o={}){const n=c.lookup;if(!n)return null;const t=new v(n,{colId:c.id,locale:o.locale,onChange:o.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&t.load(),t}}),je("packages/core/src/columns/value.js",function(e,V){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),M=Z.getPath,I=Z.isFunction,N=Z.isNil,W=Z.Lru,_=Z.warnOnce,B=V("packages/core/src/columns/graph.js").depsProxy,G="\0";function D(t,i={}){const a=i.locale,r=i.grid??null,s=i.context,u=t.value&&t.value.format,l=t.formatter||null,p=t.dataType&&t.dataType.format,m=t.lookup||null,b=(g,f,w)=>({value:g,data:w,row:f,column:t,colId:t.id,grid:r,context:s,locale:a});if(I(u))return(g,f,w)=>{const S=u(b(g,f,w));return S==null?"":String(S)};if(l){if(m){const g=l.kind==="text";return(f,w,S)=>l(g?m.text(f):f,b(f,w,S))}return(g,f,w)=>l(g,b(g,f,w))}return I(p)?(g,f,w)=>{const S=p(b(g,f,w));return S==null?"":String(S)}:m?g=>m.text(g):g=>N(g)?"":typeof g=="string"?g:String(g)}function v(t,i){!t||!t.value||t.value.pure!==!1||_(`impure:${i}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${i}. The result is not stable across passes.`)}class k{#e;#t;#n;#r;#o;#i;#s=new W(4096);constructor(i){this.#e=i.columns instanceof Map?i.columns:new Map((i.columns||[]).map(a=>[a.id,a])),this.#t=i.graph,this.#n=i.grid??null,this.#r=i.context,this.#i=i.stored||null,this.#o=i.rowKey||y}get graph(){return this.#t}setGraph(i){this.#t=i,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(i){if(this.#s.size===0)return;const a=i&&i.rows?new Set([...i.rows].map(String)):null,r=i&&i.columns?[...i.columns]:null;if(!a&&!r){this.#s.clear();return}const s=r?this.#l(r):null;for(const u of[...this.#s.keys()]){const l=String(u).split(G);l.length===3&&(a&&!a.has(l[0])||s&&!s.has(l[2])||this.#s.delete(u))}}#l(i){const a=new Set,r=this.#t,s=[...i];for(;s.length;){const u=s.pop();if(!a.has(u)){a.add(u);for(const l of r?r.dependents.get(u)||[]:[])s.push(l)}}return a}value(i,a,r){const s=typeof i=="string"?this.#e.get(i):i;if(!s)return;if(!s.computed)return this.#u(s,a,r);if(s.value.pure!==!1&&this.#i&&r&&r.physical!=null&&this.#i.has(s.id))return this.#i.get(s.id,r.physical);if(s.volatile)return this.compute(s,a,r);if(s.value.pure===!1)return this.compute(s,a,r);const u=`${this.#a(a,r)}${G}${s.id}`;if(this.#s.has(u))return this.#s.get(u);const l=this.compute(s,a,r);return this.#s.set(u,l),l}#a(i,a){return`${this.#o(i,a)}${G}${c(i)}`}#u(i,a,r){if(this.#i&&r&&r.physical!=null&&this.#i.has(i.id))return this.#i.get(i.id,r.physical);if(i.field)return i.read?i.read(a):M(a,i.field)}compute(i,a,r){const s=this.#t,u=s&&s.wholeRow.has(i.id);let l;if(u)l=a??{};else{l={};const m=s&&s.deps.get(i.id)||[];for(const g of m)l[g]=this.value(g,a,r);const b=s&&s.external.get(i.id)||[];for(const g of b)l[g]=M(a,g);l=B(l,[...m,...b],i.id)}const p={data:a,row:r,column:i,grid:this.#n,context:this.#r};return i.value.compute(l,p)}values(i,a){const r={},s=this.#t?this.#t.order:[...this.#e.keys()];for(const u of s)r[u]=this.value(u,i,a);return r}text(i,a,r){const s=typeof i=="string"?this.#e.get(i):i;return s?s.formatValue(this.value(s,a,r),r,a):""}key(i,a,r){const s=typeof i=="string"?this.#e.get(i):i;if(!s)return"";const u=this.value(s,a,r);return I(s.value.key)?String(s.value.key(this.#c(s,u,a,r))):s.lookup?s.lookup.groupKey(u):N(u)?"":String(u)}quickFilterText(i,a,r){const s=typeof i=="string"?this.#e.get(i):i;if(!s)return"";if(I(s.value.quickFilterText)){const u=this.value(s,a,r);return String(s.value.quickFilterText(this.#c(s,u,a,r))??"")}return this.text(s,a,r)}#c(i,a,r,s){return{value:a,data:r,row:s,column:i,colId:i.id,grid:this.#n,context:this.#r}}parse(i,a,r,s){const u=typeof i=="string"?this.#e.get(i):i;if(!u)return a;const l={text:a,value:this.value(u,r,s),data:r,row:s,column:u,grid:this.#n,context:this.#r,locale:this.#n&&I(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&I(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return I(u.value.parse)?u.value.parse(l):u.dataType&&I(u.dataType.parse)?u.dataType.parse(l):a}validate(i,a,r,s,u){const l=typeof i=="string"?this.#e.get(i):i;if(!l||!I(l.edit.validate))return!0;const p=l.edit.validate({value:a,oldValue:r,data:s,row:u,column:l,grid:this.#n,context:this.#r});return p===!0||p===void 0?!0:String(p)}apply(i,a,r,s){const u=typeof i=="string"?this.#e.get(i):i;if(!u)return!1;const l=this.value(u,r,s);if(I(u.value.apply)){const p=u.value.apply({value:a,oldValue:l,data:r,row:s,column:u,grid:this.#n,context:this.#r});return this.#d(u,r,s),p!==!1}return u.field?l===a?!1:(u.write(r,a),this.#d(u,r,s),!0):(_(`apply:${u.id}`,`column "${u.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(i,a,r,s){const u=typeof i=="string"?this.#e.get(i):i;if(!u)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const l=this.value(u,r,s),p=this.parse(u,a,r,s),m=this.validate(u,p,l,r,s);if(m!==!0)return{ok:!1,value:p,oldValue:l,changed:!1,error:m};const b=this.apply(u,p,r,s);return{ok:!0,value:p,oldValue:l,changed:b}}#d(i,a,r){if(this.#s.size===0)return;const s=this.#a(a,r);this.#s.delete(`${s}${G}${i.id}`);for(const u of this.#t?this.#t.dependents.get(i.id)||[]:[])this.#s.delete(`${s}${G}${u}`)}}function y(t,i){return i&&i.key!=null?String(i.key):c(t)}function c(t){if(t&&typeof t=="object"){let i=o.get(t);return i===void 0&&(i=`#${n++}`,o.set(t,i)),i}return String(t)}const o=new WeakMap;let n=0}),je("packages/core/src/model/shadow.js",function(e,V){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return N}}),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 H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return l}});const M=V("packages/core/src/internal/util.js").warnOnce,I=2e5,N=20,W=1e3,_=50;function H(p){return Math.min(W,Math.max(_,Math.floor(p)))}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"]),G=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),D=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),v=.6745,k=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),c=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 n(p,m){if(!m)return null;const b=Number.isFinite(Number(m.lower))?Number(m.lower):null,g=Number.isFinite(Number(m.upper))?Number(m.upper):null;if(b===null&&g===null||!Number.isFinite(p))return null;if(b!==null&&p<b||g!==null&&p>g)return y.FAIL;const f=Number.isFinite(Number(m.warnLower))?Number(m.warnLower):null,w=Number.isFinite(Number(m.warnUpper))?Number(m.warnUpper):null;return f!==null&&p<f||w!==null&&p>w?y.WARN:y.PASS}function t(p,m,b){if(!m||typeof m!="object")return null;if(m.kind!=="time")return m.kind!==void 0&&M(`shadow.history.window.kind:${p}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${m.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 g=m.minutes!=null?Number(m.minutes)*6e4:Number(m.span);if(!(g>0))return M(`shadow.history.window.span:${p}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const f=Math.max(2,Math.floor(b)||N);return{span:g,bucketMs:Math.max(1,Math.floor(g/f))}}class i{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(m){this.#e=m.colId,this.#a=Math.max(2,m.depth||N),this.#u=Math.max(1,m.max||I),this.#c=m.now||(()=>Date.now()),this.#d=t(this.#e,m.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(m,b){const g=u(b);if(g===null)return;if(!this.#n.has(m)){this.#m=null,this.#p=null,this.#g(),this.#t.set(m,g),this.#n.set(m,g),this.#r.set(m,0),this.#o.set(m,this.#c()),this.#i.set(m,[g]),this.#d&&this.#h.set(m,[g]),this.#s.set(m,0);return}const f=this.#n.get(m);if(f===g)return;this.#m=null,this.#p=null,this.#n.set(m,g),this.#r.set(m,(this.#r.get(m)||0)+1),this.#o.set(m,this.#c());const w=this.#i.get(m)||[];w.push(g),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(m,w);const S=Math.sign(g-f),h=this.#s.get(m)||0;this.#s.set(m,Math.sign(h)===S?h+S:S)}#g(){if(this.#n.size<this.#u)return;const m=this.#n.keys().next().value;m!==void 0&&(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.#s.delete(m),this.#l++)}rebase(){for(const[m,b]of this.#n)this.#t.set(m,b);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.#s.clear(),this.#l=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(m){const b=m instanceof Set?m:new Set(m);let g=0;for(const f of[...this.#n.keys()])b.has(f)||(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#o.delete(f),this.#i.delete(f),this.#h.delete(f),this.#s.delete(f),g++);return g&&(this.#m=null,this.#p=null),g}advanceHistoryWindow(m=this.#c()){const b=this.#d;if(!b)return 0;const g=Math.floor(m/b.bucketMs),f=g-this.#f;if(!(f>0))return 0;const w=Math.min(f,this.#a);for(const[S,h]of this.#h){const d=this.#n.get(S);for(let j=0;j<w;j++)h.push(d);h.length>this.#a&&h.splice(0,h.length-this.#a)}return this.#f=g,f}read(m,b,g,f){switch(m){case"updates":return this.#r.has(b)?this.#r.get(b):0;case"updatedAt":{const w=this.#o.get(b);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(b);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(b)?this.#t.get(b):null;case"delta":return this.#n.has(b)?this.#n.get(b)-this.#t.get(b):null;case"deltaPercent":{if(!this.#n.has(b))return null;const w=this.#t.get(b);return w?(this.#n.get(b)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(b),S=this.#o.get(b);if(!w||w.length<2||S===void 0)return null;const h=this.#c()-S,d=w[w.length-1]-w[w.length-2];return h>0?d/h*1e3:d}case"history":return this.#d?this.#h.has(b)?[...this.#h.get(b)]:null:this.#i.has(b)?[...this.#i.get(b)]:null;case"streak":return this.#s.has(b)?this.#s.get(b):0;case"specStatus":return this.#n.has(b)?n(this.#n.get(b),f):null;default:return c.includes(m)?this.#v(m,b,g,f):null}}#w(m){if(m){if(this.#p&&this.#p.only===m)return this.#p.view;const b=this.#b(m);return this.#p={only:m,view:b},b}return this.#m?this.#m:(this.#m=this.#b(null),this.#m)}#b(m){const b=[];for(const[T,A]of this.#n)m&&!m.has(T)||b.push(A);const g=b.sort((T,A)=>T-A);let f=0,w=0,S=0,h=0;for(const T of g){h+=T,f++;const A=T-w;w+=A/f,S+=A*(T-w)}const d=[];for(const[T,A]of this.#t)m&&!m.has(T)||d.push(A);const j=f?a(g):0,E=g.map(T=>Math.abs(T-j)).sort((T,A)=>T-A),O=f?a(E):0;return{sorted:g,baseline:d.sort((T,A)=>T-A),sum:h,mean:f?w:0,sd:f>1?Math.sqrt(S/(f-1)):0,median:j,mad:O}}#v(m,b,g,f){if(!this.#n.has(b)||g&&!g.has(b))return null;const w=this.#n.get(b),S=this.#w(g),h=S.sorted.length;if(!h)return null;switch(m){case"rank":return h-s(S.sorted,w)+1;case"rankAsc":return r(S.sorted,w)+1;case"rankChange":{if(!this.#t.has(b)||!S.baseline.length)return null;const d=S.baseline.length-s(S.baseline,this.#t.get(b))+1,j=h-s(S.sorted,w)+1;return d-j}case"percentile":return s(S.sorted,w)/h*100;case"quartile":{const d=s(S.sorted,w)/h;return Math.min(4,Math.max(1,Math.ceil(d*4)))}case"zScore":return S.sd?(w-S.mean)/S.sd:null;case"anomalyScore":return S.mad?v*(w-S.median)/S.mad:null;case"anomalyFlag":{if(!S.mad)return null;const d=f&&Number.isFinite(Number(f.threshold))?Number(f.threshold):k;return Math.abs(v*(w-S.median)/S.mad)>d}case"shareOfTotal":return S.sum?w/S.sum*100:null;default:return null}}}function a(p){const m=p.length;if(!m)return 0;const b=(m-1)*.5,g=Math.floor(b),f=Math.ceil(b);return g===f?p[g]:p[g]+(b-g)*(p[f]-p[g])}function r(p,m){let b=0,g=p.length;for(;b<g;){const f=b+g>>1;p[f]<m?b=f+1:g=f}return b}function s(p,m){let b=0,g=p.length;for(;b<g;){const f=b+g>>1;p[f]<=m?b=f+1:g=f}return b}function u(p){if(p==null||p==="")return null;if(p instanceof Date){const b=p.getTime();return Number.isFinite(b)?b:null}const m=typeof p=="number"?p:Number(p);return Number.isFinite(m)?m:null}function l(p){const m=[];for(const b of p||[]){const g=b.shadow;if(!g)continue;const f=typeof g=="string"?{kind:g}:g,w=f.kind;B.includes(w)&&(G.includes(w)||D.includes(w)||m.push({colId:b.id||b.field,of:f.of||b.field||b.id,kind:w,depth:f.depth,historyWindow:w==="history"?f.window:void 0}))}return m}}),je("packages/core/src/columns/model.js",function(e,V){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return re}});const Z=V("packages/core/src/internal/util.js"),M=Z.expand,I=Z.fail,N=Z.getPath,W=Z.humanise,_=Z.isFunction,H=Z.isObject,B=Z.merge,G=Z.pathGetter,D=Z.pathSetter,v=Z.toArray,k=Z.uid,y=Z.warnOnce,o=V("packages/core/src/format/index.js").compileFormat,n=V("packages/core/src/columns/datatypes.js"),t=n.comparatorFor,i=n.createTypeRegistry,a=n.storageKind,r=V("packages/core/src/columns/infer.js"),s=r.inferColumnType,u=r.DEFAULT_SAMPLE,l=V("packages/core/src/columns/graph.js"),p=l.buildGraph,m=l.affectedBy,g=V("packages/core/src/columns/lookup.js").createLookup,f=V("packages/core/src/columns/value.js"),w=f.compileDisplay,S=f.ValuePipeline,h=f.warnImpureUse,j=V("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,E=Object.freeze({geometry:"geometry",list:"list"}),O={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},T={centre:"center"},A=new Set(["start","center","end","left","right"]);function P(de){if(typeof de!="string")return;const ie=de.toLowerCase();return T[ie]?T[ie]:A.has(ie)?ie:void 0}function L(de){if(typeof de!="string")return;const ie=de.toLowerCase();return ie==="center"||ie==="centre"?"middle":ie==="top"||ie==="middle"||ie==="bottom"?ie:void 0}const $=["cell","layout","header"];function U(de){if(!H(de))return{};const ie={...de},oe=(ue,ce)=>{if(de[ue]===void 0)return;const pe=M(de[ue],ce);pe&&$.includes(ue)&&!H(de[ue])&&delete pe.enabled,ie[ue]=pe};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),ie}function x(de,ie){const oe={...de||{}},ue=H(ie)&&H(ie.layout)&&ie.layout.width!==void 0;return oe.fit==="content"&&!ue&&delete oe.width,oe}const F=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","typeOptions","validation","value","verticalAlign"]),C=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function z(de,ie,oe,ue){const ce=oe==="columnGroup"?"column group":"column";for(const pe of Object.keys(de))ie.has(pe)||y(`${oe}.unknown:${pe}`,`'${pe}' is not a configuration key this grid recognises, so it had no effect on ${ce} "${ue}". Check the spelling against the reference.`)}function q(de,ie){const oe=ie&&_(de.defaultsFor)?de.defaultsFor(ie):null,ue={...de.defaults||{},...H(oe)?oe:{}},ce={};return ue.align&&(ce.align=ue.align,ce.cell={align:ue.align},ce.header={align:ue.align}),ue.filter&&(ce.filter=ue.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ue.filter}),ue.editor&&(ce.edit=ue.editor==="none"?{editor:null}:{editor:ue.editor}),ue.total&&(ce.total=ue.total),ue.render&&(ce.cell={...ce.cell||{},render:ue.render}),de.export&&(ce.export={...de.export}),ce}function Q(de){if(typeof de=="string")return de.trim()?[de.trim()]:[];if(!Array.isArray(de))return[];const ie=[];for(const oe of de){if(typeof oe!="string")continue;const ue=oe.trim();ue&&!ie.includes(ue)&&ie.push(ue)}return ie}class Y{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(ie,oe,ue){const ce=this.#c(ie,oe,ue);if(typeof ce!="string"||!this.#d)return ce??null;const pe=oe&&oe.totals&&oe.totals.implement;if(pe&&_(pe[ce])){const $e=pe[ce];return $e.totalName=ce,$e}const Me=this.#d.totalFn?.(ce);return _(Me)?Me:ce}#c(ie,oe,ue){if(typeof ie!="string")return ie;const ce=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(ce)||ce.includes(ie))return ie;const pe=ce.length?ce.join(", "):"none";return I(`column "${ue}" is typed ${oe.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${pe}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#h;#f;#m;#p;#g;#w=!1;#b;#v;constructor(ie={}){this.#o=U(ie.columnDefaults||{}),this.#i=ie.columnPresets||{},this.#l=ie.locale,this.#s=ie.timeZone,this.#a=L(ie.verticalAlign),this.#d=ie.registry||null,this.#h=ie.grid||null,this.#f=ie.context,this.#b=ie.sampleSize??u,this.#v=ie.onChange||null,this.#g=_(ie.rowKey)?ie.rowKey:void 0,this.#r=i(ie.dataTypes,this.#d);const{leaves:oe,groups:ue}=re(ie.columns||[]);this.#n=ue;for(const ce of oe){const pe=this.#y(ce.def,null);if(pe.groupPath=ce.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}ce.column=pe,this.#e.set(pe.id,pe),this.#t.push(pe.id)}this.#O(ie.stored||null)}#y(ie,oe){z(ie,F,"column",ie.id||ie.field||"(unnamed)");const ue=U(ie),ce=v(ie.preset),pe=ce.map(nt=>{const Pe=this.#i[nt];return Pe?U(Pe):(y(`preset:${nt}`,`unknown column preset "${nt}"; ignoring`),{})}),Me=this.#j(ue,pe,oe),$e=this.#r.get(Me)||this.#r.get("text");if(!this.#r.has(Me)&&ie.type){const nt=E[Me];y(`type:${Me}`,`unknown data type "${Me}"; falling back to "text"`+(nt?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${nt}'.`:""))}const Ae=_($e.items)?this.#A(ue,pe,ie.id||ie.field||"(unnamed)"):null;let ke=O;ke=B(ke,this.#o),ie.type!==!1&&(ke=B(ke,q($e,Ae)));for(const nt of pe)ke=B(ke,nt);ke=B(ke,ue);const ge=ke.edit;ge&&ge.editor&&ge.enabled!==!0&&!_(ge.enabled)&&(ie.edit||{}).editor&&y(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${ge.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ee=ie.id||ie.field||k("col");if(ie.shadow&&!_(ke.value&&ke.value.compute)){const nt=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Pe=nt.of||ie.field||Ee,Ge=j.includes(nt.kind),He=Ge?nt.model||nt:null,Ye=Ge&&He?[...Array.isArray(He.predictors)?He.predictors:[],He.response].filter(Boolean):null;ke.value={...ke.value||{},deps:Ye&&Ye.length?Ye:nt.orderBy&&nt.orderBy!==Pe?[Pe,nt.orderBy]:[Pe],pure:!1,compute:(st,ht)=>{const bt=ht.grid&&ht.grid.statistics;if(!bt)return null;const At=ht.row&&ht.row.key||bt.keyOf(ht.data);if(!At)return null;if(Ge){if(!_(bt.fitShadow))return null;const Tt=nt.model?{...nt.model,threshold:nt.threshold}:nt;return bt.fitShadow(nt.kind,At,Tt)}return bt.shadow(Pe,nt.kind,At,nt.scope,nt)}}}if(ie.running&&!_(ke.value&&ke.value.compute)){const nt=typeof ie.running=="string"?{kind:ie.running}:ie.running,Pe=nt.of||ie.field||Ee;ke.value={...ke.value||{},deps:[Pe],pure:!1,compute:(Ge,He)=>{const Ye=He.grid&&He.grid.statistics;if(!Ye||!_(Ye.running))return null;const st=He.row&&He.row.key||Ye.keyOf(He.data);return st?Ye.running(Pe,nt.kind||"total",st):null}},ie.sort===void 0&&(ke.sort={...ke.sort||{},enabled:!1})}const De=ie.field??(_(ke.value&&ke.value.compute)?null:ie.id??null),ze=_(ke.value&&ke.value.compute),qe={id:Ee,field:De,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:ke.title??W(De||Ee),type:$e.name,dataType:$e,itemType:Ae,nullable:ke.nullable!==!1,align:P(ue.cell&&ue.cell.align||ue.align||ke.cell&&ke.cell.align||ke.align||$e.defaults&&$e.defaults.align)||"start",verticalAlign:L(ue.cell&&ue.cell.verticalAlign||ue.verticalAlign||ke.cell&&ke.cell.verticalAlign||ke.verticalAlign)||this.#a,rowSpan:_(ke.rowSpan)?ke.rowSpan:null,colSpan:_(ke.colSpan)?ke.colSpan:null,value:{pure:!0,...ke.value||{}},cell:{...ke.cell||{}},edit:{...ke.edit||{}},sort:{...ke.sort||{}},filter:{...ke.filter||{}},group:{enabled:!1,index:-1,explode:!1,...ke.group||{}},pivot:{enabled:!1,index:-1,...ke.pivot||{}},total:this.#u(ke.total,$e,ie.id||ie.field||"(unnamed)"),groupTotal:ke.groupTotal===void 0?null:this.#u(ke.groupTotal,$e,ie.id||ie.field||"(unnamed)"),grandTotal:ke.grandTotal===void 0?null:this.#u(ke.grandTotal,$e,ie.id||ie.field||"(unnamed)"),tags:Q(ke.tags),typeOptions:ke.typeOptions??null,...H(ke[Me])?{[Me]:ke[Me]}:{},layout:x(ke.layout,ue),header:{...ke.header||{}},contextMenu:ke.contextMenu===void 0?null:ke.contextMenu,facet:{...ke.facet||{}},export:{...ke.export||{}},allowGroup:ke.allowGroup!==!1,allowPivot:ke.allowPivot!==!1,allowTotal:ke.allowTotal!==!1,quickFilter:ke.quickFilter!==!1,def:ie,format:ke.format,presets:ce,inferred:oe!=null&&!ie.type,computed:ze,read:De?G(De):null,write:De?D(De):null};qe.cell.align=P(ue.cell&&ue.cell.align)||qe.align,qe.header.align=P(ue.header&&ue.header.align)||qe.align;const Xe=ke.lookup||null;return qe.lookup=Xe?g({id:Ee,lookup:Xe},{locale:this.#l,onChange:()=>{this.#v&&this.#v("lookup",{colId:Ee})}}):null,qe.group.explode&&qe.lookup&&qe.lookup.multiple&&y(`explode:${Ee}`,`column "${Ee}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S(qe),qe}#S(ie){ie.formatter=o(ie.format,ie.dataType,this.#l,this.#s,ie.id),ie.formatValue=w(ie,{locale:this.#l,grid:this.#h,context:this.#f}),ie.itemCompare=ie.itemType?t(ie.itemType,this.#l):null,ie.compare=_(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():_(ie.dataType.compareFor)?ie.dataType.compareFor(ie):t(ie.dataType,this.#l),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=a(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#A(ie,oe,ue){let ce=H(ie.typeOptions)?ie.typeOptions:null;for(let Ae=oe.length-1;!ce&&Ae>=0;Ae--)H(oe[Ae].typeOptions)&&(ce=oe[Ae].typeOptions);!ce&&H(this.#o.typeOptions)&&(ce=this.#o.typeOptions);const pe=ce&&ce.of!==void 0?ce.of:"text",Me=typeof pe=="string"?this.#r.get(pe):void 0;return Me&&!_(Me.items)&&Me.storage!=="object"?Me:(y(`type:of:${String(pe)}`,`column "${ue}" names "${String(pe)}" as its item type (typeOptions.of), which is not ${Me?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#j(ie,oe,ue){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let ce=oe.length-1;ce>=0;ce--)if(oe[ce].type)return oe[ce].type;if(this.#o.type)return this.#o.type;if(ie.shadow){const ce=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(ce==="fitInfluence")return"boolean";if(ce==="fitPredicted"||ce==="fitResidual"||ce==="fitStdResidual"||ce==="fitLeverage"||ce==="fitCooksD"||ce==="tsTrend"||ce==="tsSeasonal"||ce==="tsResidual"||ce==="tsCoverage"||ce==="tsSmoothed"||ce==="tsSmoothingAlpha"||ce==="tsSmoothingBeta")return"number"}return ue||(ie.lookup?"lookup":"text")}#O(ie){const oe=this.all();this.#m=p(oe),this.#p?this.#p.setGraph(this.#m):this.#p=new S({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:ie||null,rowKey:this.#g});const ue=this.#p;for(const ce of oe)ce.getValue=(pe,Me)=>ue.value(ce,pe,Me)}all(){return this.#t.map(ie=>this.#e.get(ie))}visible(){return this.all().filter(ie=>!ie.layout.hidden)}get(ie){return this.#e.get(ie)}groups(){const ie=oe=>{const ue=[];for(const ce of oe)Array.isArray(ce.columns)?ue.push({...ce,columns:ie(ce.columns)}):ce.column&&ue.push(ce.column);return ue};return ie(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(ie){return m(this.#m,ie)}value(ie,oe,ue){return this.#p.value(ie,oe,ue)}text(ie,oe,ue){return this.#p.text(ie,oe,ue)}checkImpure(ie,oe){h(this.#e.get(ie),oe)}setLocale(ie){this.#l=ie;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(ie),this.#S(oe);this.#v&&this.#v("locale",{locale:ie})}infer(ie){const oe={};if(this.#w||!Array.isArray(ie)||ie.length===0)return oe;this.#w=!0;let ue=!1;for(const ce of this.all()){const pe=ce.def;if(pe.type!==void 0||!ce.field||ce.computed||ce.lookup||this.#E(ce))continue;const Me=ce.read||(ke=>N(ke,ce.field)),$e=s(ce.id,ie,Me,this.#r,{sampleSize:this.#b});if($e===ce.type)continue;oe[ce.id]=$e;const Ae=this.#y(pe,$e);Ae.groupPath=ce.groupPath,Ae.layout={...Ae.layout,...J(ce.layout)},this.#e.set(ce.id,Ae),se(this.#n,ce.id,Ae),ue=!0}return ue&&this.#O(null),oe}redecorate(ie,oe,ue={}){const ce=this.#e.get(ie);if(!ce){y(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const pe=ce.def||{},Me={...H(pe.cell)?pe.cell:{}};Me.decoration=oe??void 0,ue&&"variant"in ue&&(Me.variant=ue.variant);const $e={...pe,cell:Me},Ae=this.#y($e,ce.type);return Ae.groupPath=ce.groupPath,Ae.layout={...Ae.layout,...J(ce.layout)},this.#e.set(ie,Ae),se(this.#n,ie,Ae),this.#O(null),this.#v&&this.#v("decorate",{colId:ie}),Ae}#E(ie){for(const oe of ie.presets){const ue=this.#i[oe];if(ue&&ue.type)return!0}return!!this.#o.type}#C(ie){return!ie.computed&&_(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return oe=>this.#p.value(ie,oe,null);if(this.#C(ie)){const oe=ie.dataType.toStorage,ue={timeZone:ie.timeZone||this.#s,colId:ie.id,itemType:ie.itemType||null};return ce=>oe(ie.read(ce),ue)}return ie.read}storeValue(ie,oe){if(!(!ie||ie.computed)&&_(ie.read))return this.storeReader(ie)(oe)}storeSchema(){const ie=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const ue=this.storeReader(oe);let ce=null;!oe.computed&&!this.#C(oe)&&typeof oe.field=="string"&&!oe.lookup&&(ce=oe.field);const pe={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:ue};ce!==null&&(pe.field=ce),oe.lookup&&(pe.dictionary=oe.lookup.dictionary()),ie.push(pe)}return ie}state(){return this.all().map(ie=>({id:ie.id,width:ie.layout.width,flex:ie.layout.flex||void 0,hidden:!!ie.layout.hidden,pin:ie.layout.pin??null,sort:ie.sort.direction??null,sortIndex:ie.sort.direction?ie.sort.order??0:null,groupIndex:ie.group.enabled?ie.group.index??0:null,pivotIndex:ie.pivot.enabled?ie.pivot.index??0:null,total:typeof ie.total=="string"?ie.total:null,groupTotal:typeof ie.groupTotal=="string"?ie.groupTotal:void 0,grandTotal:typeof ie.grandTotal=="string"?ie.grandTotal:void 0,decoration:ie.cell&&ie.cell.decoration!=null?te(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?te(ie.cell.variant):void 0}))}applyState(ie){const oe={applied:[],skipped:[]},ue=Array.isArray(ie)?ie:ie&&ie.columns||[],ce=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const Me of ue){if(!Me||!Me.id){oe.skipped.push({key:"?",reason:"no id"});continue}let $e=this.#e.get(Me.id);if(!$e){oe.skipped.push({key:Me.id,reason:"unknown column"});continue}if(Object.hasOwn(Me,"decoration")||Object.hasOwn(Me,"variant")){const Ae=$e.cell?$e.cell.decoration:void 0,ke=Me.decoration??null,ge=Object.hasOwn(Me,"variant"),Ee=ge&&!ee($e.cell?$e.cell.variant:void 0,Me.variant);(!ee(Ae,ke)||Ee)&&(this.redecorate(Me.id,ke,ge?{variant:Me.variant??void 0}:{}),$e=this.#e.get(Me.id)||$e)}Me.width!=null&&($e.layout.width=Me.width),Me.flex!=null&&($e.layout.flex=Me.flex),Me.hidden!=null&&($e.layout.hidden=!!Me.hidden),Me.pin!==void 0&&($e.layout.pin=Me.pin),Me.sort!==void 0&&($e.sort.direction=Me.sort),Me.sortIndex!=null&&($e.sort.order=Me.sortIndex),Me.groupIndex!=null&&($e.group.enabled=!0,$e.group.index=Me.groupIndex),Me.pivotIndex!=null&&($e.pivot.enabled=!0,$e.pivot.index=Me.pivotIndex),Me.total!==void 0&&($e.total=Me.total),Me.groupTotal!==void 0&&($e.groupTotal=Me.groupTotal),Me.grandTotal!==void 0&&($e.grandTotal=Me.grandTotal),oe.applied.push(Me.id)}const pe=ce||ue.map(Me=>Me&&Me.id).filter(Boolean);if(pe.length){const Me=pe.filter(Ae=>this.#e.has(Ae)),$e=this.#t.filter(Ae=>!Me.includes(Ae));this.#t=[...Me,...$e]}return this.#v&&this.#v("state",oe),oe}move(ie,oe){const ue=this.#t.indexOf(ie);if(ue===-1)return;const ce=this.#e.get(ie);if(ce.layout.movable===!1||ce.layout.lockPosition){y(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`);return}const pe=this.#T(ie,oe);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(oe,this.#t.length)),0,ie),this.#I(),this.#v&&this.#v("move",{id:ie,to:oe})}#T(ie,oe){if(!this.#n||!this.#n.length)return null;const ue=this.#t.filter($e=>$e!==ie),ce=Math.max(0,Math.min(oe,ue.length)),pe=($e,Ae)=>{if(Array.isArray($e.columns)){for(const ge of $e.columns)pe(ge,Ae);return Ae}const ke=$e.column?$e.column.id:$e.id;return ke&&Ae.push(ke),Ae},Me=$e=>{for(const Ae of $e){if(!Array.isArray(Ae.columns))continue;if(Ae.marryChildren===!0){const ge=pe(Ae,[]),Ee=ge.includes(ie),De=ge.map(ze=>ue.indexOf(ze)).filter(ze=>ze>=0);if(De.length){const ze=Math.min(...De),qe=Math.max(...De);if(Ee?ce<ze||ce>qe+1:ce>ze&&ce<=qe)return Ae.id}}const ke=Me(Ae.columns);if(ke)return ke}return null};return Me(this.#n)}#I(){const ie=new Map(this.#t.map((ce,pe)=>[ce,pe])),oe=ce=>{if(!Array.isArray(ce.columns)){const Me=ce.column?ce.column.id:ce.id;return ie.has(Me)?ie.get(Me):1/0}let pe=1/0;for(const Me of ce.columns)pe=Math.min(pe,oe(Me));return pe},ue=ce=>{ce.sort((pe,Me)=>oe(pe)-oe(Me));for(const pe of ce)Array.isArray(pe.columns)&&ue(pe.columns)};ue(this.#n)}#N(ie){const oe=ue=>{for(let ce=0;ce<ue.length;ce++){const pe=ue[ce];if(Array.isArray(pe.columns)){const Me=oe(pe.columns);if(Me)return Me}else if(pe.column&&pe.column.id===ie)return ue.splice(ce,1)[0]}return null};return oe(this.#n)}#D(ie){const oe=[];for(let ue=ie.length-1;ue>=0;ue--){const ce=ie[ue];Array.isArray(ce.columns)&&(oe.push(...this.#D(ce.columns)),ce.columns.length===0&&(oe.push(ce.id),ie.splice(ue,1)))}return oe}#M(){const ie=(oe,ue)=>{for(const ce of oe)Array.isArray(ce.columns)?ie(ce.columns,[...ue,ce.id]):ce.column&&(ce.column.groupPath=ue)};ie(this.#n,[])}#x(ie){const oe=new Set(ie),ue=this.#t.filter($e=>oe.has($e));if(!ue.length)return;const ce=Math.min(...ue.map($e=>this.#t.indexOf($e))),pe=this.#t.slice(0,ce).filter($e=>!oe.has($e)),Me=this.#t.slice(ce).filter($e=>!oe.has($e));this.#t=[...pe,...ue,...Me]}#W(ie){const oe=[],ue=ce=>{if(Array.isArray(ce.columns))for(const pe of ce.columns)ue(pe);else ce.column&&oe.push(ce.column.id)};return ue(ie),oe}#R(ie){const oe=ue=>{for(const ce of ue){if(!Array.isArray(ce.columns))continue;if(ce.id===ie)return{node:ce,parent:ue};const pe=oe(ce.columns);if(pe)return pe}return null};return oe(this.#n)}groupColumns(ie,oe={}){const ue=v(ie).filter(Ae=>this.#e.has(Ae));if(!ue.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ae of ue)if(this.#e.get(Ae).layout.lockPosition)return y(`columns.group.locked:${Ae}`,`column "${Ae}" is position-locked and cannot be grouped.`),null;const ce=oe.groupId?this.#R(oe.groupId):null;if(oe.groupId&&!ce)return y(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let pe=null;if(!ce&&oe.id!=null&&(pe=String(oe.id),this.#R(pe)||this.#e.has(pe)))return y(`columns.group.idtaken:${pe}`,`band id "${pe}" is already in use; nothing was grouped.`),null;const Me=ue.map(Ae=>this.#N(Ae)).filter(Boolean);if(!Me.length)return null;let $e;if(ce)ce.node.columns.push(...Me),$e=ce.node.id;else{const Ae={id:pe||k("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Me},ke=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(ke,0,Ae),$e=Ae.id}return this.#D(this.#n),this.#x(ue),this.#M(),this.#I(),this.#v&&this.#v("columngroup",{action:"formed",groupId:$e,ids:ue}),$e}ungroupColumn(ie){const oe=this.#e.get(ie);if(!oe){y(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ue=oe.groupPath||[];if(!ue.length)return;const ce=ue[ue.length-1],pe=this.#R(ce);if(!pe)return;const Me=this.#N(ie);if(!Me)return;const $e=pe.parent.indexOf(pe.node);pe.parent.splice($e+1,0,Me);const Ae=this.#D(this.#n),ke=this.#W(pe.node);if(ke.length){this.#x(ke);const ge=Math.max(...ke.map(De=>this.#t.indexOf(De))),Ee=this.#t.filter(De=>De!==ie);Ee.splice(ge+1,0,ie),this.#t=Ee}this.#M(),this.#I(),this.#v&&this.#v("columngroup",{action:"removed",id:ie,dissolved:Ae})}renameGroup(ie,oe){const ue=this.#R(ie);if(!ue){y(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ue.node.title=String(oe??""),this.#v&&this.#v("columngroup",{action:"renamed",groupId:ie,title:ue.node.title})}dissolveGroup(ie){const oe=this.#R(ie);if(!oe){y(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ue=oe.parent.indexOf(oe.node);oe.parent.splice(ue,1,...oe.node.columns),this.#M(),this.#I(),this.#v&&this.#v("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,oe){const ue=this.#R(ie);if(!ue){y(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const ce=ue.parent,pe=ce.indexOf(ue.node);pe!==-1&&(ce.splice(pe,1),ce.splice(Math.max(0,Math.min(oe,ce.length)),0,ue.node),this.#_(),this.#M(),this.#v&&this.#v("columngroup",{action:"moved",groupId:ie,to:oe}))}#_(){const ie=[],oe=ce=>{for(const pe of ce)Array.isArray(pe.columns)?oe(pe.columns):pe.column&&ie.push(pe.column.id)};oe(this.#n);const ue=new Set(ie);this.#t=[...ie,...this.#t.filter(ce=>!ue.has(ce))]}groupTree(){const ie=ue=>ue.map(ce=>Array.isArray(ce.columns)?{id:ce.id,title:ce.title||"",collapsible:!!ce.collapsible,openByDefault:ce.openByDefault!==!1,columns:ie(ce.columns)}:ce.column?ce.column.id:null).filter(ce=>ce!==null),oe=ie(this.#n);return oe.some(ue=>ue&&typeof ue=="object")?oe:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const oe=new Set,ue=pe=>{const Me=[];for(const $e of pe)if($e&&typeof $e=="object"&&Array.isArray($e.columns)){const Ae=ue($e.columns);if(!Ae.length)continue;Me.push({id:$e.id||k("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ae})}else if(typeof $e=="string"){const Ae=this.#e.get($e);Ae&&!oe.has($e)&&(oe.add($e),Me.push({column:Ae,path:[]}))}return Me},ce=ue(ie);for(const pe of this.#t){if(oe.has(pe))continue;const Me=this.#e.get(pe);Me&&ce.push({column:Me,path:[]})}this.#n=ce,this.#M(),this.#I(),this.#v&&this.#v("columngroup",{action:"applied"})}show(ie){this.#B(ie,!1)}hide(ie){this.#B(ie,!0)}#B(ie,oe){const ue=[];for(const ce of v(ie)){const pe=this.#e.get(ce);if(pe){if(oe&&pe.layout.lockVisible){y(`lockVisible:${ce}`,`column "${ce}" is \`layout.lockVisible\` and cannot be hidden`);continue}pe.layout.hidden!==oe&&(pe.layout.hidden=oe,ue.push(ce))}}ue.length&&this.#v&&this.#v("visible",{ids:ue,hidden:oe})}pin(ie,oe){const ue=this.#e.get(ie);ue&&(ue.layout.pin=oe??null,this.#v&&this.#v("pin",{id:ie,side:ue.layout.pin}))}resize(ie,oe){const ue=this.#e.get(ie);if(!ue)return;if(ue.layout.resizable===!1){y(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const ce=ue.layout.min??0,pe=ue.layout.max;let Me=Math.max(ce,oe);pe!=null&&(Me=Math.min(pe,Me)),ue.layout.width=Me,ue.layout.flex=0,this.#v&&this.#v("resize",{id:ie,width:Me})}}function J(de){const ie={};return de.width!=null&&(ie.width=de.width),de.hidden!=null&&(ie.hidden=de.hidden),de.pin!==void 0&&(ie.pin=de.pin),ie}function te(de){if(de===null||typeof de!="object")return de;try{return structuredClone(de)}catch{}try{return JSON.parse(JSON.stringify(de))}catch{return de}}function ee(de,ie){const oe=de??null,ue=ie??null;if(oe===ue)return!0;if(oe===null||ue===null)return!1;if(typeof oe!="object"||typeof ue!="object")return oe===ue;try{return JSON.stringify(oe)===JSON.stringify(ue)}catch{return!1}}function re(de){const ie=[],oe=(ce,pe)=>{const Me=[];for(const $e of ce){if(!H($e)){I("a column definition must be an object");continue}if(Array.isArray($e.columns)){z($e,C,"columnGroup",$e.title||$e.id||"(unnamed)");const Ae={id:$e.id||k("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:$e.showWhen||"always",marryChildren:$e.marryChildren===!0,header:$e.header||{},def:$e,columns:[]};Ae.columns=oe($e.columns,[...pe,Ae.id]),Me.push(Ae)}else{const Ae={def:$e,path:pe};ie.push(Ae),Me.push(Ae)}}return Me},ue=oe(de,[]);return{leaves:ie,groups:ue}}function se(de,ie,oe){for(const ue of de){if(ue.columns){if(se(ue.columns,ie,oe))return!0;continue}if(ue.column&&ue.column.id===ie)return ue.column=oe,!0}return!1}}),je("packages/core/src/columns/autogroup.js",function(e,V){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return H}});const M=V("packages/core/src/internal/util.js").warnOnce,I="__lattice_group",N=240,W=.5;function _(B){const{columns:G,groupBy:D}=B,v=D.map(c=>G.get(c)).filter(Boolean),k=v.length?v.map(c=>c.title||c.id).join(" > "):"Group",y=B.config&&B.config.autoGroupColumnWidth||N;return{id:I,field:null,title:k,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:D.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(c,o){return o&&o.group?o.groupValue:null},formatValue(c,o){if(!o||!o.group)return"";if(o.grandTotal)return B.config&&B.config.grandTotalLabel||"Total";const n=v[Math.min(o.level||0,v.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(c,o):c==null?"":String(c)}}}function H(B,G,D){!B.length||D<100||G<D*W||M(`grouping.cardinality:${B.join(",")}`,`grouping by ${B.join(", ")} produced ${G} groups for ${D} 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.`)}}),je("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 I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Z="__lattice_select",M=44;function I(W){const _=W.selection||{},H=W.config&&W.config.selectionColumnWidth||M;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:H,min:H,max:H,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,G){return G?G.selected:!1},formatValue(){return""}}}const N=I}),je("packages/core/src/columns/rownumbercolumn.js",function(e,V){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const M=V("packages/core/src/internal/util.js").isFunction,I="__lattice_rownumber",N=40,W=9,_=22;function H(D){const v=String(Math.max(1,Math.trunc(Math.abs(D))||1)).length;return Math.max(N,v*W+_)}function B(D){const v=D.rowNumbers,k=v&&typeof v=="object"?v:{},y=Number.isFinite(k.start)?k.start:1,c=Number.isFinite(k.width)?k.width:H((D.maxNumber||0)+y),o=M(D.rank)?D.rank:()=>null;return{id:I,field:null,title:typeof k.title=="string"?k.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:c,min:c,max:c,pin:"start",hidden:!1,resizable:k.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(n,t){const i=o(t);return i==null?null:i-1+y},formatValue(n){return n==null?"":String(n)}}}const G=B}),je("packages/core/src/model/detail.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return N}}),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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N=240,W=10;function _(G){if(!G)return null;const D=G===!0?{}:G;return D.enabled===!1?null:!M(D.rows)&&!D.render?(I("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:D.render||null,config:D.config||null,rows:M(D.rows)?D.rows:null,height:D.height??N,cacheLimit:Number.isFinite(D.cacheLimit)?Math.max(0,D.cacheLimit):W,isMaster:M(D.isMaster)?D.isMaster:null,target:D.target||null,onCreate:M(D.onCreate)?D.onCreate:null,path:typeof D.path=="string"?D.path:null}}class H{#e;#t=new Set;#n;#r=0;constructor(D){this.#e=D.config,this.#n=M(D.onChange)?D.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(D){if(!D||D.group||D.detail)return!1;const v=this.#e.isMaster;return v?!!v(D.data,D):!0}isOpen(D){return this.#t.has(D)}keys(){return[...this.#t]}activeKey(){for(const D of this.#t)return D;return null}heightOf(D){const v=this.#e.height;return M(v)?Number(v(D))||N:v==="auto"?N:Number(v)||N}open(D){return this.#t.has(D)?!1:(this.inline||this.#t.clear(),this.#t.add(D),this.#o(),!0)}close(D){return this.#t.delete(D)?(this.#o(),!0):!1}toggle(D){return this.#t.has(D)?(this.close(D),!1):(this.open(D),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(D){if(!this.#t.size||!M(D))return;let v=!1;for(const k of[...this.#t])D(k)||(this.#t.delete(k),v=!0);v&&this.#o()}signature(){return`${this.#r}`}set(D){this.#t.clear();const v=Array.isArray(D)?D:[];for(const k of this.inline?v:v.slice(0,1))this.#t.add(k);this.#o()}#o(){this.#r++,this.#n()}}const B=H}),je("packages/core/src/compute/special.js",function(e,V){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return n}});const Z=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),M=3e-12,I=1e-300;function N(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-N(1-t);const i=t-1;let a=.9999999999998099;const r=i+7.5;for(let s=0;s<Z.length;s++)a+=Z[s]/(i+s+1);return .5*Math.log(2*Math.PI)+(i+.5)*Math.log(r)-r+Math.log(a)}function W(t,i,a){const r=t+i,s=t+1,u=t-1;let l=1,p=1-r*a/s;Math.abs(p)<I&&(p=I),p=1/p;let m=p;for(let b=1;b<=300;b++){const g=2*b;let f=b*(i-b)*a/((u+g)*(t+g));p=1+f*p,Math.abs(p)<I&&(p=I),l=1+f/l,Math.abs(l)<I&&(l=I),p=1/p,m*=p*l,f=-(t+b)*(r+b)*a/((t+g)*(s+g)),p=1+f*p,Math.abs(p)<I&&(p=I),l=1+f/l,Math.abs(l)<I&&(l=I),p=1/p;const w=p*l;if(m*=w,Math.abs(w-1)<M)break}return m}function _(t,i,a){if(!(t>0)||!(i>0)||!Number.isFinite(a))return Number.NaN;if(a<=0)return 0;if(a>=1)return 1;const r=Math.exp(N(t+i)-N(t)-N(i)+t*Math.log(a)+i*Math.log(1-a));return a<(t+1)/(t+i+2)?r*W(t,i,a)/t:1-r*W(i,t,1-a)/i}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const i=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],a=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],r=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let l,p,m;t<u?(l=Math.sqrt(-2*Math.log(t)),m=(((((r[0]*l+r[1])*l+r[2])*l+r[3])*l+r[4])*l+r[5])/((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+1)):t<=1-u?(l=t-.5,p=l*l,m=(((((i[0]*p+i[1])*p+i[2])*p+i[3])*p+i[4])*p+i[5])*l/(((((a[0]*p+a[1])*p+a[2])*p+a[3])*p+a[4])*p+1)):(l=Math.sqrt(-2*Math.log(1-t)),m=-(((((r[0]*l+r[1])*l+r[2])*l+r[3])*l+r[4])*l+r[5])/((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+1));const g=(.5*B(-m/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(m*m/2);return m-g/(1+m*g/2)}function B(t){const i=Math.abs(t),a=2/(2+i),r=4*a-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,l=0,p;for(let b=s.length-1;b>0;b--)p=l,l=r*l-u+s[b],u=p;const m=a*Math.exp(-i*i+.5*(s[0]+r*l)-u);return t>=0?m:2-m}function G(t){return .5*B(-t/Math.SQRT2)}function D(t,i){if(!(i>0)||!Number.isFinite(t))return Number.NaN;const a=.5*_(i/2,.5,i/(i+t*t));return t>0?1-a:a}function v(t,i){if(!(t>0)||!(t<1)||!(i>0))return Number.NaN;if(i>1e7)return H(t);let a=-1e4,r=1e4,s=H(t);const u=N(i/2)+N(.5)-N((i+1)/2);for(let l=0;l<60;l++){const p=D(s,i);p<t?a=s:r=s;const m=Math.exp(-((i+1)/2)*Math.log(1+s*s/i)-u)/Math.sqrt(i),b=m>0?(p-t)/m:0;if(Math.abs(b)<1e-12)break;const g=s-b;if(s=g>a&&g<r&&Number.isFinite(g)?g:(a+r)/2,r-a<1e-12)break}return s}function k(t,i){let a=t,r=1/t,s=r;for(let u=0;u<300&&(a+=1,s*=i/a,r+=s,!(Math.abs(s)<Math.abs(r)*M));u++);return r*Math.exp(-i+t*Math.log(i)-N(t))}function y(t,i){let a=i+1-t,r=1/I,s=1/a,u=s;for(let l=1;l<=300;l++){const p=-l*(l-t);a+=2,s=p*s+a,Math.abs(s)<I&&(s=I),r=a+p/r,Math.abs(r)<I&&(r=I),s=1/s;const m=s*r;if(u*=m,Math.abs(m-1)<M)break}return Math.exp(-i+t*Math.log(i)-N(t))*u}function c(t,i){return!(t>0)||!(i>=0)||!Number.isFinite(i)?Number.NaN:i===0?0:i<t+1?k(t,i):1-y(t,i)}function o(t,i){return i>0?c(i/2,t/2):Number.NaN}function n(t,i){const a=o(t,i);return Number.isNaN(a)?Number.NaN:Math.min(1,Math.max(0,1-a))}}),je("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 M}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return _}});function Z(H){const B=H.length,G=Array.from({length:B},()=>new Array(B).fill(0));for(let D=0;D<B;D++)for(let v=0;v<=D;v++){let k=H[D][v];for(let y=0;y<v;y++)k-=G[D][y]*G[v][y];if(D===v){if(!(k>0))return null;G[D][v]=Math.sqrt(k)}else G[D][v]=k/G[v][v]}return G}function M(H,B){const G=H.length,D=new Array(G).fill(0);for(let k=0;k<G;k++){let y=B[k];for(let c=0;c<k;c++)y-=H[k][c]*D[c];D[k]=y/H[k][k]}const v=new Array(G).fill(0);for(let k=G-1;k>=0;k--){let y=D[k];for(let c=k+1;c<G;c++)y-=H[c][k]*v[c];v[k]=y/H[k][k]}return v}function I(H){const B=H.length,G=Array.from({length:B},()=>new Array(B).fill(0));for(let D=0;D<B;D++){const v=new Array(B).fill(0);v[D]=1;const k=M(H,v);for(let y=0;y<B;y++)G[y][D]=k[y]}return G}function N(H,B,G){const D=H.length,v=D?H[0].length:0,k=Array.from({length:v},()=>new Array(v).fill(0)),y=new Array(v).fill(0);for(let c=0;c<D;c++){const o=G?G[c]:1,n=H[c];for(let t=0;t<v;t++){const i=o*n[t];y[t]+=i*B[c];for(let a=t;a<v;a++)k[t][a]+=i*n[a]}}for(let c=0;c<v;c++)for(let o=0;o<c;o++)k[c][o]=k[o][c];return{xtwx:k,xtwy:y}}function W(H,B){return H.map(G=>G.reduce((D,v,k)=>D+v*B[k],0))}function _(H,B){let G=0;for(let D=0;D<H.length;D++){let v=0;for(let k=0;k<H.length;k++)v+=B[D][k]*H[k];G+=H[D]*v}return G}}),je("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 M}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});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(c){if(!Number.isFinite(c))return;this.#e++;const o=c-this.#t;this.#t+=o/this.#e,this.#n+=o*(c-this.#t)}merge(c){if(c.#e===0)return;if(this.#e===0){this.#e=c.#e,this.#t=c.#t,this.#n=c.#n;return}const o=this.#e+c.#e,n=c.#t-this.#t;this.#t+=n*(c.#e/o),this.#n+=c.#n+n*n*(this.#e*c.#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 c=this.variance();return c===null?null:Math.sqrt(c)}stddevP(){const c=this.varianceP();return c===null?null:Math.sqrt(c)}}class M{#e=[];#t=0;#n;#r;constructor(c,o=Math.random){if(!(c>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(c),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(c){if(!Number.isFinite(c))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(c);return}const o=Math.floor(this.#r()*this.#t);o<this.#n&&(this.#e[o]=c)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let c=0;for(const o of this.#e)c+=o;return c/this.#e.length}quantile(c){const o=this.#e.length;if(!o)return null;const n=this.#e.slice().sort((r,s)=>r-s);if(o===1)return n[0];const t=(o-1)*Math.min(1,Math.max(0,c)),i=Math.floor(t),a=Math.ceil(t);return i===a?n[i]:n[i]+(t-i)*(n[a]-n[i])}}function I(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function N(y){if(typeof y=="number"){const n=new DataView(new ArrayBuffer(8));return n.setFloat64(0,y===0?0:y),I(n.getUint32(0)^n.getUint32(4))}const c=typeof y=="string"?y:String(y);let o=2166136261;for(let n=0;n<c.length;n++)o^=c.charCodeAt(n),o=Math.imul(o,16777619);return I(o)}class W{#e;#t;#n;constructor(c=14){const o=Math.floor(c);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(c=14){const o=1<<Math.floor(c),n=1.04/Math.sqrt(o);return Object.freeze({kind:"probabilistic",metric:"relative",value:n,statement:`distinct count within ~${(n*100).toFixed(2)}% relative standard error (m=${o} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(c){const o=N(c),n=o&this.#t-1,t=o>>>this.#e|1<<32-this.#e;let i=1,a=t;for(;(a&1)===0;)i++,a>>>=1;i>this.#n[n]&&(this.#n[n]=i)}count(){const c=this.#t,o=32-this.#e,n=new Float64Array(o+2);for(let a=0;a<c;a++)n[this.#n[a]]++;let t=c*B(1-n[o+1]/c);for(let a=o;a>=1;a--)t=.5*(t+n[a]);t+=c*H(n[0]/c);const i=_*c*c/t;return Math.round(i)}}const _=.5/Math.log(2);function H(y){if(y===1)return 1/0;let c=1,o=y,n;do y*=y,n=o,o+=y*c,c+=c;while(o!==n);return o}function B(y){if(y===0||y===1)return 0;let c=1,o=1-y,n;do y=Math.sqrt(y),n=o,c*=.5,o-=(1-y)**2*c;while(o!==n);return o/3}class G{#e=new Map;#t;#n=0;constructor(c){if(!(c>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(c)}errorBoundFor(c){const o=c/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=${c}, m=${this.#t})`})}get seen(){return this.#n}add(c){this.#n++;const o=this.#e.get(c);if(o){o.count++;return}if(this.#e.size<this.#t){this.#e.set(c,{count:1,error:0});return}let n,t=1/0;for(const[i,a]of this.#e)a.count<t&&(t=a.count,n=i);this.#e.delete(n),this.#e.set(c,{count:t+1,error:t})}top(c=this.#t){return[...this.#e.entries()].map(([n,t])=>({item:n,count:t.count,error:t.error})).sort((n,t)=>t.count-n.count).slice(0,Math.max(0,Math.floor(c)))}}class D{#e;#t=[[]];#n=0;#r;#o;constructor(c=200,o=Math.random){this.#e=Math.max(8,Math.floor(c)),this.#r=o,this.#o=2/3}static errorBoundFor(c=200){const o=1/Math.max(8,Math.floor(c));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=${c})`})}errorBound(){return D.errorBoundFor(this.#e)}get count(){return this.#n}#i(c){const n=this.#t.length-1-c,t=Math.ceil(this.#e*this.#o**n);return Math.max(2,t)}add(c){Number.isFinite(c)&&(this.#n++,this.#t[0].push(c),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(c){const o=this.#t[c];o.sort((i,a)=>i-a),c+1>=this.#t.length&&this.#t.push([]);const n=this.#t[c+1],t=this.#r()<.5?0:1;for(let i=t;i<o.length;i+=2)n.push(o[i]);this.#t[c]=[];for(let i=0;i<this.#t.length;i++)if(this.#t[i].length>=this.#i(i)){this.#s(i);return}}#l(){const c=[];for(let o=0;o<this.#t.length;o++){const n=1<<o;for(const t of this.#t[o])c.push({v:t,w:n})}return c}quantile(c){const o=this.#l();if(!o.length)return null;o.sort((a,r)=>a.v-r.v);let n=0;for(const a of o)n+=a.w;const t=Math.min(1,Math.max(0,c))*n;let i=0;for(const a of o)if(i+=a.w,i>=t)return a.v;return o[o.length-1].v}rank(c){let o=0;for(let n=0;n<this.#t.length;n++){const t=1<<n;for(const i of this.#t[n])i<=c&&(o+=t)}return o}}const v=Object.freeze({distinct:W.errorBoundFor(14),median:D.errorBoundFor(200),p25:D.errorBoundFor(200),p75:D.errorBoundFor(200),p90:D.errorBoundFor(200),p95:D.errorBoundFor(200),p99:D.errorBoundFor(200),iqr:D.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"})}),k={Welford:Z,Reservoir:M,HyperLogLog:W,SpaceSaving:G,KLL:D,hash32:N,SKETCH_BOUNDS:v}}),je("packages/core/src/compute/statistics.js",function(e,V){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return De}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return At}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return gt}});const Z=V("packages/core/src/compute/handle.js"),M=Z.presenceReader,I=Z.valueReader,N=V("packages/core/src/compute/special.js"),W=N.studentTQuantile,_=N.studentT,H=N.normalQuantile,B=N.normalCdf,G=N.chiSquareUpperTail,D=V("packages/core/src/compute/linalg.js"),v=D.cholesky,k=D.choleskySolve,y=D.choleskyInverse,c=D.normalEquations,o=D.quadForm,t=V("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,i=5e3,a=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"}),r=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 s(me){const Oe=me==="sum"||me==="avg"||me==="countValues"||me==="min"||me==="max"?"maintained":Object.prototype.hasOwnProperty.call(a,me)?a[me]:null,we=Object.prototype.hasOwnProperty.call(r,me)?r[me]:null;return{stat:me,exact:Oe,approximate:we}}function u(me,Oe){const we=Oe.length,Ne=new Float64Array(we);let he=0;if(me&&(me.kind==="float64"||me.kind==="int32")){const Ce=me.values,Re=M(me);for(let Be=0;Be<we;Be++){const We=Oe[Be];if(Re&&Re(We)!==1)continue;const ft=Ce[We];Number.isNaN(ft)||(Ne[he++]=ft)}return Ne.subarray(0,he)}const Te=I(me);for(let Ce=0;Ce<we;Ce++){const Re=Te(Oe[Ce]);if(Re==null||Re==="")continue;const Be=typeof Re=="number"?Re:Number(Re);Number.isFinite(Be)&&(Ne[he++]=Be)}return Ne.subarray(0,he)}function l(me,Oe){const we=new Map,Ne=I(me);let he=0;for(let Te=0;Te<Oe.length;Te++){const Ce=Ne(Oe[Te]);if(Ce==null||Ce===""||typeof Ce=="number"&&Number.isNaN(Ce))continue;const Re=typeof Ce=="object"?String(Ce):Ce;we.set(Re,(we.get(Re)||0)+1),he++}const ve=[...we.values()].sort((Te,Ce)=>Ce-Te);return{counts:ve,total:he,distinct:ve.length}}function p(me){return me.total>0?me.counts.map(Oe=>Oe/me.total):[]}function m(me,Oe){const we=l(me,Oe);if(!we.total)return null;let Ne=0;for(const he of p(we))Ne+=he*he;return Ne}function b(me,Oe){const we=l(me,Oe);if(!we.total)return null;let Ne=0;for(const he of p(we))he>0&&(Ne-=he*Math.log2(he));return Ne}function g(me,Oe){const we=l(me,Oe);if(!we.total||we.distinct<2)return we.total?1:null;let Ne=0;for(const he of p(we))he>0&&(Ne-=he*Math.log2(he));return Ne/Math.log2(we.distinct)}function f(me,Oe,we=3){const Ne=l(me,Oe);if(!Ne.total)return null;const he=Math.max(1,Math.floor(we));let ve=0;for(let Te=0;Te<Math.min(he,Ne.counts.length);Te++)ve+=Ne.counts[Te];return ve/Ne.total}function w(me,Oe){const we=u(me,Oe),Ne=we.length;if(!Ne)return null;const he=we.slice().sort();if(he[0]<0)return null;let ve=0,Te=0;for(let Ce=0;Ce<Ne;Ce++)ve+=he[Ce],Te+=(Ce+1)*he[Ce];return ve===0?0:2*Te/(Ne*ve)-(Ne+1)/Ne}function S(me){let Oe=0,we=0,Ne=0;for(let he=0;he<me.length;he++){const ve=me[he];Oe++;const Te=ve-we;we+=Te/Oe,Ne+=Te*(ve-we)}return{n:Oe,mean:we,m2:Ne}}function h(me,Oe){const we=me.length;if(!we)return NaN;if(we===1)return me[0];const Ne=(we-1)*Math.min(1,Math.max(0,Oe)),he=Math.floor(Ne),ve=Math.ceil(Ne);return he===ve?me[he]:me[he]+(Ne-he)*(me[ve]-me[he])}function d(me,Oe){if(!me.length)return NaN;const we=me.slice().sort();return h(we,Oe)}function j(me,Oe){const we=I(me);let Ne=0,he=0,ve=0;for(let Te=0;Te<Oe.length;Te++){const Ce=we(Oe[Te]);if(Ce==null||Ce==="")continue;const Re=String(Ce).toUpperCase();Re==="PASS"?Ne++:Re==="FAIL"?he++:Re==="WARN"&&ve++}return{pass:Ne+ve,fail:he,warn:ve,judged:Ne+ve+he}}const E=Object.freeze({hhi:(me,Oe)=>m(me,Oe),entropy:(me,Oe)=>b(me,Oe),evenness:(me,Oe)=>g(me,Oe),top3Share:(me,Oe)=>f(me,Oe,3),top10Share:(me,Oe)=>f(me,Oe,10),gini:(me,Oe)=>w(me,Oe),trimmedMean:(me,Oe)=>L(u(me,Oe),.1),winsorizedMean:(me,Oe)=>$(u(me,Oe),.1),robustOutliers:(me,Oe)=>U(u(me,Oe),3.5),jarqueBera:(me,Oe)=>x(u(me,Oe)),variance:(me,Oe)=>{const{n:we,m2:Ne}=S(u(me,Oe));return we>1?Ne/(we-1):null},varianceP:(me,Oe)=>{const{n:we,m2:Ne}=S(u(me,Oe));return we>0?Ne/we:null},stddev:(me,Oe)=>{const{n:we,m2:Ne}=S(u(me,Oe));return we>1?Math.sqrt(Ne/(we-1)):null},stddevP:(me,Oe)=>{const{n:we,m2:Ne}=S(u(me,Oe));return we>0?Math.sqrt(Ne/we):null},median:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.5):null},p25:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.25):null},p75:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.75):null},p90:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.9):null},p95:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.95):null},p99:(me,Oe)=>{const we=u(me,Oe);return we.length?d(we,.99):null},iqr:(me,Oe)=>{const we=u(me,Oe);if(!we.length)return null;const Ne=we.slice().sort();return h(Ne,.75)-h(Ne,.25)},mad:(me,Oe)=>{const we=u(me,Oe);if(!we.length)return null;const Ne=d(we,.5),he=new Float64Array(we.length);for(let ve=0;ve<we.length;ve++)he[ve]=Math.abs(we[ve]-Ne);return d(he,.5)},range:(me,Oe)=>{const we=u(me,Oe);if(!we.length)return null;let Ne=1/0,he=-1/0;for(let ve=0;ve<we.length;ve++)we[ve]<Ne&&(Ne=we[ve]),we[ve]>he&&(he=we[ve]);return he-Ne},distinct:(me,Oe)=>{const we=I(me),Ne=new Set;for(let he=0;he<Oe.length;he++){const ve=we(Oe[he]);ve==null||ve===""||Ne.add(ve instanceof Date?ve.getTime():ve)}return Ne.size},mode:(me,Oe)=>{const we=I(me),Ne=new Map;for(let Te=0;Te<Oe.length;Te++){const Ce=we(Oe[Te]);if(Ce==null||Ce==="")continue;const Re=Ce instanceof Date?Ce.getTime():Ce;Ne.set(Re,(Ne.get(Re)||0)+1)}let he=null,ve=1;for(const[Te,Ce]of Ne)Ce>ve&&(ve=Ce,he=Te);return he},skewness:(me,Oe)=>{const we=u(me,Oe),{n:Ne,mean:he,m2:ve}=S(we);if(Ne<3||ve<=0)return null;const Te=Math.sqrt(ve/(Ne-1));let Ce=0;for(let Re=0;Re<we.length;Re++)Ce+=((we[Re]-he)/Te)**3;return Ne/((Ne-1)*(Ne-2))*Ce},kurtosis:(me,Oe)=>{const we=u(me,Oe),{n:Ne,mean:he,m2:ve}=S(we);if(Ne<4||ve<=0)return null;const Te=Math.sqrt(ve/(Ne-1));let Ce=0;for(let We=0;We<we.length;We++)Ce+=((we[We]-he)/Te)**4;const Re=Ne*(Ne+1)/((Ne-1)*(Ne-2)*(Ne-3)),Be=3*(Ne-1)**2/((Ne-2)*(Ne-3));return Re*Ce-Be},geomean:(me,Oe)=>{const we=u(me,Oe);if(!we.length)return null;let Ne=0;for(let he=0;he<we.length;he++){if(we[he]<=0)return null;Ne+=Math.log(we[he])}return Math.exp(Ne/we.length)},harmean:(me,Oe)=>{const we=u(me,Oe);if(!we.length)return null;let Ne=0;for(let he=0;he<we.length;he++){if(we[he]===0)return null;Ne+=1/we[he]}return we.length/Ne},sumSquares:(me,Oe)=>{const we=u(me,Oe);let Ne=0;for(let he=0;he<we.length;he++)Ne+=we[he]*we[he];return Ne},passRate:(me,Oe)=>{const{pass:we,judged:Ne}=j(me,Oe);return Ne?we/Ne:null},failureCount:(me,Oe)=>j(me,Oe).fail}),O=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function T(me,Oe,we){const Ne=I(me),he=I(Oe);let ve=0,Te=0;for(let Ce=0;Ce<we.length;Ce++){const Re=we[Ce],Be=Number(Ne(Re)),We=Number(he(Re));!Number.isFinite(Be)||!Number.isFinite(We)||(ve+=Be*We,Te+=We)}return Te===0?null:ve/Te}function A(me,Oe,we){const Ne=I(me);let he=null,ve=we?-1/0:1/0;for(let Te=0;Te<Oe.length;Te++){const Ce=Oe[Te],Re=Number(Ne(Ce));Number.isFinite(Re)&&(we?Re>ve:Re<ve)&&(ve=Re,he=Ce)}return he}function P(me,Oe,we){const Ne=I(me),he=I(Oe);let ve=0,Te=0,Ce=0,Re=0,Be=0,We=0;for(let ct=0;ct<we.length;ct++){const vt=we[ct],St=Number(Ne(vt)),Le=Number(he(vt));!Number.isFinite(St)||!Number.isFinite(Le)||(ve++,Te+=St,Ce+=Le,Re+=St*St,Be+=Le*Le,We+=St*Le)}if(ve<2)return null;const ft=ve*We-Te*Ce,at=Math.sqrt((ve*Re-Te*Te)*(ve*Be-Ce*Ce));if(at===0)return null;const mt=ft/at;return Math.max(-1,Math.min(1,mt))}function L(me,Oe=.1){const we=me.length;if(!we)return null;const Ne=Array.from(me).sort((Ce,Re)=>Ce-Re),he=Math.floor(we*Math.min(.49,Math.max(0,Oe))),ve=Ne.slice(he,we-he);if(!ve.length)return h(Ne,.5);let Te=0;for(const Ce of ve)Te+=Ce;return Te/ve.length}function $(me,Oe=.1){const we=me.length;if(!we)return null;const Ne=Array.from(me).sort((Re,Be)=>Re-Be),he=Math.floor(we*Math.min(.49,Math.max(0,Oe))),ve=Ne[he],Te=Ne[we-1-he];let Ce=0;for(const Re of Ne)Ce+=Math.min(Te,Math.max(ve,Re));return Ce/we}function U(me,Oe=3.5){if(!me.length)return null;const Ne=Array.from(me).sort((Re,Be)=>Re-Be),he=h(Ne,.5),ve=Ne.map(Re=>Math.abs(Re-he)).sort((Re,Be)=>Re-Be),Te=h(ve,.5);if(Te===0)return null;let Ce=0;for(const Re of Ne)Math.abs(.6745*(Re-he)/Te)>Oe&&Ce++;return Ce}function x(me){const Oe=me.length;if(Oe<8)return null;let we=0;for(const Re of me)we+=Re;we/=Oe;let Ne=0,he=0,ve=0;for(const Re of me){const Be=Re-we;Ne+=Be*Be,he+=Be*Be*Be,ve+=Be*Be*Be*Be}if(Ne/=Oe,he/=Oe,ve/=Oe,Ne===0)return null;const Te=he/Ne**1.5,Ce=ve/(Ne*Ne)-3;return Oe/6*(Te*Te+Ce*Ce/4)}function F(me,Oe,we){const Ne=[];let he=0;for(let Re=0;Re<me.length;Re++){const Be=Number(me[Re]),We=Number(Oe[Re]);!Number.isFinite(Be)||!Number.isFinite(We)||We<=0||(Ne.push([Be,We]),he+=We)}if(!Ne.length||he<=0)return null;if(Ne.sort((Re,Be)=>Re[0]-Be[0]),Ne.length===1)return Ne[0][0];const ve=[];let Te=0;for(const[,Re]of Ne)ve.push((Te+Re/2)/he),Te+=Re;const Ce=Math.max(0,Math.min(1,we));if(Ce<=ve[0])return Ne[0][0];if(Ce>=ve[ve.length-1])return Ne[Ne.length-1][0];for(let Re=1;Re<ve.length;Re++){if(Ce>ve[Re])continue;const Be=ve[Re]-ve[Re-1],We=Be>0?(Ce-ve[Re-1])/Be:0;return Ne[Re-1][0]+(Ne[Re][0]-Ne[Re-1][0])*We}return Ne[Ne.length-1][0]}function C(me,Oe,we){const Ne=I(me),he=I(Oe),ve=new Float64Array(we.length),Te=new Float64Array(we.length);let Ce=0;for(let Re=0;Re<we.length;Re++){const Be=we[Re],We=Number(Ne(Be)),ft=Number(he(Be));!Number.isFinite(We)||!Number.isFinite(ft)||(ve[Ce]=We,Te[Ce]=ft,Ce++)}return{xs:ve.subarray(0,Ce),ys:Te.subarray(0,Ce),n:Ce}}function z(me,Oe,we,Ne=!1){const{xs:he,ys:ve,n:Te}=C(me,Oe,we);if(Te<2)return null;let Ce=0,Re=0;for(let We=0;We<Te;We++)Ce+=he[We],Re+=ve[We];Ce/=Te,Re/=Te;let Be=0;for(let We=0;We<Te;We++)Be+=(he[We]-Ce)*(ve[We]-Re);return Be/(Ne?Te:Te-1)}function q(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2)return null;let Te=0,Ce=0;for(let St=0;St<ve;St++)Te+=Ne[St],Ce+=he[St];Te/=ve,Ce/=ve;let Re=0,Be=0,We=0;for(let St=0;St<ve;St++){const Le=Ne[St]-Te,rt=he[St]-Ce;Re+=Le*Le,Be+=Le*rt,We+=rt*rt}if(Re===0)return null;const ft=Be/Re,at=Ce-ft*Te,mt=We===0?1:Math.max(0,Math.min(1,Be*Be/(Re*We))),ct=Math.max(0,We-ft*Be),vt=ve>2?Math.sqrt(ct/(ve-2)/Re):0;return{slope:ft,intercept:at,r2:mt,stdError:vt,n:ve}}const Q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),te=1.345;function ee(me,Oe,we){const{xtwx:Ne,xtwy:he}=c(me,Oe,we),ve=v(Ne);if(!ve)return null;const Te=k(ve,he),Ce=y(ve),Re=re(me,Te),Be=Oe.map((We,ft)=>We-Re[ft]);return{beta:Te,cov:Ce,fitted:Re,residuals:Be}}function re(me,Oe){return me.map(we=>we.reduce((Ne,he,ve)=>Ne+he*Oe[ve],0))}function se(me,Oe){const we=me.length,Ne=me.map(Be=>Be[Oe]),he=me.map(Be=>[1,...Be.filter((We,ft)=>ft!==Oe)]),ve=ee(he,Ne,null);if(!ve)return 1;const Te=Ne.reduce((Be,We)=>Be+We,0)/we;let Ce=0,Re=0;for(let Be=0;Be<we;Be++)Ce+=ve.residuals[Be]**2,Re+=(Ne[Be]-Te)**2;return Re===0?1:Math.max(0,Math.min(1,1-Ce/Re))}function de(me){const Oe=[...me].sort((he,ve)=>he-ve),we=ie(Oe),Ne=me.map(he=>Math.abs(he-we)).sort((he,ve)=>he-ve);return ie(Ne)/.6745}function ie(me){const Oe=me.length;if(!Oe)return 0;const we=Math.floor(Oe/2);return Oe%2?me[we]:(me[we-1]+me[we])/2}function oe(me,Oe,we={}){const Ne=we.method||"ols";if(J.has(Ne))throw new Error(`[lattice] regression method "${Ne}" is out of scope; use ols, wls or robust.`);if(Y.has(Ne))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Q.has(Ne))throw new Error(`[lattice] unknown regression method "${Ne}"; use ols, wls or robust.`);const he=Array.isArray(Oe)?Oe.length:0,ve=he&&Array.isArray(me[0])?me[0].length:0,Te=ve+1;if(!(he>Te))return null;for(let jt=0;jt<he;jt++){if(!Number.isFinite(Oe[jt])||!Array.isArray(me[jt])||me[jt].length!==ve)return null;for(let Rt=0;Rt<ve;Rt++)if(!Number.isFinite(me[jt][Rt]))return null}let Ce=null;if(Ne==="wls"){if(Ce=we.weights,!Array.isArray(Ce)||Ce.length!==he)return null;for(let jt=0;jt<he;jt++)if(!(Ce[jt]>0)||!Number.isFinite(Ce[jt]))return null}const Re=me.map(jt=>[1,...jt]);let Be,We=null;if(Ne==="robust"){if(Be=ee(Re,Oe,null),!Be)return null;for(let jt=0;jt<50;jt++){const Rt=de(Be.residuals);if(!(Rt>0))break;const Ft=Be.residuals.map(qt=>{const Zt=Math.abs(qt/Rt);return Zt<=te?1:te/Zt}),Ut=ee(Re,Oe,Ft);if(!Ut)return null;const Qt=Ut.beta.reduce((qt,Zt,en)=>Math.max(qt,Math.abs(Zt-Be.beta[en])),0);if(Be=Ut,We=Ft,Qt<1e-10)break}}else if(Be=ee(Re,Oe,Ce),!Be)return null;const ft=Ne==="robust"?We:Ce,{beta:at,cov:mt,fitted:ct,residuals:vt}=Be;let St=0,Le=0,rt=0;for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1;St+=Rt*vt[jt]**2,Le+=Rt,rt+=Rt*Oe[jt]}const et=rt/Le;let it=0;for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1;it+=Rt*(Oe[jt]-et)**2}const Et=he-Te,Nt=St/Et,dt=it===0?1:Math.max(0,Math.min(1,1-St/it)),Ot=1-(1-dt)*(he-1)/Et,Vt=Array.isArray(we.names)&&we.names.length===ve?we.names:me[0].map((jt,Rt)=>`x${Rt+1}`),Wt=Tt(we.confidence),sn=Et>0?W(1-(1-Wt)/2,Et):1/0,an=at.map((jt,Rt)=>{const Ft=Math.sqrt(Math.max(0,Nt*mt[Rt][Rt])),Ut=Ft>0?jt/Ft:jt===0?0:1/0,Qt=Number.isFinite(Ut)?2*(1-_(Math.abs(Ut),Et)):0,qt=Number.isFinite(sn)?sn*Ft:null;return{name:Rt===0?"(intercept)":Vt[Rt-1],estimate:jt,stdError:Ft,t:Ut,p:Math.max(0,Math.min(1,Qt)),lower:qt===null?null:jt-qt,upper:qt===null?null:jt+qt}}),ln=new Array(he),zt=new Array(he);for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1,Ft=Math.max(0,Math.min(1,Rt*o(Re[jt],mt)));ln[jt]=Ft;const Ut=(1-Ft)**2;zt[jt]=Ut>0&&Nt>0?vt[jt]**2/(Te*Nt)*(Ft/Ut):null}const un=me[0].map((jt,Rt)=>{if(ve<2)return 1;const Ft=se(me,Rt);return Ft>=1?1/0:1/(1-Ft)});let cn=null;{const jt=vt.map(Ft=>Ft*Ft),Rt=ee(Re,jt,null);if(Rt){const Ft=jt.reduce((Xt,dn)=>Xt+dn,0)/he;let Ut=0,Qt=0;for(let Xt=0;Xt<he;Xt++)Ut+=Rt.residuals[Xt]**2,Qt+=(jt[Xt]-Ft)**2;const qt=Qt===0?0:Math.max(0,Math.min(1,1-Ut/Qt)),Zt=he*qt,en=G(Zt,ve);cn={statistic:Zt,df:ve,p:en,heteroscedastic:en<.05}}}let rn=null;if(ve===1){const jt=me.map((Rt,Ft)=>Ft).sort((Rt,Ft)=>me[Rt][0]-me[Ft][0]);rn={confidence:Wt,points:jt.map(Rt=>{const Ft=Re[Rt],Ut=Math.sqrt(Math.max(0,Nt*o(Ft,mt)));return{x:me[Rt][0],yhat:ct[Rt],lower:ct[Rt]-sn*Ut,upper:ct[Rt]+sn*Ut}})}}return{method:Ne,coefficients:an,r2:dt,adjR2:Ot,n:he,df:Et,sigma2:Nt,fitted:ct,residuals:vt,leverage:ln,cooksD:zt,vif:un,heteroscedasticity:cn,band:rn,weights:ft?[...ft]:null}}function ue(me){const Oe=me.length,we=Array.from({length:Oe},(ve,Te)=>Te).sort((ve,Te)=>me[ve]-me[Te]),Ne=new Float64Array(Oe);let he=0;for(;he<Oe;){let ve=he;for(;ve+1<Oe&&me[we[ve+1]]===me[we[he]];)ve++;const Te=(he+ve)/2+1;for(let Ce=he;Ce<=ve;Ce++)Ne[we[Ce]]=Te;he=ve+1}return Ne}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(me){const Oe=[.01,.05,.1],we=[ce["1%"],ce["5%"],ce["10%"]];if(me<=we[0]){const ve=(Math.log(Oe[1])-Math.log(Oe[0]))/(we[1]-we[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Oe[0])+ve*(me-we[0]))))}if(me>=we[2]){const ve=(Math.log(Oe[2])-Math.log(Oe[1]))/(we[2]-we[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Oe[2])+ve*(me-we[2]))))}const Ne=me<we[1]?0:1,he=(me-we[Ne])/(we[Ne+1]-we[Ne]);return Math.exp(Math.log(Oe[Ne])+he*(Math.log(Oe[Ne+1])-Math.log(Oe[Ne])))}function Me(me,Oe,we,Ne){const he=we-Ne,ve=Ne+3,Te=new Array(he),Ce=new Array(he);let Re=!0,Be=Ne;for(let ct=0;ct<he;ct++){const vt=Ne+ct,St=new Float64Array(ve);St[0]=1,St[1]=ct+1,St[2]=me[vt];for(let Le=1;Le<=Ne;Le++)St[2+Le]=Oe[vt-Le];for(let Le=1;Le<ve;Le++)Number.isFinite(St[Le])||(Be=Math.min(Be,Le-3));Te[ct]=St,Ce[ct]=Oe[vt],Number.isFinite(Ce[ct])||(Re=!1)}if(!Re)return 0;const{xtwx:We,xtwy:ft}=c(Te,Ce,null);let at=0,mt=1/0;for(let ct=0;ct<=Be;ct++){const vt=ct+3;if(!(he>vt))continue;const St=new Array(vt);for(let dt=0;dt<vt;dt++)St[dt]=We[dt].slice(0,vt);const Le=v(St);if(!Le)continue;const rt=k(Le,ft.slice(0,vt));let et=0;for(let dt=0;dt<he;dt++){const Ot=Te[dt];let Vt=0;for(let Wt=0;Wt<vt;Wt++)Vt+=Ot[Wt]*rt[Wt];et+=(Ce[dt]-Vt)**2}const Et=et/(he-vt)*(he-vt);if(!(Et>0))continue;const Nt=he*Math.log(Et/he)+2*vt;Nt<mt&&(mt=Nt,at=ct)}return at}function $e(me,Oe={}){const we=[];for(let mt=0;mt<me.length;mt++){const ct=Number(me[mt]);Number.isFinite(ct)&&we.push(ct)}const Ne=we.length,he=Ne-1;if(Ne<8||he<6)return null;const ve=new Array(he);for(let mt=0;mt<he;mt++)ve[mt]=we[mt+1]-we[mt];let Te=Number.isFinite(Oe.maxlag)?Math.floor(Oe.maxlag):Math.ceil(12*(Ne/100)**.25);Te=Math.max(0,Math.min(Te,Math.floor((he-5)/2)));const Ce=(mt,ct)=>{const vt=[],St=[];for(let Le=ct;Le<he;Le++){const rt=[Le-ct+1,we[Le]];for(let et=1;et<=mt;et++)rt.push(ve[Le-et]);vt.push(rt),St.push(ve[Le])}return oe(vt,St,{method:"ols"})},Re=Me(we,ve,he,Te),Be=Ce(Re,Re);if(!Be||!Be.coefficients[2])return null;const We=Be.coefficients[2].t,ft=pe(We),at=We<ce["5%"];return{statistic:We,usedLag:Re,nobs:he-Re,criticalValues:{...ce},pValue:ft,pApproximate:!0,stationary:at,verdict:at?"stationary":"non-stationary",regression:"ct"}}function Ae(me,Oe={}){const we=[];for(let at=0;at<me.length;at++){const mt=Number(me[at]);Number.isFinite(mt)&&we.push(mt)}const Ne=we.length;if(Ne<3)return null;let he=Number.isFinite(Oe.maxlag)?Math.floor(Oe.maxlag):Math.min(10,Ne-1);he=Math.max(1,Math.min(he,Ne-1));let ve=0;for(const at of we)ve+=at;ve/=Ne;const Te=we.map(at=>at-ve);let Ce=0;for(const at of Te)Ce+=at*at;Ce/=Ne;const Re=new Array(he+1).fill(0);Re[0]=1;for(let at=1;at<=he;at++){let mt=0;for(let ct=at;ct<Ne;ct++)mt+=Te[ct]*Te[ct-at];Re[at]=Ce>0?mt/Ne/Ce:0}const Be=new Array(he+1).fill(0);Be[0]=1;let We=[];for(let at=1;at<=he;at++){let mt=Re[at];for(let Le=1;Le<at;Le++)mt-=We[Le-1]*Re[at-Le];let ct=1;for(let Le=1;Le<at;Le++)ct-=We[Le-1]*Re[Le];const vt=ct!==0?mt/ct:0,St=new Array(at);for(let Le=1;Le<at;Le++)St[Le-1]=We[Le-1]-vt*We[at-1-Le];St[at-1]=vt,Be[at]=vt,We=St}const ft=1.96/Math.sqrt(Ne);return{acf:Re,pacf:Be,bounds:{upper:ft,lower:-ft},n:Ne,nlags:he,approximate:!0}}function ke(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2)return null;const Te=ue(Ne),Ce=ue(he);let Re=0,Be=0;for(let mt=0;mt<ve;mt++)Re+=Te[mt],Be+=Ce[mt];Re/=ve,Be/=ve;let We=0,ft=0,at=0;for(let mt=0;mt<ve;mt++){const ct=Te[mt]-Re,vt=Ce[mt]-Be;We+=ct*vt,ft+=ct*ct,at+=vt*vt}return ft===0||at===0?null:Math.max(-1,Math.min(1,We/Math.sqrt(ft*at)))}function ge(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2||ve>i)return null;let Te=0,Ce=0,Re=0,Be=0;for(let at=0;at<ve;at++)for(let mt=at+1;mt<ve;mt++){const ct=Math.sign(Ne[at]-Ne[mt]),vt=Math.sign(he[at]-he[mt]),St=ct*vt;St>0?Te++:St<0?Ce++:ct===0&&vt===0||(ct===0?Re++:Be++)}const We=Te+Ce+Be,ft=Te+Ce+Re;return We===0||ft===0?null:(Te-Ce)/Math.sqrt(We*ft)}function Ee(me,Oe={}){const we=me.length;if(we<2)return null;const Ne=me[0],he=me[we-1],ve=[];for(let Le=1;Le<we;Le++){const rt=me[Le-1];rt!==0&&ve.push((me[Le]-rt)/Math.abs(rt))}let Te=null;if(ve.length>1){let Le=0;for(const et of ve)Le+=et;Le/=ve.length;let rt=0;for(const et of ve)rt+=(et-Le)**2;Te=Math.sqrt(rt/(ve.length-1))}const Ce=Number(Oe.periodsPerYear)>0?Number(Oe.periodsPerYear):null;let Re=me[0],Be=0,We=0,ft=0,at=0;for(let Le=1;Le<we;Le++){if(me[Le]>Re){Re=me[Le],Be=Le;continue}if(Re<=0)continue;const rt=(Re-me[Le])/Re;rt>We&&(We=rt,ft=Be,at=Le)}let mt=null;if(we>2){let Le=0;for(let it=0;it<we;it++)Le+=me[it];Le/=we;let rt=0,et=0;for(let it=0;it<we;it++){const Et=me[it]-Le;et+=Et*Et,it>0&&(rt+=Et*(me[it-1]-Le))}mt=et>0?rt/et:null}let ct=0,vt=0;for(const Le of ve)Le>0?ct++:Le<0&&vt++;let St=null;if(Ne>0&&he>0){const Le=(he/Ne)**(1/(we-1))-1;St=Ce?(1+Le)**Ce-1:Le}return{n:we,first:Ne,last:he,change:he-Ne,changePercent:Ne===0?null:(he-Ne)/Math.abs(Ne)*100,volatility:Te,annualisedVolatility:Te!==null&&Ce?Te*Math.sqrt(Ce):null,growth:St,maxDrawdown:We,maxDrawdownFrom:ft,maxDrawdownTo:at,autocorrelation:mt,upDays:ct,downDays:vt}}const De=1.128,ze=3.267;function qe(me){const Oe=me.length;if(Oe<2)return null;const we=[];for(let he=1;he<Oe;he++)we.push(Math.abs(me[he]-me[he-1]));const Ne=we.reduce((he,ve)=>he+ve,0)/we.length;return{ranges:we,centre:Ne,upper:ze*Ne,lower:0}}function Xe(me){const Oe=me.length;if(Oe<2)return null;let we=0;for(let he=1;he<Oe;he++)we+=Math.abs(me[he]-me[he-1]);const Ne=we/(Oe-1);return{sigma:Ne/De,meanRange:Ne}}function nt(me,Oe){const we=me.length;if(we<2||!Oe)return null;const Ne=Number.isFinite(Number(Oe.lower))?Number(Oe.lower):null,he=Number.isFinite(Number(Oe.upper))?Number(Oe.upper):null;if(Ne===null&&he===null)return null;let ve=0;for(let ct=0;ct<we;ct++)ve+=me[ct];ve/=we;let Te=0;for(let ct=0;ct<we;ct++)Te+=(me[ct]-ve)**2;const Ce=Math.sqrt(Te/(we-1)),Re=Xe(me),Be=Re?Re.sigma:null,We=ct=>{if(!ct||ct<=0)return{index:null,k:null};const St=Ne!==null&&he!==null?(he-Ne)/(6*ct):null,Le=he!==null?(he-ve)/(3*ct):1/0,rt=Ne!==null?(ve-Ne)/(3*ct):1/0;return{index:St,k:Math.min(Le,rt)}},ft=We(Be),at=We(Ce);let mt=0;for(let ct=0;ct<we;ct++){if(Ne!==null&&me[ct]<Ne){mt++;continue}he!==null&&me[ct]>he&&mt++}return{n:we,mean:ve,lower:Ne,upper:he,target:Number.isFinite(Number(Oe.target))?Number(Oe.target):null,sigmaWithin:Be,sigmaOverall:Ce,cp:ft.index,cpk:ft.k,pp:at.index,ppk:at.k,outOfSpec:mt,defectRate:we?mt/we:null}}function Pe(me){const Oe=me.length;if(Oe<2)return null;const we=Xe(me);if(!we||!(we.sigma>0))return null;let Ne=0;for(let he=0;he<Oe;he++)Ne+=me[he];return Ne/=Oe,{centre:Ne,sigma:we.sigma,upper:Ne+3*we.sigma,lower:Ne-3*we.sigma}}function Ge(me,Oe){if(!Oe||!(Oe.sigma>0))return[];const we=me.length,{centre:Ne,sigma:he}=Oe,ve=Ce=>(me[Ce]-Ne)/he,Te=[];for(let Ce=0;Ce<we;Ce++){if(Math.abs(ve(Ce))>3&&Te.push({index:Ce,rule:1,description:"beyond three sigma"}),Ce>=2)for(const Re of[1,-1]){let Be=0;for(let We=Ce-2;We<=Ce;We++)ve(We)*Re>2&&Be++;if(Be>=2){Te.push({index:Ce,rule:2,description:"two of three past two sigma"});break}}if(Ce>=4)for(const Re of[1,-1]){let Be=0;for(let We=Ce-4;We<=Ce;We++)ve(We)*Re>1&&Be++;if(Be>=4){Te.push({index:Ce,rule:3,description:"four of five past one sigma"});break}}if(Ce>=7)for(const Re of[1,-1]){let Be=!0;for(let We=Ce-7;We<=Ce;We++)if(ve(We)*Re<=0){Be=!1;break}if(Be){Te.push({index:Ce,rule:4,description:"eight in a row on one side"});break}}}return Te}function He(me,Oe){if(!Oe||!(Oe.sigma>0))return[];const we=me.length,{centre:Ne,sigma:he}=Oe,ve=Re=>(me[Re]-Ne)/he,Te=(Re,Be,We,ft)=>{for(const at of[1,-1]){let mt=0;for(let ct=Re;ct<=Be;ct++)ve(ct)*at>We&&mt++;if(mt>=ft)return!0}return!1},Ce=[];for(let Re=0;Re<we;Re++){if(Math.abs(ve(Re))>3&&Ce.push({index:Re,rule:1,description:"beyond three sigma"}),Re>=8)for(const Be of[1,-1]){let We=!0;for(let ft=Re-8;ft<=Re;ft++)if(ve(ft)*Be<=0){We=!1;break}if(We){Ce.push({index:Re,rule:2,description:"nine in a row on one side"});break}}if(Re>=5)for(const Be of[1,-1]){let We=!0;for(let ft=Re-4;ft<=Re;ft++)if((me[ft]-me[ft-1])*Be<=0){We=!1;break}if(We){Ce.push({index:Re,rule:3,description:Be>0?"six rising":"six falling"});break}}if(Re>=13){let Be=!0;for(let We=Re-12;We<=Re;We++){const ft=me[We]-me[We-1],at=me[We+1<=Re?We+1:We]-me[We];if(We+1>Re)break;if(ft===0||at===0||ft>0==at>0){Be=!1;break}}Be&&Ce.push({index:Re,rule:4,description:"fourteen alternating"})}if(Re>=2&&Te(Re-2,Re,2,2)&&Ce.push({index:Re,rule:5,description:"two of three past two sigma"}),Re>=4&&Te(Re-4,Re,1,4)&&Ce.push({index:Re,rule:6,description:"four of five past one sigma"}),Re>=14){let Be=!0;for(let We=Re-14;We<=Re;We++)if(Math.abs(ve(We))>=1){Be=!1;break}Be&&Ce.push({index:Re,rule:7,description:"fifteen within one sigma"})}if(Re>=7){let Be=!0;for(let We=Re-7;We<=Re;We++)if(Math.abs(ve(We))<=1){Be=!1;break}Be&&Ce.push({index:Re,rule:8,description:"eight beyond one sigma"})}}return Ce}const Ye=Object.freeze(["westernElectric","nelson"]);function st(me,Oe,we="westernElectric"){return String(we)==="nelson"?He(me,Oe):Ge(me,Oe)}function ht(me,Oe,we){let Ne=0;for(let he=0;he<me.length;he++)(me[he]<Oe||me[he]>we)&&Ne++;return Ne}function bt(me,Oe,we,Ne=20){const he=me.length;if(!he)return[];const ve=me[0],Te=me[he-1];if(Te===ve)return[{from:ve,to:Te,count:he}];const Ce=we-Oe,Re=1.5*Ce;let Be=Ce>0?Math.max(ve,Oe-Re):ve,We=Ce>0?Math.min(Te,we+Re):Te;We>Be||(Be=ve,We=Te);const ft=Ce>0?2*Ce/Math.cbrt(he):(We-Be)/(Math.ceil(Math.log2(he))+1),at=ft>0?Math.min(Ne,Math.max(1,Math.ceil((We-Be)/ft))):1,mt=(We-Be)/at,ct=[];for(let vt=0;vt<at;vt++)ct.push({from:Be+vt*mt,to:Be+(vt+1)*mt,count:0});for(let vt=0;vt<he;vt++){const St=Math.min(at-1,Math.max(0,Math.floor((me[vt]-Be)/mt)));ct[St].count++}return ct[0].from=ve,ct[at-1].to=Te,ct}const At=.95;function Tt(me){const Oe=Number(me);return Number.isFinite(Oe)&&Oe>0&&Oe<1?Oe:At}function Dt(me,Oe=At){const we=me.length;if(we<2)return null;let Ne=0;for(let We=0;We<we;We++)Ne+=me[We];const he=Ne/we;let ve=0;for(let We=0;We<we;We++){const ft=me[We]-he;ve+=ft*ft}const Te=Math.sqrt(ve/(we-1)),Ce=Tt(Oe),Be=W(1-(1-Ce)/2,we-1)*Te/Math.sqrt(we);return{mean:he,lower:he-Be,upper:he+Be,margin:Be,n:we,confidence:Ce}}function It(me,Oe,we=At){const Ne=Number(me),he=Number(Oe);if(!(he>0)||!(Ne>=0)||Ne>he)return null;const ve=Tt(we),Te=H(1-(1-ve)/2),Ce=Ne/he,Re=Te*Te,Be=1+Re/he,We=(Ce+Re/(2*he))/Be,ft=Te/Be*Math.sqrt(Ce*(1-Ce)/he+Re/(4*he*he));return{proportion:Ce,lower:Math.max(0,We-ft),upper:Math.min(1,We+ft),n:he,confidence:ve}}function Gt(me,Oe=At){if(!me||!(me.n>2)||!Number.isFinite(me.stdError))return null;const we=Tt(Oe),he=W(1-(1-we)/2,me.n-2)*me.stdError;return{slope:me.slope,lower:me.slope-he,upper:me.slope+he,margin:he,confidence:we}}function Yt(me,Oe,we=At){const Ne=Number(me),he=Number(Oe);if(!Number.isFinite(Ne)||!(he>1))return null;const ve=Tt(we),Ce=H(1-(1-ve)/2)*Math.sqrt(1/(9*he)+Ne*Ne/(2*(he-1)));return{index:Ne,lower:Ne-Ce,upper:Ne+Ce,margin:Ce,n:he,confidence:ve}}function wt(me,Oe){return!me||!(me.sd>0)||!Number.isFinite(Oe)||!Number.isFinite(me.mean)?null:(Oe-me.mean)/me.sd}function fe(me){return Number.isFinite(me)?Math.min(1,Math.max(0,2*B(Math.abs(me)/2)-1)):0}function be(me,Oe){const we=new Map,Ne=I(me);let he=0;for(let ve=0;ve<Oe.length;ve++){const Te=Ne(Oe[ve]);if(Te==null||Te===""||typeof Te=="number"&&Number.isNaN(Te))continue;const Ce=Te instanceof Date?Te.getTime():typeof Te=="object"?String(Te):Te;we.set(Ce,(we.get(Ce)||0)+1),he++}return{map:we,total:he}}function xe(me,Oe,we,Ne){if(!(Oe>0)||!(Ne>0))return null;let he=0;const ve=new Set(me.keys());for(const Te of we.keys())ve.add(Te);for(const Te of ve){const Ce=(me.get(Te)||0)/Oe,Re=(we.get(Te)||0)/Ne;he+=Math.abs(Ce-Re)}return he/2}const Ke=10;function _e(me,Oe,we){if(we&&we.numeric){const Ce=u(me,Oe),{n:Re,mean:Be}=S(Ce),We=Re>0?wt({mean:we.mean,sd:we.sd},Be):null;return{measure:"standardizedMeanDifference",magnitude:We,distance:We===null?0:fe(We),direction:We===null?0:Math.sign(We),subsetN:Re,populationN:we.n||0,reliable:Re>=Ke}}const{map:he,total:ve}=be(me,Oe),Te=xe(he,ve,we.map,we.total);return{measure:"categoricalTotalVariation",magnitude:Te,distance:Te===null?0:Te,direction:0,subsetN:ve,populationN:we.total||0,reliable:ve>=Ke}}function ut(me,Oe){if(me&&(me.kind==="float64"||me.kind==="int32"))return!0;const we=I(me);let Ne=0,he=0;for(let ve=0;ve<Oe.length&&Ne<200;ve++){const Te=we(Oe[ve]);if(Te==null||Te==="")continue;if(Te instanceof Date)return!1;Ne++;const Ce=typeof Te=="number"?Te:Number(Te);Number.isFinite(Ce)&&he++}return Ne===0?!1:he/Ne>=.9}function gt(me,Oe){if(ut(me,Oe)){const he=u(me,Oe),{n:ve,mean:Te,m2:Ce}=S(he);return{numeric:!0,mean:Te,sd:ve>0?Math.sqrt(Ce/ve):0,n:ve}}const{map:we,total:Ne}=be(me,Oe);return{numeric:!1,map:we,total:Ne}}}),je("packages/core/src/compute/total.js",function(e,V){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N=V("packages/core/src/compute/handle.js"),W=N.presenceReader,_=N.valueComparator,H=N.valueReader,B=V("packages/core/src/compute/statistics.js"),G=B.STAT_FNS,D=B.STAT_LABELS;function v(S){return!!S&&(S.kind==="float64"||S.kind==="int32")}function k(S,h){const d=h.length;let j=0;if(v(S)){const O=S.values,T=W(S);if(!T){for(let A=0;A<d;A++){const P=O[h[A]];Number.isNaN(P)||(j+=P)}return j}for(let A=0;A<d;A++){const P=h[A];if(T(P)===1){const L=O[P];Number.isNaN(L)||(j+=L)}}return j}const E=H(S);for(let O=0;O<d;O++){const T=s(E(h[O]));T!==null&&(j+=T)}return j}k.kernel=!0;function y(S,h){const d=h.length;let j=0;if(v(S)){const O=S.values,T=W(S);if(!T){for(let A=0;A<d;A++)Number.isNaN(O[h[A]])||j++;return j}for(let A=0;A<d;A++){const P=h[A];T(P)===1&&!Number.isNaN(O[P])&&j++}return j}const E=H(S);for(let O=0;O<d;O++){const T=E(h[O]);T!=null&&!(typeof T=="number"&&Number.isNaN(T))&&j++}return j}y.kernel=!0;function c(S,h){return h.length}c.kernel=!0;function o(S,h){const d=y(S,h);return d===0?null:k(S,h)/d}o.kernel=!0;function n(S,h,d,j){const E=h.length;if(v(S)){const P=S.values,L=W(S);let $=null;if(!L){for(let U=0;U<E;U++){const x=P[h[U]];Number.isNaN(x)||($===null||(d<0?x<$:x>$))&&($=x)}return $}for(let U=0;U<E;U++){const x=h[U];if(L(x)===0)continue;const F=P[x];Number.isNaN(F)||($===null||(d<0?F<$:F>$))&&($=F)}return $}const O=H(S),T=_(j);let A=null;for(let P=0;P<E;P++){const L=O(h[P]);L==null||typeof L=="number"&&Number.isNaN(L)||(A===null||(d<0?T(L,A)<0:T(L,A)>0))&&(A=L)}return A}function t(S,h,d){return n(S,h,-1,d&&d.locale)}t.kernel=!0;function i(S,h,d){return n(S,h,1,d&&d.locale)}i.kernel=!0;function a(S,h){return h.length===0?null:H(S)(h[0])}a.kernel=!0;function r(S,h){return h.length===0?null:H(S)(h[h.length-1])}r.kernel=!0;function s(S){if(typeof S=="number")return Number.isNaN(S)?null:S;if(S==null||S===""||typeof S=="boolean")return null;if(S instanceof Date)return S.getTime();const h=Number(S);return Number.isNaN(h)?null:h}const u={sum:k,min:t,max:i,avg:o,count:c,first:a,last:r,countValues:y,...G},l=Object.freeze({...D,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function p(S){return S?typeof S=="string"?l[S]||S:"Total":""}const m=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function b(S){const h=S&&S.dataType&&S.dataType.totals&&S.dataType.totals.supported;if(Array.isArray(h))return h.slice();const d=m.filter(j=>j in u);for(const j of Object.keys(u))d.includes(j)||d.push(j);return d}function g(S,h){return typeof h!="string"?!0:b(S).includes(h)}function f(S,h){const d=H(S),j=[];for(let E=0;E<h.length;E++){const O=d(h[E]);O!=null&&j.push(O)}return j}function w(S,h,d,j){const E=h||[];if(typeof d=="string"){const O=u[d];return O?O(S,E,j):(I(`total:${d}`,`unknown total function "${d}"; register it in config.totalFns`),null)}return M(d)?d.kernel===!0?d(S,E,j):d(f(S,E),j||{}):null}}),je("packages/core/src/compute/windowed.js",function(e,V){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/compute/sketch.js").Welford;class I{#e;#t;#n=[];#r;#o;constructor(B,G=0,D=Date.now){if(B!=="count"&&B!=="time"&&B!=="session")throw new RangeError(`unknown window kind: ${B}`);if((B==="count"||B==="time")&&!(G>0))throw new RangeError(`a ${B} window needs a positive span`);this.#e=B,this.#t=Math.floor(G),this.#r=D,this.#o=D()}get size(){return this.#n.length}push(B,G=this.#r()){Number.isFinite(B)&&(this.#n.push({t:G,v:B}),this.#i(G))}#i(B){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const G=B-this.#t;for(;this.#n.length&&this.#n[0].t<G;)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 G=new M;let D=0,v=1/0,k=-1/0;for(const{v:y}of this.#n)D+=y,y<v&&(v=y),y>k&&(k=y),G.add(y);return{over:B,count:this.#n.length,sum:D,mean:G.mean(),min:v,max:k,variance:G.variance(),stddev:G.stddev()}}reduce(B){const G=this.aggregate(),D={sum:G.sum,avg:G.mean,mean:G.mean,min:G.min,max:G.max,count:G.count,variance:G.variance,stddev:G.stddev};if(!(B in D))throw new RangeError(`unknown windowed aggregate: ${B}`);return{value:D[B],over:G.over}}}const N=Object.freeze(["count","time","session"]);function W(H,B=Date.now){const G=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new I(H.kind,G,B)}const _={Window:I,WINDOW_KINDS:N,openWindow:W}}),je("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 H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return D}}),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 s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const M=V("packages/core/src/compute/windowed.js").openWindow,N=V("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function _(l,p,m,b){if(l.kind==="count"){const g=Math.max(1,Math.floor(l.span||0));return{coverage:Math.min(1,p/g),partial:p<g}}if(l.kind==="time"){const g=l.minutes!=null?l.minutes*6e4:l.span||0;if(!(g>0))return{coverage:1,partial:!1};const f=m-b;return{coverage:Math.min(1,f/g),partial:f<g}}return{coverage:null,partial:!1}}function H(l,p){const m=M(p),b=new Map,g=l.length?l[0].at:0;for(let f=0;f<l.length;f++){const{key:w,at:S,value:h}=l[f];Number.isFinite(h)&&m.push(h,S);const d=m.aggregate(),j=_(p,d.count,S,g);w!=null&&b.set(String(w),{sum:d.sum,avg:d.mean,min:d.min,max:d.max,count:d.count,coverage:j.coverage,partial:j.partial})}return b}function B(l){const p=new Map;let m=0;for(const{key:b,value:g}of l)Number.isFinite(g)&&(m+=g),b!=null&&p.set(String(b),m);return p}function G(l,p=1){const m=new Map,b=Math.max(1,Math.floor(p));for(let g=0;g<l.length;g++){const{key:f,value:w}=l[g];if(f==null)continue;const S=g>=b?l[g-b].value:null,h=Number.isFinite(w)?w:null,d=Number.isFinite(S)?S:null;m.set(String(f),h!==null&&d!==null?h-d:null)}return m}const D=4096;function v(l){let p=l>>>0;return()=>{p+=1831565813;let m=p;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296}}function k(l,p){const m=l.length;if(m===1)return l[0];const b=(m-1)*p,g=Math.floor(b),f=Math.ceil(b);return g===f?l[g]:l[g]+(b-g)*(l[f]-l[g])}function y(l,p,m={}){const b=Math.min(1,Math.max(0,m.q==null?.5:m.q)),g=Math.max(1,Math.floor(m.cap==null?D:m.cap)),f=v(m.seed==null?2654435769:m.seed),w=new Map,S=l.length?l[0].at:0;if(p.kind==="session"){const d=new N(200,f);let j=0;for(const{key:E,value:O}of l)Number.isFinite(O)&&(d.add(O),j++),E!=null&&w.set(String(E),{value:j?d.quantile(b):null,approx:j>0,count:j,coverage:null,partial:!1});return w}const h=M(p);for(const{key:d,at:j,value:E}of l){Number.isFinite(E)&&h.push(E,j);const O=h.values(),T=O.length;let A=null,P=!1;if(T)if(T<=g)A=k([...O].sort(($,U)=>$-U),b);else{const $=new N(200,f);for(const U of O)$.add(U);A=$.quantile(b),P=!0}const L=_(p,T,j,S);d!=null&&w.set(String(d),{value:A,approx:P,count:T,coverage:L.coverage,partial:L.partial})}return w}function c(l,p){const m=l.length,b=new Array(m).fill(null),g=Math.floor(p/2),f=p%2===0;for(let w=0;w<m;w++){if(w-g<0||w+g>=m)continue;let S=0,h=!0;if(f)for(let d=-g;d<=g;d++){const j=l[w+d];if(!Number.isFinite(j)){h=!1;break}S+=d===-g||d===g?j*.5:j}else for(let d=-g;d<=g;d++){const j=l[w+d];if(!Number.isFinite(j)){h=!1;break}S+=j}h&&(b[w]=S/p)}return b}function o(l,p){const m=new Map,b=Math.floor(Number(p&&p.period));if(!(b>=2))return m;const g=p&&p.model==="multiplicative",f=l.length,w=l.map(P=>Number.isFinite(P.value)?P.value:null),S=c(w,b),h=new Array(f).fill(null);for(let P=0;P<f;P++){const L=S[P],$=w[P];L===null||$===null||(g?L!==0&&(h[P]=$/L):h[P]=$-L)}const d=new Array(b).fill(0),j=new Array(b).fill(0);for(let P=0;P<f;P++){if(h[P]===null)continue;const L=P%b;d[L]+=h[P],j[L]+=1}const E=g?1:0,O=d.map((P,L)=>j[L]?P/j[L]:E),T=O.reduce((P,L)=>P+L,0)/b,A=g?O.map(P=>T!==0?P/T:1):O.map(P=>P-T);for(let P=0;P<f;P++){const{key:L}=l[P];if(L==null)continue;const $=S[P],U=A[P%b],x=w[P];let F=null;$!==null&&x!==null&&(F=g?$*U!==0?x/($*U):null:x-$-U),m.set(String(L),{trend:$,seasonal:x===null?null:U,residual:F,coverage:$===null?0:1,partial:$===null})}return m}function n(l,p,m,b=80){const g=(Math.sqrt(5)-1)/2;let f=p,w=m,S=w-g*(w-f),h=f+g*(w-f),d=l(S),j=l(h);for(let E=0;E<b;E++)d<j?(w=h,h=S,j=d,S=w-g*(w-f),d=l(S)):(f=S,S=h,d=j,h=f+g*(w-f),j=l(h));return(f+w)/2}const t=1e-4,i=1-1e-4;function a(l,p){const m=l.length,b=new Array(m).fill(null),g=new Array(m).fill(null);let f=null,w=0;for(let S=0;S<m;S++){const h=l[S];if(!Number.isFinite(h)){f!==null&&(g[S]=f,b[S]=f);continue}if(f===null){f=h,g[S]=h,b[S]=h;continue}g[S]=f,w+=(h-f)**2,f=p*h+(1-p)*f,b[S]=f}return{smoothed:b,fitted:g,sse:w}}function r(l,p,m){const b=l.length,g=new Array(b).fill(null),f=new Array(b).fill(null);let w=null,S=null,h=0;for(let d=0;d<b;d++){const j=l[d];if(!Number.isFinite(j)){w!==null&&(w+=S,g[d]=w);continue}if(w===null){w=j,g[d]=j;continue}if(S===null){S=j-w;const T=w+S;f[d]=T,h+=(j-T)**2;const A=w;w=p*j+(1-p)*(A+S),S=m*(w-A)+(1-m)*S,g[d]=w;continue}const E=w+S;f[d]=E,h+=(j-E)**2;const O=w;w=p*j+(1-p)*(O+S),S=m*(w-O)+(1-m)*S,g[d]=w}return{smoothed:g,fitted:f,sse:h}}function s(l,p={}){const m=new Map,b=p.method==="holt",g=l.map(E=>Number.isFinite(E.value)?E.value:null),f=g.filter(E=>E!==null).length,w=E=>Math.min(i,Math.max(t,E)),S=()=>{for(const{key:E}of l)E!=null&&m.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return m};if(f<(b?2:1))return S();let h=Number.isFinite(p.alpha)?w(p.alpha):null,d=b&&Number.isFinite(p.beta)?w(p.beta):null;if(b){if(h===null||d===null){let E=h===null?.5:h,O=d===null?.5:d;for(let T=0;T<6;T++)h===null&&(E=n(A=>r(g,A,O).sse,t,i)),d===null&&(O=n(A=>r(g,E,A).sse,t,i));h=h===null?E:h,d=d===null?O:d}}else h===null&&(h=n(E=>a(g,E).sse,t,i));const j=b?r(g,h,d):a(g,h);for(let E=0;E<l.length;E++){const{key:O}=l[E];O!=null&&m.set(String(O),{smoothed:j.smoothed[E],fitted:j.fitted[E],alpha:h,beta:b?d:null,sse:j.sse})}return m}const u={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:D,rollingWindow:H,rollingQuantile:y,cumulativeToDate:B,periodOverPeriod:G,seasonalDecompose:o,exponentialSmoothing:s}}),je("packages/core/src/compute/compare.js",function(e,V){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/compute/statistics.js"),M=Z.numbers,I=Z.moments,N=Z.frequencyMap,W=Z.categoricalDistance,_=Z.normalTotalVariation,H=Z.isNumericColumn,B=Z.SUBSET_RELIABILITY_FLOOR,G=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function D(o,n){if(!o||!n||!(o.n>0)||!(n.n>0)||!Number.isFinite(o.mean)||!Number.isFinite(n.mean))return null;const t=(o.n*o.sd*o.sd+n.n*n.sd*n.sd)/(o.n+n.n);return t>0?(o.mean-n.mean)/Math.sqrt(t):null}function v(o,n){const t=M(o,n),{n:i,mean:a,m2:r}=I(t),s=i>0?Math.sqrt(r/i):0;return{mean:a,sd:s,n:i}}function k(o,n,t,i){return H(o,n)&&H(t,i)}function y(o,n,t,i){if(k(o,n,t,i)){const u=v(o,n),l=v(t,i),p=D(u,l);return{measure:G.numeric,magnitude:p,distance:p===null?0:_(p),direction:p===null?0:Math.sign(p),nA:u.n,nB:l.n,reliable:u.n>=B&&l.n>=B}}const a=N(o,n),r=N(t,i),s=W(a.map,a.total,r.map,r.total);return{measure:G.categorical,magnitude:s,distance:s===null?0:s,direction:0,nA:a.total,nB:r.total,reliable:a.total>=B&&r.total>=B}}function c(o,n,t={}){const i=new Set(o.columns),a=new Set(n.columns),r=o.columns.filter(m=>a.has(m)),s=Array.isArray(t.columns)&&t.columns.length?r.filter(m=>t.columns.includes(m)):r,u=o.indices(),l=n.indices(),p=[];for(const m of s){const b=o.handle(m),g=n.handle(m);if(!b||!g)continue;const f=y(b,u,g,l);p.push({column:m,name:o.name&&o.name(m)||n.name&&n.name(m)||m,measure:f.measure,magnitude:f.magnitude,distance:f.distance,direction:f.direction,nA:f.nA,nB:f.nB,reliable:f.reliable})}return p.sort((m,b)=>b.distance-m.distance||Math.abs(b.magnitude||0)-Math.abs(m.magnitude||0)),{ranked:p,nA:u.length,nB:l.length,unmatched:{onlyA:o.columns.filter(m=>!a.has(m)),onlyB:n.columns.filter(m=>!i.has(m))},measures:G}}}),je("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 H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const M=V("packages/core/src/compute/statistics.js").quantileSorted,N=V("packages/core/src/compute/special.js").logGamma,W=.6745,_=3.5,H=1.5,B=.975,G=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function D(l){if(!l.length)return null;const m=Array.from(l,Number).sort((w,S)=>w-S),b=M(m,.5),g=m.map(w=>Math.abs(w-b)).sort((w,S)=>w-S),f=M(g,.5);return{median:b,mad:f}}function v(l,p={}){const m=Number.isFinite(p.threshold)?p.threshold:_,b=l.length,g=new Array(b).fill(null),f=new Array(b).fill(!1),w=[];for(let d=0;d<b;d++){const j=Number(l[d]);Number.isFinite(j)&&w.push(j)}if(!w.length)return{median:null,mad:null,threshold:m,scores:g,flags:f,flagged:0};const S=D(w);if(S.mad===0)return{median:S.median,mad:0,threshold:m,scores:g,flags:f,flagged:0};let h=0;for(let d=0;d<b;d++){const j=Number(l[d]);if(!Number.isFinite(j))continue;const E=W*(j-S.median)/S.mad;g[d]=E,Math.abs(E)>m&&(f[d]=!0,h++)}return{median:S.median,mad:S.mad,threshold:m,scores:g,flags:f,flagged:h}}function k(l,p={}){const m=Number.isFinite(p.k)?p.k:H,b=[];for(let h=0;h<l.length;h++){const d=Number(l[h]);Number.isFinite(d)&&b.push(d)}if(!b.length)return null;const g=b.sort((h,d)=>h-d),f=M(g,.25),w=M(g,.75),S=w-f;return{q1:f,q3:w,iqr:S,lower:f-m*S,upper:w+m*S,k:m}}function y(l,p){if(p<=0)return 0;const m=N(l);if(p<l+1){let d=l,j=1/l,E=j;for(let O=0;O<1e3&&(d+=1,E*=p/d,j+=E,!(Math.abs(E)<Math.abs(j)*1e-15));O++);return j*Math.exp(-p+l*Math.log(p)-m)}const b=1e-300;let g=p+1-l,f=1/b,w=1/g,S=w;for(let d=1;d<1e3;d++){const j=-d*(d-l);g+=2,w=j*w+g,Math.abs(w)<b&&(w=b),f=g+j/f,Math.abs(f)<b&&(f=b),w=1/w;const E=w*f;if(S*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-p+l*Math.log(p)-m)*S}function c(l,p){return l<=0?0:y(p/2,l/2)}function o(l,p=B){if(!(p>0)||!(p<1))return NaN;let m=0,b=Math.max(1,l);for(;c(b,l)<p;)b*=2;for(let g=0;g<200;g++){const f=(m+b)/2;if(c(f,l)<p?m=f:b=f,b-m<1e-10)break}return(m+b)/2}function n(l){const p=l.length,m=l.map((b,g)=>{const f=b.slice();for(let w=0;w<p;w++)f.push(g===w?1:0);return f});for(let b=0;b<p;b++){let g=b;for(let w=b+1;w<p;w++)Math.abs(m[w][b])>Math.abs(m[g][b])&&(g=w);if(Math.abs(m[g][b])<1e-12)return null;if(g!==b){const w=m[g];m[g]=m[b],m[b]=w}const f=m[b][b];for(let w=0;w<2*p;w++)m[b][w]/=f;for(let w=0;w<p;w++){if(w===b)continue;const S=m[w][b];if(S!==0)for(let h=0;h<2*p;h++)m[w][h]-=S*m[b][h]}}return m.map(b=>b.slice(p))}function t(l,p){const m=l.length,b=new Array(p).fill(0);for(const w of l)for(let S=0;S<p;S++)b[S]+=w[S];for(let w=0;w<p;w++)b[w]/=m;const g=Array.from({length:p},()=>new Array(p).fill(0));for(const w of l)for(let S=0;S<p;S++){const h=w[S]-b[S];for(let d=S;d<p;d++)g[S][d]+=h*(w[d]-b[d])}const f=m>1?m-1:1;for(let w=0;w<p;w++)for(let S=w;S<p;S++)g[w][S]/=f,g[S][w]=g[w][S];return{mean:b,cov:g}}function i(l,p={}){const m=Number.isFinite(p.p)?p.p:B,b=Number.isFinite(p.ridge)?p.ridge:1e-6,g=l.length;if(!g)return null;const f=l[0].length;if(!f)return null;const w=new Array(g).fill(null),S=new Array(g).fill(null),h=new Array(g).fill(!1),d=[],j=[];for(let U=0;U<g;U++){const x=l[U];let F=x.length===f;const C=new Array(f);for(let z=0;F&&z<f;z++){const q=Number(x[z]);Number.isFinite(q)?C[z]=q:F=!1}F&&(d.push(U),j.push(C))}const E=f,O=o(E,m);if(j.length<=f)return{center:[],df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:S,flags:h,flagged:0};const{mean:T,cov:A}=t(j,f);let P=n(A),L=!1;if(!P){L=!0;let U=0;for(let C=0;C<f;C++)U+=A[C][C];const x=U/f*b||b,F=A.map((C,z)=>C.map((q,Q)=>z===Q?q+x:q));if(P=n(F),!P)return{center:T,df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:S,flags:h,flagged:0}}let $=0;for(let U=0;U<j.length;U++){const x=j[U],F=new Array(f);for(let q=0;q<f;q++)F[q]=x[q]-T[q];let C=0;for(let q=0;q<f;q++){let Q=0;for(let Y=0;Y<f;Y++)Q+=P[q][Y]*F[Y];C+=F[q]*Q}C<0&&(C=0);const z=d[U];S[z]=C,w[z]=Math.sqrt(C),C>O&&(h[z]=!0,$++)}return{center:T,df:E,cutoff:O,singular:L,used:j.length,distances:w,squared:S,flags:h,flagged:$}}const a=20,r=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(l,p={}){const m=p.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",b=Number.isFinite(p.windowLen)&&p.windowLen>=1?Math.floor(p.windowLen):a,g=Number.isFinite(p.threshold)?p.threshold:_,f=Number.isFinite(p.k)?p.k:H,w=Number.isFinite(p.minPeriods)&&p.minPeriods>=1?Math.floor(p.minPeriods):b,S=l.length,h=new Array(S).fill(null),d=new Array(S).fill(!1);let j=0;for(let E=0;E<S;E++){const O=Number(l[E]);if(!Number.isFinite(O))continue;const T=Math.max(0,E-b+1),A=[];for(let P=T;P<=E;P++){const L=Number(l[P]);Number.isFinite(L)&&A.push(L)}if(!(A.length<w))if(m==="rollingIqr"){const P=k(A,{k:f});if(!P)continue;(O<P.lower||O>P.upper)&&(d[E]=!0,j++)}else{const P=D(A);if(!P||P.mad===0)continue;const L=W*(O-P.median)/P.mad;h[E]=L,Math.abs(L)>g&&(d[E]=!0,j++)}}return{method:m,windowLen:b,minPeriods:w,threshold:g,k:f,scores:h,flags:d,flagged:j}}function u(l={}){const p=l||{},m=p.field;if(typeof m!="string"||!m)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const b=p.method||"modifiedZScore";if(!(G.includes(b)||r.includes(b))||b==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${b}'`);const f=typeof p.orderBy=="string"?p.orderBy:null,w=p.latest===!0,S=r.includes(b),h=d=>Number(d==null?NaN:d[m]);return d=>{const j=Array.isArray(d)?d.slice():[...d];f&&j.sort((P,L)=>{const $=P?.[f],U=L?.[f];return $===U?0:$==null?-1:U==null?1:$<U?-1:1});const E=j.map(h);let O,T;if(S)({flags:O,scores:T}=s(E,{method:b,windowLen:p.windowLen,threshold:p.threshold,k:p.k,minPeriods:p.minPeriods}));else if(b==="iqr"){const P=k(E,{k:p.k});O=E.map(L=>P?Number.isFinite(L)&&(L<P.lower||L>P.upper):!1),T=E.map(()=>null)}else({flags:O,scores:T}=v(E,{threshold:p.threshold}));if(w){const P=O.length-1;return P<0||!O[P]?!1:{method:b,field:m,flagged:[{row:j[P],score:T[P]}]}}const A=[];for(let P=0;P<O.length;P++)O[P]&&A.push({row:j[P],score:T[P]});return A.length?{method:b,field:m,flagged:A}:!1}}}),je("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 l}});const Z=V("packages/core/src/compute/special.js"),M=Z.normalQuantile,I=Z.studentTQuantile,W=V("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,B=1-1e-4;function G(p){const m=[];for(let b=0;b<p.length;b++){const g=p[b];if(g!==null&&typeof g=="object"){const f=Number.isFinite(g.at)?g.at:b,w=Number.isFinite(g.value)?g.value:null;m.push({at:f,value:w})}else m.push({at:b,value:Number.isFinite(g)?Number(g):null})}return m}function D(p){const m=p.filter(S=>S.value!==null),b=m[0],g=m[m.length-1],f=g.at-b.at,w=m.length>1&&f>0?f/(m.length-1):1;return{lastAt:g.at,step:w}}function v(p){return Math.min(B,Math.max(H,p))}function k(p,m=H,b=B,g=80){const f=(Math.sqrt(5)-1)/2;let w=m,S=b,h=S-f*(S-w),d=w+f*(S-w),j=p(h),E=p(d);for(let O=0;O<g;O++)j<E?(S=d,d=h,E=j,h=S-f*(S-w),j=p(h)):(w=h,h=d,j=E,d=w+f*(S-w),E=p(d));return(w+S)/2}function y(p,m){let b=null,g=0,f=0;for(let w=0;w<p.length;w++){const S=p[w];if(S!==null){if(b===null){b=S;continue}g+=(S-b)**2,f+=1,b=m*S+(1-m)*b}}return{level:b,sse:g,m:f}}function c(p,m,b){let g=null,f=null,w=0,S=0;for(let h=0;h<p.length;h++){const d=p[h];if(d===null){g!==null&&f!==null&&(g+=f);continue}if(g===null){g=d;continue}f===null&&(f=d-g);const j=g+f;w+=(d-j)**2,S+=1;const E=g;g=m*d+(1-m)*(E+f),f=b*(g-E)+(1-b)*f}return{level:g,trend:f,sse:w,m:S}}function o(p,m,b,g,f){const w=p.length;if(w<2*m)return null;const S=L=>{let $=0,U=0;for(let x=L;x<L+m&&x<w;x++)p[x]!==null&&($+=p[x],U+=1);return U?$/U:null},h=S(0),d=S(m);if(h===null||d===null)return null;let j=h,E=(d-h)/m;const O=new Array(m).fill(0);for(let L=0;L<m;L++)O[L]=p[L]===null?0:p[L]-j;const T=O.reduce((L,$)=>L+$,0)/m;for(let L=0;L<m;L++)O[L]-=T;let A=0,P=0;for(let L=m;L<w;L++){const $=L%m,U=O[$],x=p[L];if(x===null){j+=E;continue}const F=j+E+U;A+=(x-F)**2,P+=1;const C=j;j=b*(x-U)+(1-b)*(j+E),E=g*(j-C)+(1-g)*E,O[$]=f*(x-j)+(1-f)*U}return{level:j,trend:E,season:O,phase:(w-1)%m,sse:A,count:P}}function n(p,m,b){let g=1;for(const w of m)g+=w*w;const f=Math.sqrt(p*g);return{se:f,margin:b*f}}function t(p,m={}){if(!p||typeof p.length!="number"||p.length===0)return null;const b=_.includes(m.method)?m.method:"linear",g=Math.max(1,Math.floor(Number(m.horizon)||1)),f=Number.isFinite(m.confidence)&&m.confidence>0&&m.confidence<1?m.confidence:.95,w=1-(1-f)/2,S=G(p),h=S.map(A=>A.value),d=h.filter(A=>A!==null),j=d.length,{lastAt:E,step:O}=j?D(S):{lastAt:0,step:1},T=A=>E+A*O;return b==="linear"?i(S,j,g,f,w,T):b==="movingAverage"?a(d,j,g,f,w,m,T):b==="ses"?r(h,j,g,f,w,m,T):b==="holt"?s(h,j,g,f,w,m,T):u(h,j,g,f,w,m,T)}function i(p,m,b,g,f,w){if(m<2)return null;let S=0,h=0;for(const x of p)x.value!==null&&(S+=x.at,h+=x.value);S/=m,h/=m;let d=0,j=0,E=0;for(const x of p){if(x.value===null)continue;const F=x.at-S,C=x.value-h;d+=F*F,j+=F*C,E+=C*C}if(d===0)return null;const O=j/d,T=h-O*S,A=E===0?1:Math.max(0,Math.min(1,j*j/(d*E))),P=Math.max(0,E-O*j),L=m>2?Math.sqrt(P/(m-2)):null,$=m>2?I(f,m-2):null,U=[];for(let x=1;x<=b;x++){const F=w(x),C=T+O*F;let z=null,q=null,Q=null,Y=null,J=null;if(L!==null){const te=1/m+(F-S)**2/d,ee=L*Math.sqrt(1+te),re=L*Math.sqrt(te);J=ee,z=C-$*ee,q=C+$*ee,Q=C-$*re,Y=C+$*re}U.push({step:x,at:F,mean:C,lower:z,upper:q,lowerMean:Q,upperMean:Y,se:J})}return{method:"linear",horizon:b,confidence:g,n:m,sigma:L,r2:A,params:{slope:O,intercept:T},points:U}}function a(p,m,b,g,f,w,S){if(m<1)return null;const h=Math.max(1,Math.min(m,Math.floor(Number(w.windowLen)||m))),d=p.slice(m-h);let j=0;for(const L of d)j+=L;const E=j/h;let O=null,T=null;if(h>1){let L=0;for(const U of d)L+=(U-E)**2;O=Math.sqrt(L/(h-1))*Math.sqrt(1+1/h),T=I(f,h-1)}const A=O===null?null:T*O,P=[];for(let L=1;L<=b;L++)P.push({step:L,at:S(L),mean:E,lower:A===null?null:E-A,upper:A===null?null:E+A,se:O});return{method:"movingAverage",horizon:b,confidence:g,n:m,sigma:O===null?null:O,params:{windowLen:h},points:P}}function r(p,m,b,g,f,w,S){if(m<1)return null;let h=Number.isFinite(w.alpha)?v(w.alpha):null;h===null&&(h=k(T=>y(p,T).sse));const d=y(p,h),j=M(f),E=d.m>0?d.sse/d.m:null,O=[];for(let T=1;T<=b;T++){const A=d.level;let P=null,L=null,$=null;if(E!==null){const U=[];for(let F=1;F<T;F++)U.push(h);const x=n(E,U,j);$=x.se,P=A-x.margin,L=A+x.margin}O.push({step:T,at:S(T),mean:A,lower:P,upper:L,se:$})}return{method:"ses",horizon:b,confidence:g,n:m,sigma:E===null?null:Math.sqrt(E),params:{alpha:h},points:O}}function s(p,m,b,g,f,w,S){if(m<2)return null;let h=Number.isFinite(w.alpha)?v(w.alpha):null,d=Number.isFinite(w.beta)?v(w.beta):null;if(h===null||d===null){let P=h===null?.5:h,L=d===null?.5:d;for(let $=0;$<6;$++)h===null&&(P=k(U=>c(p,U,L).sse)),d===null&&(L=k(U=>c(p,P,U).sse));h=h===null?P:h,d=d===null?L:d}const j=c(p,h,d),E=M(f),O=j.m>0?j.sse/j.m:null,T=h*d,A=[];for(let P=1;P<=b;P++){const L=j.level+P*j.trend;let $=null,U=null,x=null;if(O!==null){const F=[];for(let z=1;z<P;z++)F.push(h+z*T);const C=n(O,F,E);x=C.se,$=L-C.margin,U=L+C.margin}A.push({step:P,at:S(P),mean:L,lower:$,upper:U,se:x})}return{method:"holt",horizon:b,confidence:g,n:m,sigma:O===null?null:Math.sqrt(O),params:{alpha:h,beta:d},points:A}}function u(p,m,b,g,f,w,S){const h=Math.floor(Number(w.period));if(!(h>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(m<2*h)return null;let d=Number.isFinite(w.alpha)?v(w.alpha):null,j=Number.isFinite(w.beta)?v(w.beta):null,E=Number.isFinite(w.gamma)?v(w.gamma):null;const O=(x,F,C)=>{const z=o(p,h,x,F,C);return z?z.sse:1/0};if(d===null||j===null||E===null){let x=d===null?.5:d,F=j===null?.5:j,C=E===null?.5:E;for(let z=0;z<8;z++)d===null&&(x=k(q=>O(q,F,C))),j===null&&(F=k(q=>O(x,q,C))),E===null&&(C=k(q=>O(x,F,q)));d=d===null?x:d,j=j===null?F:j,E=E===null?C:E}const T=o(p,h,d,j,E);if(!T)return null;const A=M(f),P=T.count>0?T.sse/T.count:null,L=d*j,$=E*(1-d),U=[];for(let x=1;x<=b;x++){const F=T.season[(T.phase+x)%h],C=T.level+x*T.trend+F;let z=null,q=null,Q=null;if(P!==null){const Y=[];for(let te=1;te<x;te++)Y.push(d+te*L+(te%h===0?$:0));const J=n(P,Y,A);Q=J.se,z=C-J.margin,q=C+J.margin}U.push({step:x,at:S(x),mean:C,lower:z,upper:q,se:Q})}return{method:"holtWinters",horizon:b,confidence:g,n:m,sigma:P===null?null:Math.sqrt(P),params:{alpha:d,beta:j,gamma:E,period:h},points:U}}const l={FORECAST_METHODS:_,forecast:t}}),je("packages/core/src/compute/hypothesis.js",function(e,V){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return A}});const M=V("packages/core/src/internal/util.js").warnOnce,N=V("packages/core/src/compute/handle.js").valueReader,W=V("packages/core/src/compute/statistics.js"),_=W.numbers,H=W.moments,B=W.frequencyMap,G=W.categoricalDistance,D=W.isNumericColumn,v=W.jarqueBera,k=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,o=V("packages/core/src/compute/compare.js").pooledStandardMeanDifference,n=V("packages/core/src/compute/special.js"),t=n.studentT,i=n.studentTQuantile,a=n.normalCdf,r=n.normalQuantile,s=n.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),l=.05,p=2e6;function m(P){const L=Number(P);return Number.isFinite(L)&&L>0&&L<1?L:.95}function b(P){const{n:L,mean:$,m2:U}=H(P);return{mean:$,sd:L>0?Math.sqrt(U/L):0,n:L}}function g(P,L){const $=P.length;if($<2)return 0;let U=0;for(let x=0;x<$;x++){const F=P[x]-L;U+=F*F}return U/($-1)}function f(P,L){return{name:"pooledStandardMeanDifference",value:o(b(P),b(L))}}function w(P,L,$){const U=P.length,x=L.length;if(U<2||x<2)return null;const F=m($),{mean:C}=H(P),{mean:z}=H(L),q=g(P,C),Q=g(L,z),Y=q/U+Q/x;if(!(Y>0))return null;const J=Math.sqrt(Y),te=(C-z)/J,ee=q/U*(q/U)/(U-1),re=Q/x*(Q/x)/(x-1),se=Y*Y/(ee+re),de=Math.min(1,Math.max(0,2*(1-t(Math.abs(te),se)))),ie=C-z,oe=i(1-(1-F)/2,se)*J;return{test:u.WELCH,statistic:te,statisticName:"t",df:se,pValue:de,interval:{estimate:ie,lower:ie-oe,upper:ie+oe,confidence:F,method:"welch-t (difference of means)"},effectSize:f(P,L),nA:U,nB:x,reliable:U>=y&&x>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function S(P){const L=P.length;if(L===0)return Number.NaN;const $=L>>1;return L%2?P[$]:(P[$-1]+P[$])/2}function h(P,L,$){const U=P.length,x=L.length,F=U*x;if(F===0||F>p)return null;const C=new Float64Array(F);let z=0;for(let ee=0;ee<U;ee++)for(let re=0;re<x;re++)C[z++]=P[ee]-L[re];C.sort();const q=S(C),Q=Math.sqrt(U*x*(U+x+1)/12),Y=r(1-(1-$)/2);let J=Math.round(F/2-Y*Q);J>=0||(J=0);const te=Math.floor((F-1)/2);return J>te&&(J=te),{estimate:q,lower:C[J],upper:C[F-1-J],confidence:$,method:"hodges-lehmann (normal approximation)"}}function d(P,L,$){const U=P.length,x=L.length;if(U<1||x<1)return null;const F=m($),C=U+x,z=new Array(C);for(let de=0;de<U;de++)z[de]={v:P[de],g:0};for(let de=0;de<x;de++)z[U+de]={v:L[de],g:1};z.sort((de,ie)=>de.v-ie.v);let q=0,Q=0,Y=0;for(;Y<C;){let de=Y;for(;de<C&&z[de].v===z[Y].v;)de++;const ie=de-Y,oe=(Y+1+de)/2;for(let ue=Y;ue<de;ue++)z[ue].g===0&&(q+=oe);Q+=ie*ie*ie-ie,Y=de}const J=q-U*(U+1)/2,te=U*x/2,ee=U*x/12*(C+1-Q/(C*(C-1)));let re=1;if(ee>0){const de=Math.max(0,Math.abs(J-te)-.5);re=Math.min(1,2*a(-de/Math.sqrt(ee)))}const se=h(P,L,F);return{test:u.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:re,interval:se,effectSize:f(P,L),nA:U,nB:x,reliable:U>=y&&x>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function j(P,L,$,U,x){const F=k(P,L,x),C=k($,U,x);if(!F||!C)return null;const z=F.proportion-C.proportion,q=z-Math.sqrt((F.proportion-F.lower)**2+(C.upper-C.proportion)**2),Q=z+Math.sqrt((F.upper-F.proportion)**2+(C.proportion-C.lower)**2);return{lower:q,upper:Q}}function E(P,L,$,U,x,F={}){if(!(L>0)||!(U>0))return null;const C=new Set([...P.keys(),...$.keys()]),z=C.size;if(z<2)return null;const q=L+U;let Q=0;for(const re of C){const se=P.get(re)||0,de=$.get(re)||0,ie=se+de,oe=L*ie/q,ue=U*ie/q;oe>0&&(Q+=(se-oe)*(se-oe)/oe),ue>0&&(Q+=(de-ue)*(de-ue)/ue)}const Y=z-1,J=s(Q,Y);let te=null;F.category!==void 0&&C.has(F.category)?te=F.category:z===2&&([te]=[...C]);let ee=null;if(te!==null){const re=j(P.get(te)||0,L,$.get(te)||0,U,m(x));re&&(ee={estimate:(P.get(te)||0)/L-($.get(te)||0)/U,lower:re.lower,upper:re.upper,confidence:m(x),method:"newcombe (difference in this category's share)",category:te})}return{test:u.CHI_SQUARE,statistic:Q,statisticName:"chiSquare",df:Y,pValue:J,interval:ee,effectSize:{name:"categoricalTotalVariation",value:G(P,L,$,U)},nA:L,nB:U,reliable:L>=y&&U>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function T(P,L,$){if($===u.WELCH||$===u.MANN_WHITNEY)return{test:$,chosenBy:"override",reason:`caller override: ${$}`};const U=v(P),x=v(L),F=U===null?null:Math.exp(-U/2),C=x===null?null:Math.exp(-x/2);return F!==null&&F<l||C!==null&&C<l?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${l})`}:{test:u.WELCH,chosenBy:"auto",reason:F!==null||C!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function A(P,L,$,U={}){if(!P||!L)return null;const x=m(U.confidence),F=N(L);let C;if(Array.isArray(U.groups)&&U.groups.length===2)C=[O(U.groups[0]),O(U.groups[1])];else{const{map:de}=B(L,$),ie=[...de.entries()].sort((oe,ue)=>ue[1]-oe[1]).slice(0,2).map(oe=>oe[0]);if(ie.length<2)return M("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;C=ie}const[z,q]=C;if(z===null||q===null||z===q)return M("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Q=[],Y=[];for(let de=0;de<$.length;de++){const ie=O(F($[de]));ie===z?Q.push($[de]):ie===q&&Y.push($[de])}if(Q.length===0||Y.length===0)return M("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=U.test&&U.test!=="auto"?String(U.test):null,te=D(P,Q.concat(Y));let ee,re,se;if(J===u.CHI_SQUARE||!J&&!te){re=J?"override":"auto",se=J?"caller override: chiSquare":"column family: categorical";const de=B(P,Q),ie=B(P,Y);ee=E(de.map,de.total,ie.map,ie.total,x,{category:U.category})}else{if((J===u.WELCH||J===u.MANN_WHITNEY)&&!te)return M("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const de=_(P,Q),ie=_(P,Y),oe=T(de,ie,J);re=oe.chosenBy,se=oe.reason,ee=oe.test===u.MANN_WHITNEY?d(de,ie,x):w(de,ie,x)}return ee?{...ee,chosenBy:re,reason:se,groups:[z,q]}:(M("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),je("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 I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Z="__lattice_detail",M=36;function I(W){const _=W.config&&W.config.detailColumnWidth||M;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(H,B){return!!(B&&B.expanded)},formatValue(){return""}}}const N=I}),je("packages/core/src/columns/treecolumn.js",function(e,V){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isFunction,I="__lattice_tree",N=260;function W(H){const B=H.tree||{},G=H.config&&H.config.treeColumnWidth||N,D=()=>(H.columns&&M(H.columns.visible)?H.columns.visible():[]).find(c=>!c.generated)||null,v=(y,c)=>{if(c&&c.group)return c.groupValue;if(M(B.label))return B.label(y,c);if(typeof B.label=="string")return y==null?null:y[B.label];const o=D();return o&&M(o.getValue)?o.getValue(y,c):null},k=()=>{if(B.title)return B.title;const y=typeof B.label=="string"?H.columns&&M(H.columns.get)?H.columns.get(B.label):null:D();return y&&(y.title||y.id)||"Hierarchy"};return{id:I,get title(){return k()},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:G,min:140,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(y,c){return v(y,c)},formatValue(y,c){if(c&&c.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(y==null)return"";if(!B.label){const o=D();if(o&&M(o.formatValue))return o.formatValue(y,c)}return String(y)}}}const _=W}),je("packages/core/src/columns/pivotcolumns.js",function(e,V){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const M=V("packages/core/src/internal/util.js").warnOnce,I="__lattice_pivot",N=500;function W(G){const{pivot:D,valueColumns:v,config:k}=G,y=D&&D.paths||[],c=G.separator||k&&k.pivot&&k.pivot.separator||" | ",o=k&&k.pivot&&k.pivot.maxColumns||N;if(!y.length||!v.length)return{tree:[],leaves:[],error:null};const n=_(k),t=y.length*v.length+(n?v.length:0);if(t>o){const r=`pivot would generate ${t} columns, above the limit of ${o}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return M(`pivot.maxColumns:${t}`,r),{tree:[],leaves:[],error:r}}const i=[],a=[];for(const r of y){const s=[];for(const u of v){const l=B(r,u,c);s.push(l),a.push(l)}s.length===1?(s[0].title=String(r),i.push(s[0])):i.push({id:`${I}:group:${r}`,title:String(r),columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(n){const r=v.map(u=>H(u,k));a.push(...r);const s=k&&k.pivot&&k.pivot.totalsLabel||"Total";if(r.length===1)r[0].title=s,n==="before"?i.unshift(r[0]):i.push(r[0]);else{const u={id:`${I}:group:__totals`,title:s,columns:r,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};n==="before"?i.unshift(u):i.push(u)}}return{tree:i,leaves:a,error:null}}function _(G){const D=G&&G.pivot&&G.pivot.groupTotals;return D==="before"||D==="after"?D:null}function H(G,D){return{id:`${I}:__total${D&&D.pivot&&D.pivot.separator||" | "}${G.id}`,field:null,title:G.title||G.id,type:G.type,dataType:G.dataType,nullable:!0,align:G.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:G.id,total:!0},value:{pure:!0},cell:{align:G.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:G.total,lookup:null,layout:{width:G.layout&&G.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(v,k){const y=k&&k.totals;return y&&Object.hasOwn(y,G.id)?y[G.id]:null},formatValue(v,k){return v==null?"":G.formatValue?G.formatValue(v,k):String(v)}}}function B(G,D,v){return{id:`${I}:${G}${v}${D.id}`,field:null,title:D.title||D.id,type:D.type,dataType:D.dataType,nullable:!0,align:D.align,generated:!0,pivot:{enabled:!1,index:0,path:G,sourceId:D.id},value:{pure:!0},cell:{align:D.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:D.total,lookup:null,layout:{width:D.layout&&D.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(k,y){return k==null?"":D.formatValue?D.formatValue(k,y):String(k)}}}}),je("packages/core/src/compute/group.js",function(e,V){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/compute/handle.js"),M=Z.dictSize,I=Z.identity,N=Z.presenceReader,W=Z.rowCount,_=Z.valueReader,H="",B="\0",G=1<<20;function D(y,c,o,n){const t=y.length,i=y.map(p=>_(p)),a=Array.isArray(n)&&n.some(Boolean),r=a?i.map((p,m)=>n[m]?b=>n[m](p(b)):p):i;if(!a&&t>0&&y.every(p=>p&&p.kind==="dictionary"&&p.dict)){const p=y.map(b=>M(b.dict)+1);let m=1;for(let b=0;b<t;b++)m*=p[b];if(m<=Number.MAX_SAFE_INTEGER){const b=y.map(S=>S.values),g=y.map(S=>N(S)),f=S=>{let h=0;for(let d=0;d<t;d++){const j=g[d],E=j&&j(S)===0?p[d]-1:b[d][S];h=h*p[d]+E}return h},w=new Float64Array(o);for(let S=0;S<o;S++)w[S]=f(c[S]);return{packed:w,strings:null,product:m,readers:r,keyOf:f}}}const u=p=>{let m="";for(let b=0;b<t;b++){const g=r[b](p);m+=(b===0?"":H)+(g==null?B:String(g))}return m},l=new Array(o);for(let p=0;p<o;p++)l[p]=u(c[p]);return{packed:null,strings:l,product:1/0,readers:r,keyOf:u}}function v(y,c,o,n){const t=new Uint32Array(n+1);for(let s=0;s<o;s++)t[c[s]+1]++;for(let s=0;s<n;s++)t[s+1]+=t[s];const i=new Uint32Array(o),a=t.slice(0,n);for(let s=0;s<o;s++)i[a[c[s]]++]=y[s];const r=new Array(n);for(let s=0;s<n;s++)r[s]=i.subarray(t[s],t[s+1]);return r}function k(y,c,o={}){const n=y||[],t=c||I(W(n[0],o)),i=t.length;if(n.length===0||i===0)return{keys:[],buckets:[]};const{packed:a,strings:r,product:s,readers:u}=D(n,t,i,o.project),l=new Uint32Array(i);let p=0,m=null;if(a&&s<=Math.max(1024,Math.min(G,i*4))){const w=s,S=new Int32Array(w).fill(-1);for(let h=0;h<i;h++)S[a[h]]=0;for(let h=0;h<w;h++)S[h]===0&&(S[h]=p++);for(let h=0;h<i;h++)l[h]=S[a[h]];m=new Float64Array(p);for(let h=0;h<w;h++)S[h]>=0&&(m[S[h]]=h)}else if(a){const w=new Map;for(let S=0;S<i;S++){const h=a[S];let d=w.get(h);d===void 0&&(d=p++,w.set(h,d)),l[S]=d}m=new Float64Array(p);for(const[S,h]of w)m[h]=S}else{const w=new Map;for(let S=0;S<i;S++){const h=r[S];let d=w.get(h);d===void 0&&(d=p++,w.set(h,d)),l[S]=d}}const b=v(t,l,i,p),g=new Array(p);for(let w=0;w<p;w++){const S=b[w][0],h=new Array(u.length);for(let d=0;d<u.length;d++)h[d]=u[d](S);g[w]=h}const f={keys:g,buckets:b};return m&&(f.packed=m),f}}),je("packages/core/src/compute/pivot.js",function(e,V){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return i}});const M=V("packages/core/src/internal/util.js").warnOnce,N=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,G="|",D="/",v=2e3;function k(s,u,l){return`${s}${G}${u}${G}${l}`}function y(s,u){let l="";for(let p=0;p<s.length;p++){const m=s[p];l+=(p===0?"":u)+(m==null?"":String(m))}return l}function c(s,u,l={}){const p=l.separator||D,m=u.length,{keyOf:b,readers:g}=_(s,u,0),f=new Map,w=[],S=[];for(let A=0;A<m;A++){const P=u[A],L=b(P);if(f.has(L))continue;f.set(L,w.length),S.push(L);const $=new Array(g.length);for(let U=0;U<g.length;U++)$[U]=g[U](P);w.push($)}const h=N(l.locale),d=w.map((A,P)=>P);d.sort((A,P)=>{const L=w[A],$=w[P];for(let U=0;U<L.length;U++){const x=o(L[U],$[U],h);if(x!==0)return x}return A-P});const j=new Array(d.length),E=new Array(d.length),O=new Map;for(let A=0;A<d.length;A++){const P=d[A];j[A]=w[P],E[A]=y(w[P],p),O.set(S[P],A)}return{keys:j,paths:E,idOf:A=>{const P=O.get(b(A));return P===void 0?-1:P}}}function o(s,u,l){const p=s==null,m=u==null;return p||m?p&&m?0:p?1:-1:l(s,u)}function n(s){const u=s.values||s.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(b=>b&&b.handle);const l=typeof s.handle=="function"?s.handle:null;if(!l)return u.length&&M("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 p=typeof s.totalOf=="function"?s.totalOf:null,m=[];for(const b of u){const g=l(b);g&&m.push({colId:b,handle:g,fn:p?p(b):"sum"})}return m}function t(s,u,l){if(Array.isArray(s)){const p=l||{};return{...p,pivotHandles:s,order:u||null,groups:p.groups||null}}return s||{}}function i(s,u,l){const p=t(s,u,l),m=p.separator||D,b=n(p),g=p.maxColumns===void 0?v:p.maxColumns,f=p.groups&&p.groups.buckets?p.groups:null,w=f?f.buckets:[p.order||new Uint32Array(0)],S=p.groupPaths||(f?f.keys.map(L=>y(L,m)):[""]),h=r(w),{keys:d,paths:j,idOf:E}=c(p.pivotHandles||[],h,p),O=j.length*Math.max(1,b.length),T=a(j,b,m);if(g&&O>g){const L=new Map;return{keys:d,paths:j,fields:T,groupPaths:S,columns:O,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:g}}}const A=new Map,P=j.length;for(let L=0;L<w.length;L++){const $=w[L],U=S[L]===void 0?"":S[L],x=$.length;if(x===0)continue;const F=new Int32Array(x),C=new Uint32Array(P+1);for(let Q=0;Q<x;Q++){const Y=E($[Q]);F[Q]=Y,Y>=0&&C[Y+1]++}for(let Q=0;Q<P;Q++)C[Q+1]+=C[Q];const z=new Uint32Array(x),q=C.slice(0,P);for(let Q=0;Q<x;Q++){const Y=F[Q];Y>=0&&(z[q[Y]++]=$[Q])}for(let Q=0;Q<P;Q++){const Y=C[Q],J=C[Q+1];if(J===Y)continue;const te=z.subarray(Y,J);for(let ee=0;ee<b.length;ee++){const re=b[ee],se=B(re.handle,te,re.fn,p.totalContext||{locale:p.locale});A.set(k(U,j[Q],re.colId),se)}}}return{keys:d,paths:j,fields:T,groupPaths:S,columns:O,values:A,cells:A,error:null}}function a(s,u,l){if(u.length===0)return s.slice();const p=[];for(const m of s)for(const b of u)p.push(`${m}${l}${b.colId}`);return p}function r(s){if(s.length===1)return s[0]||new Uint32Array(0);let u=0;for(const m of s)u+=m?m.length:0;const l=new Uint32Array(u);let p=0;for(const m of s)!m||m.length===0||(l.set(m,p),p+=m.length);return l}}),je("packages/core/src/store/bitset.js",function(e,V){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return M}});const Z=8;class M{static#e=new Uint8Array(256);static{for(let N=1;N<256;N++)M.#e[N]=M.#e[N>>1]+(N&1)}#t;#n;constructor(N=0){const W=Math.max(0,N|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(N){return N<0||N>=this.#n?0:this.#t[N>>3]>>(N&7)&1}set(N){return N>=0&&N<this.#n&&(this.#t[N>>3]|=1<<(N&7)),this}clear(N){return N>=0&&N<this.#n&&(this.#t[N>>3]&=~(1<<(N&7))),this}assign(N,W){return W?this.set(N):this.clear(N)}fill(N=!1){return this.#t.fill(N?255:0),N&&this.#r(),this}grow(N){const W=Math.max(0,N|0);if(W<=this.#n)return this;const _=Math.ceil(W/Z);if(_>this.#t.length){const H=new Uint8Array(_);H.set(this.#t),this.#t=H}return this.#n=W,this}count(){const N=this.#t,W=M.#e;let _=0;for(let H=0;H<N.length;H++)_+=W[N[H]];return _}and(N){const W=N instanceof M?N.words:N,_=this.#t,H=Math.min(_.length,W.length);for(let B=0;B<H;B++)_[B]&=W[B];for(let B=H;B<_.length;B++)_[B]=0;return this}or(N){const W=N instanceof M?N.words:N,_=this.#t,H=Math.min(_.length,W.length);for(let B=0;B<H;B++)_[B]|=W[B];return this}not(){const N=this.#t;for(let W=0;W<N.length;W++)N[W]=~N[W]&255;return this.#r(),this}clone(){const N=new M(this.#n);return N.words.set(this.#t.subarray(0,N.words.length)),N}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const N=this.#n&7;if(N===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<N)-1)}static from(N){const W=Array.isArray(N)?N:Array.from(N),_=new M(W.length);for(let H=0;H<W.length;H++)W[H]&&_.set(H);return _}}}),je("packages/core/src/store/dictionary.js",function(e,V){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return N}});const Z=V("packages/core/src/internal/util.js"),M=Z.collator,I=Z.defaultCompare;class N{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(_=[]){this.#e=[];for(let H=0;H<_.length;H++){const B=_[H];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 H=0;H<this.#e.length;H++){const B=this.#e[H];typeof B=="string"&&(_+=B.length*2),_+=16}return _}codeOf(_){const H=this.#t.get(_);if(H!==void 0)return H;const B=this.#e.length;return this.#e.push(_),this.#t.set(_,B),this.#n++,B}lookup(_){const H=this.#t.get(_);return H===void 0?-1:H}has(_){return this.#t.has(_)}valueOf(_){return this.#e[_]}values(){return this.#e}ranks(_){const H=_||"";if(this.#r&&this.#o===this.#n&&this.#i===H)return this.#r;const B=this.#e.length,G=new Array(B);for(let y=0;y<B;y++)G[y]=y;const D=M(_).compare,v=this.#e;G.sort((y,c)=>this.#s(v[y],v[c],D));const k=new Uint32Array(B);for(let y=0;y<B;y++)k[G[y]]=y;return this.#r=k,this.#o=this.#n,this.#i=H,k}#s(_,H,B){return typeof _=="string"&&typeof H=="string"?B(_,H):I(_,H)}}}),je("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(I={}){const N=Math.max(1,I.rows??16),W=Math.max(1,I.values??N);this.#e=new Int32Array(W),this.#t=new Uint32Array(N+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(I){return I<0||I>=this.#n?0:this.#t[I+1]-this.#t[I]}at(I){return I<0||I>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[I],this.#t[I+1])}has(I,N){if(I<0||I>=this.#n)return!1;const W=this.#e,_=this.#t[I+1];for(let H=this.#t[I];H<_;H++)if(W[H]===N)return!0;return!1}hasAny(I,N){for(let W=0;W<N.length;W++)if(this.has(I,N[W]))return!0;return!1}hasAll(I,N){for(let W=0;W<N.length;W++)if(!this.has(I,N[W]))return!1;return!0}hasNone(I,N){return!this.hasAny(I,N)}push(I){const N=this.#n,W=I.length;this.#o(N+1),this.#i(this.#r+W);const _=this.#r;for(let H=0;H<W;H++)this.#e[_+H]=I[H]|0;return this.#r+=W,this.#n=N+1,this.#t[N]=_,this.#t[N+1]=this.#r,N}write(I,N){if(I===this.#n){this.push(N);return}if(I<0||I>this.#n)return;const W=this.#t[I],_=this.#t[I+1],H=N.length;if(_-W===H){for(let B=0;B<H;B++)this.#e[W+B]=N[B]|0;return}this.#s(I,N)}compact(I,N,W){const _=this.#e,H=this.#t,B=this.#n,G=new Int32Array(Math.max(1,this.#r)),D=new Uint32Array(N+1);let v=0;for(let k=0;k<B;k++){if(I[k]===W)continue;const y=H[k],c=H[k+1];D[I[k]]=v;for(let o=y;o<c;o++)G[v++]=_[o];D[I[k]+1]=v}this.#e=G,this.#t=D,this.#n=N,this.#r=v}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(I){if(I+1<=this.#t.length)return;let N=this.#t.length-1;for(;N<I;)N=N*2||16;const W=new Uint32Array(N+1);W.set(this.#t),this.#t=W}#i(I){if(I<=this.#e.length)return;let N=this.#e.length;for(;N<I;)N=N*2||16;const W=new Int32Array(N);W.set(this.#e),this.#e=W}#s(I,N){const W=this.#e,_=this.#t,H=this.#n,B=N.length-(_[I+1]-_[I]),G=new Int32Array(Math.max(1,this.#r+B)),D=new Uint32Array(_.length);let v=0;for(let k=0;k<H;k++){if(D[k]=v,k===I)for(let y=0;y<N.length;y++)G[v++]=N[y]|0;else for(let y=_[k];y<_[k+1];y++)G[v++]=W[y];D[k+1]=v}this.#e=G,this.#t=D,this.#r=v}}}),je("packages/core/src/compute/sort.js",function(e,V){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const Z=V("packages/core/src/compute/handle.js"),M=Z.bitReader,I=Z.dictRanks,N=Z.dictSize,W=Z.identity,_=Z.isMissing,H=Z.presenceReader,B=Z.rowCount,G=Z.valueComparator,D=Z.valueReader,v=new Uint32Array(0),k=new ArrayBuffer(8),y=new Float64Array(k),c=new Uint32Array(k),o=(y[0]=-1,(c[1]&2147483648)!==0?1:0),n=o===1?0:1;function t($,U){y[0]=$;let x=c[o],F=c[n];(x&2147483648)!==0?(x=~x>>>0,F=~F>>>0):x=(x^2147483648)>>>0,U[0]=F,U[1]=x}function i($,U,x,F){if(F<2)return $;const C=new Uint32Array(256*8);for(let re=0;re<F;re++){const se=U[re],de=x[re];C[se&255]++,C[256+(se>>>8&255)]++,C[512+(se>>>16&255)]++,C[768+(se>>>24&255)]++,C[1024+(de&255)]++,C[1280+(de>>>8&255)]++,C[1536+(de>>>16&255)]++,C[1792+(de>>>24&255)]++}let z=$,q=U,Q=x,Y=new Uint32Array(F),J=new Uint32Array(F),te=new Uint32Array(F);const ee=new Uint32Array(256);for(let re=0;re<8;re++){const se=re<<8,de=(re&3)<<3,ie=re>=4;let oe=!1;for(let pe=0;pe<256;pe++)if(C[se+pe]===F){oe=!0;break}if(oe)continue;let ue=0;for(let pe=0;pe<256;pe++)ee[pe]=ue,ue+=C[se+pe];for(let pe=0;pe<F;pe++){const Me=q[pe],$e=Q[pe],Ae=(ie?$e:Me)>>>de&255,ke=ee[Ae]++;Y[ke]=z[pe],J[ke]=Me,te[ke]=$e}let ce=z;z=Y,Y=ce,ce=q,q=J,J=ce,ce=Q,Q=te,te=ce}return z}function a($,U,x){if(x<2)return $;const F=new Uint32Array(256*4);for(let J=0;J<x;J++){const te=U[J];F[te&255]++,F[256+(te>>>8&255)]++,F[512+(te>>>16&255)]++,F[768+(te>>>24&255)]++}let C=$,z=U,q=new Uint32Array(x),Q=new Uint32Array(x);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const te=J<<8,ee=J<<3;let re=!1;for(let ie=0;ie<256;ie++)if(F[te+ie]===x){re=!0;break}if(re)continue;let se=0;for(let ie=0;ie<256;ie++)Y[ie]=se,se+=F[te+ie];for(let ie=0;ie<x;ie++){const oe=z[ie],ue=Y[oe>>>ee&255]++;q[ue]=C[ie],Q[ue]=oe}let de=C;C=q,q=de,de=z,z=Q,Q=de}return C}function r($,U,x,F){const C=new Uint32Array(F+1);for(let Q=0;Q<x;Q++)C[U[Q]]++;let z=0;for(let Q=0;Q<=F;Q++){const Y=C[Q];C[Q]=z,z+=Y}const q=new Uint32Array(x);for(let Q=0;Q<x;Q++)q[C[U[Q]]++]=$[Q];return q}function s($,U,x,F){return x<2?$:F<=65536||F<=x*2?r($,U,x,F):a($,U,x)}function u($,U){return $.length===U&&$.byteOffset===0?$:Uint32Array.prototype.slice.call($,0,U)}function l($,U,x=!1){const F=U||W($.length),C=F.length;if(C<2)return Uint32Array.from(F);const z=new Uint32Array(C),q=new Uint32Array(C),Q=new Uint32Array(C),Y=new Uint32Array(C),J=new Uint32Array(2);let te=0,ee=0;for(let de=0;de<C;de++){const ie=F[de],oe=$[ie];if(Number.isNaN(oe)){Y[ee++]=ie;continue}t(oe,J),x?(q[te]=~J[0]>>>0,Q[te]=~J[1]>>>0):(q[te]=J[0],Q[te]=J[1]),z[te++]=ie}const re=i(z.subarray(0,te),q.subarray(0,te),Q.subarray(0,te),te);if(ee===0)return u(re,te);const se=new Uint32Array(C);return se.set(re.subarray(0,te),0),se.set(Y.subarray(0,ee),te),se}function p($,U,x=!1){const F=U||W($.length),C=F.length;if(C<2)return Uint32Array.from(F);const z=Uint32Array.from(F),q=new Uint32Array(C);for(let Q=0;Q<C;Q++){const Y=($[z[Q]]^2147483648)>>>0;q[Q]=x?~Y>>>0:Y}return u(a(z,q,C),C)}function m($,U,x={}){const F=U||W(B($,x)),C=F.length;if(C<2)return Uint32Array.from(F);const z=I($.dict,x.locale),q=$.values,Q=H($),Y=Math.max(N($.dict),z.length),J=Y,te=Uint32Array.from(F),ee=new Uint32Array(C),re=!!x.descending;for(let se=0;se<C;se++){const de=te[se];let ie=Q&&Q(de)===0?J:z[q[de]];ie===void 0&&(ie=J),ee[se]=re?J-ie:ie}return u(s(te,ee,C,Y+1),C)}function b($,U,x){const F=U.length;let C=Uint32Array.from(U);if(F<2)return C;let z=new Uint32Array(F);for(let q=1;q<F;q<<=1){for(let Y=0;Y<F;Y+=q<<1){const J=Math.min(Y+q,F),te=Math.min(Y+(q<<1),F);let ee=Y,re=J,se=Y;for(;ee<J&&re<te;)z[se++]=x($[C[ee]],$[C[re]])<=0?C[ee++]:C[re++];for(;ee<J;)z[se++]=C[ee++];for(;re<te;)z[se++]=C[re++]}const Q=C;C=z,z=Q}return C}function g($,U,x){const F=M($.values),C=U.length,z=new Uint32Array(C),q=x?1:0;let Q=0;for(let Y=0;Y<C;Y++)F(U[Y])===q&&(z[Q++]=U[Y]);for(let Y=0;Y<C;Y++)F(U[Y])!==q&&(z[Q++]=U[Y]);return z}function f($,U){const x=$.values,F=$.kind;if((F==="object"||F===void 0)&&(Array.isArray(x)||ArrayBuffer.isView(x))&&!$.presence)return x;const z=D($),q=new Array(B($)||0);for(let Q=0;Q<U.length;Q++){const Y=U[Q];q[Y]=z(Y)}return q}function w($,U){for(let x=0;x<U.length;x++)if(typeof $[U[x]]!="string")return!1;return!0}function S($,U,x,F,C){const z=$.length,q=Uint32Array.from($);if(z<2||F<1)return q;const Q=new Uint32Array(z),Y=F-1;for(let J=0;J<z;J++){const te=x[U[J]];Q[J]=C?Y-te:te}return u(s(q,Q,z,F),z)}function h($,U,x){const F=G(x),C=new Array(U);for(let q=0;q<U;q++)C[q]=q;C.sort((q,Q)=>F($[q],$[Q])||q-Q);const z=new Uint32Array(U);for(let q=0;q<U;q++)z[C[q]]=q;return z}function d($,U,x){const F=U.length,C=new Map,z=[],q=new Uint32Array(F);for(let J=0;J<F;J++){const te=$[U[J]];let ee=C.get(te);ee===void 0&&(ee=z.length,C.set(te,ee),z.push(te)),q[J]=ee}const Q=z.length,Y=h(z,Q,x.locale);return S(U,q,Y,Q,!!x.descending)}function j($,U,x){const F=f($,U);if(U.length>=2&&w(F,U)){const q=$.stringRank;return q&&q.version===$.version&&q.usable(U,F,x.locale)?q.sort(U,x):d(F,U,x)}const C=G(x.locale),z=x.descending?(q,Q)=>C(Q,q):C;return b(F,U,z)}function E($,U,x){const F=f($,U),C=x.compare,q=!!x.descending?(Q,Y)=>-C(Q,Y,void 0,void 0,!0):(Q,Y)=>C(Q,Y,void 0,void 0,!1);return b(F,U,q)}function O($,U){const x=U.length,F=H($),C=$.values,z=$.kind==="float64"&&!!C,q=$.kind==="object"||$.kind==="multi"||$.kind===void 0;if(!F&&!z&&!q)return{present:U,absent:v};const Q=new Uint32Array(x),Y=new Uint32Array(x);let J=0,te=0;if(F&&z)for(let ee=0;ee<x;ee++){const re=U[ee];F(re)===1&&!Number.isNaN(C[re])?Q[J++]=re:Y[te++]=re}else if(z&&!F)for(let ee=0;ee<x;ee++){const re=U[ee];Number.isNaN(C[re])?Y[te++]=re:Q[J++]=re}else if(F&&!q)for(let ee=0;ee<x;ee++){const re=U[ee];F(re)===1?Q[J++]=re:Y[te++]=re}else{const ee=D($);for(let re=0;re<x;re++){const se=U[re];_(ee(se))?Y[te++]=se:Q[J++]=se}}return te===0?{present:U,absent:v}:{present:Q.subarray(0,J),absent:Y.subarray(0,te)}}function T($,U,x){if(U.length===0)return $;const F=new Uint32Array($.length+U.length);return x?(F.set(U,0),F.set($,U.length)):(F.set($,0),F.set(U,$.length)),F}function A($,U,x={}){const F=U||W(B($,x));if(!$||F.length<2)return Uint32Array.from(F);const{present:C,absent:z}=O($,F);if(C.length===0)return Uint32Array.from(F);const q=!!x.descending;let Q;if(typeof x.compare=="function")Q=E($,C,x);else switch($.kind){case"float64":Q=l($.values,C,q);break;case"int32":Q=p($.values,C,q);break;case"dictionary":Q=m($,C,x);break;case"bitset":Q=g($,C,q);break;default:Q=j($,C,x);break}return T(Q,z,!!x.nullsFirst)}function P($,U,x,F={}){const C=U||[],z=C.length&&(C[0].handle||L($,C[0].col))||$&&$[0];let q=x||W(B(z,F));for(let Q=C.length-1;Q>=0;Q--){const Y=C[Q],J=Y.handle||L($,Y.col)||$&&$[Q];J&&(q=A(J,q,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:F.locale,compare:Y.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function L($,U){if(!(!$||U===void 0)){for(let x=0;x<$.length;x++)if($[x]&&$[x].id===U)return $[x]}}}),je("packages/core/src/store/stringrank.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const Z=V("packages/core/src/compute/sort.js"),M=Z.collateStringRanks,I=Z.rankSortStrings,N=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(H=N){this.#s=H>0?H:N,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const B=this.#e;for(let G=0;G<B.length;G++)H+=B[G].length*2+24;return H}#d(H,B){const G=this.#t.get(H);if(G!==void 0)return G;if(this.#l)return-1;if(B&&this.#e.length>=this.#s)return this.#l=!0,-1;const D=this.#e.length;return this.#e.push(H),this.#t.set(H,D),this.#o++,D}build(H,B){const G=B|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(G);for(let D=0;D<G;D++){const v=H[D],k=typeof v=="string"?this.#d(v,!1):-1;this.#n[D]=k<0?0:k}this.#r=G}append(H,B,G){const D=(B|0)+(G|0);if(D>this.#n.length){const v=new Uint32Array(D);v.set(this.#n.subarray(0,this.#r)),this.#n=v}for(let v=B|0;v<D;v++){const k=H[v],y=typeof k=="string"?this.#d(k,!0):-1;this.#n[v]=y<0?0:y}this.#r=Math.max(this.#r,D)}ranks(H){const B=H||"";if(this.#a&&this.#u===this.#o&&this.#c===B)return this.#a;const G=M(this.#e,this.#e.length,H);return this.#a=G,this.#u=this.#o,this.#c=B,G}usable(H,B,G){if(this.#l||this.#e.length===0)return!1;const D=this.#n,v=this.#e,k=this.#r;for(let y=0;y<H.length;y++){const c=H[y];if(c>=k||v[D[c]]!==B[c])return!1}return!0}sort(H,B){const G=this.ranks(B.locale),D=this.#e.length,v=H.length,k=new Uint32Array(v),y=this.#n;for(let c=0;c<v;c++)k[c]=y[H[c]];return I(H,k,G,D,!!B.descending)}}}),je("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 a}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return m}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isFunction,N=Z.pathGetter,_=V("packages/core/src/store/bitset.js").Bitset,B=V("packages/core/src/store/dictionary.js").Dictionary,D=V("packages/core/src/store/multivalue.js").MultiValue,k=V("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,c=1024,o=5e3,n=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function i(b){return b==null}function a(b){if(typeof b=="number")return b;if(b instanceof Date)return b.getTime();if(typeof b=="boolean")return b?1:0;const g=Number(b);return Number.isNaN(g)&&typeof b=="string"?Date.parse(b):g}function r(b){const g=a(b);return Number.isFinite(g)?g|0:0}function s(b){return i(b)?[]:Array.isArray(b)?b:[b]}function u(b,g){switch(b.kind){case"float64":case"int32":return b.buf[g];case"bitset":return b.bits.get(g)===1;case"dictionary":return b.dict.valueOf(b.buf[g]);case"multi":{const f=b.mv.at(g),w=new Array(f.length);for(let S=0;S<f.length;S++)w[S]=b.dict.valueOf(f[S]);return w}default:return b.buf[g]}}function l(b,g){switch(b.kind){case"float64":case"int32":return b.values[g];case"bitset":return(b.values[g>>3]&1<<(g&7))!==0;case"dictionary":return(b.table||[])[b.values[g]];case"multi":{const f=b.offsets[g],w=b.offsets[g+1],S=b.table||[],h=new Array(w-f);for(let d=f;d<w;d++)h[d-f]=S[b.values[d]];return h}default:return b.values[g]}}class p{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#w=0;#b=0;#v=null;#y=null;#S=!1;constructor(g,f){this.#e=g.id;const w=t.has(g.kind)?g.kind:"object";g.kind&&!t.has(g.kind)&&M(`store.kind.${g.id}`,`column "${g.id}" declares unknown storage kind "${g.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=g.nullable!==!1,this.#s=g.dictionary??null,this.#i=f,this.#o=I(g.read)?g.read:N(g.field||g.id),this.#f=g.stringRankIndex!=="off",this.#m=typeof g.stringRankMaxDistinct=="number"?g.stringRankMaxDistinct:0,this.#v=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#S||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const g=this.values,f=this.#i.physical();if(!g||f===0)return null;if(this.#h===null){if(typeof g[0]!="string")return null;const w=new k(this.#A());return w.build(g,f),w.version=this.#b,this.#h=w,this.#p=this.#b,w.capped?null:w}return this.#h.length<f&&this.#h.append(g,this.#h.length,f-this.#h.length),this.#h.version=this.#b,this.#p=this.#b,this.#h.capped?null:this.#h}#A(){return this.#m}#j(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let g=0;return this.#a&&(g+=this.#a.byteLength??this.#a.length*8),this.#u&&(g+=this.#u.bytes),this.#c&&(g+=this.#c.bytes),this.#g&&(g+=this.#g.bytes),this.#d&&(g+=this.#d.bytes),this.#v&&(g+=this.#v.size*24),g}get(g){if(!this.#S&&!(g<0||g>=this.#i.physical())){if(!this.#l)return this.#C(g);if(this.#r&&this.#g.get(g)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[g];case"bitset":return this.#u.get(g)===1;case"dictionary":return this.#d.valueOf(this.#a[g]);case"multi":{const f=this.#c.at(g),w=new Array(f.length);for(let S=0;S<f.length;S++)w[S]=this.#d.valueOf(f[S]);return w}default:return this.#a[g]}}}set(g,f){this.#S||(this.#l?this.#E(g,f):this.#v.set(g,f===void 0?null:f),this.#h&&this.#j(),this.#b++)}read(g){return this.#o(g)}appendColumn(g,f,w){if(this.#S||w<=0)return;if(!this.#l){this.#b++;return}const S=this.#o,h=this.#r,d=this.#g;let j=!1;switch(this.#t){case"float64":{const E=this.#a;for(let O=0;O<w;O++){const T=S(g[O]);if(typeof T=="number"){h&&d.set(f+O),E[f+O]=T;continue}const A=T==null;h?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?NaN:a(T)}break}case"int32":{const E=this.#a;for(let O=0;O<w;O++){const T=S(g[O]),A=T==null;h?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?0:r(T)}break}case"bitset":{const E=this.#u;for(let O=0;O<w;O++){const T=S(g[O]),A=T==null;h?d.assign(f+O,!A):A&&(j=!0),E.assign(f+O,!A&&!!T)}break}case"dictionary":{const E=this.#a,O=this.#d;for(let T=0;T<w;T++){const A=S(g[T]),P=A==null;h?d.assign(f+T,!P):P&&(j=!0),E[f+T]=P?0:O.codeOf(A)}break}case"multi":{const E=this.#c,O=this.#d;for(let T=0;T<w;T++){const A=S(g[T]),P=A==null;h?d.assign(f+T,!P):P&&(j=!0);const L=s(A),$=new Array(L.length);for(let U=0;U<L.length;U++)$[U]=O.codeOf(L[U]);E.write(f+T,$)}break}default:{const E=this.#a;for(let O=0;O<w;O++){const T=S(g[O]),A=T==null;h?d.assign(f+O,!A):A&&(j=!0),E[f+O]=A?null:T}break}}j&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,f,w),this.#h.version=this.#b+1,this.#p=this.#b+1),this.#b++}appendPacked(g,f,w){if(this.#S||w<=0||!g)return;if(!this.#l){this.#b++;return}const S=this.#g,h=g.presence;if(S)if(h)for(let j=0;j<w;j++)S.assign(f+j,(h[j>>3]&1<<(j&7))!==0);else for(let j=0;j<w;j++)S.set(f+j);const d=g.kind===this.#t;if(d&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(g.values,f),this.#b++;return}if(d&&this.#t==="bitset"){const j=g.values;for(let E=0;E<w;E++)this.#u.assign(f+E,(j[E>>3]&1<<(E&7))!==0);this.#b++;return}if(d&&this.#t==="dictionary"){const j=g.table||[],E=new Uint32Array(j.length);for(let P=0;P<j.length;P++)E[P]=this.#d.codeOf(j[P]);const O=g.values,T=this.#a,A=S;for(let P=0;P<w;P++){if(A&&(h&&(h[P>>3]&1<<(P&7))===0)){T[f+P]=0;continue}T[f+P]=E[O[P]]??0}this.#b++;return}if(d&&this.#t==="multi"){const j=g.table||[],E=new Uint32Array(j.length);for(let A=0;A<j.length;A++)E[A]=this.#d.codeOf(j[A]);const O=g.values,T=g.offsets;for(let A=0;A<w;A++){const P=T[A],L=T[A+1],$=new Array(L-P);for(let U=P;U<L;U++)$[U-P]=E[O[U]]??0;this.#c.write(f+A,$)}this.#b++;return}for(let j=0;j<w;j++){const E=h?(h[j>>3]&1<<(j&7))===0:g.kind==="object"?g.values[j]===null:!1;this.#E(f+j,E?null:l(g,j))}this.#b++}touch(){this.#b++}columnarise(g,f){if(this.#l||this.#S)return;const w=new Array(f);for(let S=0;S<f;S++)w[S]=this.#C(S);this.#t=this.#n,this.#l=!0,this.#O(g);for(let S=0;S<f;S++)this.#E(S,w[S]);this.#v.clear(),this.#y=null,this.#j(),this.#b++}grow(g){if(!(!this.#l||this.#S||g<=this.#w)){switch(this.#t){case"float64":case"int32":case"dictionary":{const f=new this.#a.constructor(g);f.set(this.#a),this.#a=f;break}case"bitset":this.#u.grow(g);break;case"multi":break;default:this.#a.length=g;break}this.#g&&this.#g.grow(g),this.#w=g,this.#b++}}convert(g){if(this.#S||!t.has(g)||(this.#n=g,!this.#l||g===this.#t))return!1;const f={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),S=this.#g;this.#t=g,this.#O(this.#w);for(let h=0;h<w;h++){const d=S!==null&&S.get(h)===0;d&&g!=="multi"||this.#E(h,d?null:u(f,h))}return this.#j(),this.#b++,!0}compact(g,f,w){if(!this.#S){if(this.#j(),!this.#l){const S=this.#v;if(S.size){const h=new Map;for(const[d,j]of S)g[d]!==y&&h.set(g[d],j);this.#v=h}this.#y=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const S=this.#a;for(let h=0;h<f;h++)g[h]!==y&&(S[g[h]]=S[h]);if(this.#t==="object")for(let h=w;h<f;h++)S[h]=void 0;break}case"bitset":{const S=this.#u;for(let h=0;h<f;h++)g[h]!==y&&S.assign(g[h],S.get(h)===1);for(let h=w;h<f;h++)S.clear(h);break}case"multi":this.#c.compact(g,w,y);break;default:break}if(this.#g){const S=this.#g;for(let h=0;h<f;h++)g[h]!==y&&S.assign(g[h],S.get(h)===1);for(let h=w;h<f;h++)S.clear(h)}this.#b++}}release(){this.#S||(this.#S=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#v=new Map,this.#y=null,this.#w=0,this.#b++)}#O(g){const f=Math.max(1,g);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(f);break;case"int32":this.#a=new Int32Array(f);break;case"bitset":this.#u=new _(f);break;case"dictionary":this.#a=new Uint32Array(f),this.#d=this.#d??new B(this.#s??[]);break;case"multi":this.#c=new D({rows:f,values:f}),this.#d=this.#d??new B(this.#s??[]);break;default:this.#a=new Array(f);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(f):this.#g=new _(f)),this.#w=f}#E(g,f){const w=i(f);switch(this.#r?this.#g.assign(g,!w):w&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[g]=w?NaN:a(f);break;case"int32":this.#a[g]=w?0:r(f);break;case"bitset":this.#u.assign(g,!w&&!!f);break;case"dictionary":this.#a[g]=w?0:this.#d.codeOf(f);break;case"multi":{const S=s(f),h=new Array(S.length);for(let d=0;d<S.length;d++)h[d]=this.#d.codeOf(S[d]);this.#c.write(g,h);break}default:this.#a[g]=w?null:f;break}}#C(g){if(this.#v.has(g))return this.#v.get(g);const f=this.#o(this.#i.rowAt(g));return f===void 0?null:f}#T(){if(this.#y&&this.#y.version===this.#b)return this.#y;const g=this.#i.physical(),f=new Array(g),w=this.#r?new _(g):null;for(let S=0;S<g;S++){const h=this.#C(S);f[S]=h,w&&!i(h)&&w.set(S)}return this.#y={version:this.#b,values:f,presence:w},this.#y}}class m{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new _(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(g,f={}){this.#e=Array.isArray(g)?g:[],this.#h=Math.max(1,f.initialCapacity??c),this.#c=f.retainSource!==!1,this.#d=this.#c?f.columnarBelow??o:0,this.#f=f.compactRatio??n;const w={rowAt:S=>this.#r[S],physical:()=>this.#o};for(const S of this.#e){if(!S||!S.id)continue;if(this.#t.has(S.id)){M(`store.dup.${S.id}`,`duplicate column id "${S.id}" in the store schema; ignoring the second`);continue}const h=new p(S,w);this.#t.set(S.id,h),this.#n.push(h)}this.#d<=0&&this.#w()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#m}get bytes(){let g=this.#a.bytes+this.#r.length*8;for(const f of this.#n)g+=f.bytes;return g}append(g){const f=this.#o;if(this.#m||!g)return{from:f,to:f};const w=g.length|0;if(w===0)return{from:f,to:f};if(this.#c)for(let h=0;h<w;h++)this.#r[f+h]=g[h];if(this.#o=f+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#w();else for(const h of this.#n)h.touch();return{from:f,to:this.#o}}this.#p(this.#o);const S=this.#n;for(let h=0;h<S.length;h++)S[h].appendColumn(g,f,w);return{from:f,to:this.#o}}appendPacked(g,f){const w=this.#o;if(this.#m||!g)return{from:w,to:w};const S=g.count|0;if(S===0)return{from:w,to:w};if(this.#c&&f)for(let d=0;d<S;d++)this.#r[w+d]=f[d];this.#o=w+S,this.#s+=S,this.#a.grow(this.#o),this.#u||this.#w(),this.#p(this.#o);const h=new Map;for(const d of g.columns)h.set(d.id,d);for(const d of this.#n){const j=h.get(d.id);j?d.appendPacked(j,w,S):d.grow(this.#i)}return{from:w,to:this.#o}}source(g){if(this.#c)return this.#r[g];if(!(g<0||g>=this.#o))return this.#g(g)}setSource(g,f){this.#m||g<0||g>=this.#o||this.#c&&(this.#r[g]=f)}get(g,f){const w=this.#t.get(g);return w?w.get(f):void 0}set(g,f,w){if(this.#m||f<0||f>=this.#o)return;const S=this.#t.get(g);if(!S){M(`store.set.${g}`,`set() on unknown column "${g}"`);return}S.set(f,w)}remove(g){return this.#m||g<0||g>=this.#o||this.#a.get(g)===1?!1:(this.#a.set(g),this.#l++,this.#s--,!0)}live(g){return g<0||g>=this.#o?!1:this.#a.get(g)===0}compact(g={}){if(this.#m||this.#l===0||!g.force&&this.#l/this.#o<this.#f)return null;const f=this.#o,w=new Uint32Array(f);let S=0;for(let h=0;h<f;h++)w[h]=this.#a.get(h)===1?y:S++;for(const h of this.#n)h.compact(w,f,S);if(this.#c){const h=this.#r;for(let d=0;d<f;d++)w[d]!==y&&(h[w[d]]=h[d]);h.length=S}return this.#o=S,this.#s=S,this.#l=0,this.#a=new _(Math.max(this.#i,S)),w}column(g){return this.#t.get(g)}columns(){return this.#n.slice()}liveIndices(){const g=new Uint32Array(this.#s);if(this.#l===0){for(let w=0;w<this.#o;w++)g[w]=w;return g}let f=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(g[f++]=w);return g}convert(g,f){const w=this.#t.get(g);return w?w.convert(f):!1}destroy(){if(!this.#m){this.#m=!0;for(const g of this.#n)g.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#p(g){if(g<=this.#i)return;let f=this.#i||this.#h;for(;f<g;)f*=2;for(const w of this.#n)w.grow(f);this.#a.grow(f),this.#i=f}#g(g){const f={};for(const w of this.#n)f[w.id]=w.get(g);return f}#w(){if(this.#u)return;let g=this.#h;for(;g<this.#o;)g*=2;this.#u=!0,this.#i=g,this.#a.grow(g);for(const f of this.#n)f.columnarise(g,this.#o)}}}),je("packages/core/src/store/pool.js",function(e,V){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const Z=64,M=8;function I(H){let B=Z;for(;B<H;)B*=2;return B}class N{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(B={}){this.#n=B.limit??M}get bytes(){return this.#r}mask(B){const G=new Uint8Array(this.#i(B),0,B);return G.fill(0),G}indices(B){return new Uint32Array(this.#i(B*4),0,B)}release(B){if(!B||!B.buffer)return!1;const G=B.buffer;if(!this.#t.has(G))return!1;this.#t.delete(G),this.#o.released++;const D=G.byteLength;let v=this.#e.get(D);return v||this.#e.set(D,v=[]),v.length>=this.#n||(v.push(G),this.#r+=D),!0}releaseAll(B){for(const G of B)this.release(G)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(B){const G=I(B),D=this.#e.get(G);this.#o.acquired++;let v;return D&&D.length?(v=D.pop(),this.#r-=G,this.#o.reused++):v=new ArrayBuffer(G),this.#t.add(v),v}}function W(){return _??=new N,_}let _=null}),je("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 M}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function Z(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function M(_){return!!_&&typeof _.compare!="function"}function I(_){if(!_)return!0;for(let H=0;H<_.length;H++)if(!M(_[H]))return!1;return!0}function N(_,H){const B=_.col!==void 0?_.col:_.handle&&_.handle.id,G=_.locale!==void 0?_.locale:H;return{col:B,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:Z(G)}}function W(_,H){const B=_||[],G=new Array(B.length);for(let D=0;D<B.length;D++)G[D]=N(B[D],H);return G}}),je("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 H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const Z=V("packages/core/src/compute/handle.js"),M=Z.presenceReader,I=Z.valueReader,N=Z.dictSize,W=Z.dictValue,_=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),B=20,G=50,D=1e4;function v(h,d){if(!h)return"none";const j=d;if(j&&(j.multi===!0||typeof j.items=="function"))return"category";const E=d&&d.base;if(E==="date"||E==="datetime"||E==="time"||E==="dateString")return"date";switch(h.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return E==="number"?"numeric":E==="boolean"?"boolean":E==="text"?"category":"none"}}function k(h){const d=h.values,j=h.kind;if((j==="float64"||j==="int32")&&d)return O=>d[O];const E=I(h);return O=>y(E(O))}function y(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(h==null||h==="")return NaN;if(typeof h=="boolean")return h?1:0;if(typeof h=="string"){const d=Number(h);if(Number.isFinite(d))return d;const j=Date.parse(h);return Number.isFinite(j)?j:NaN}return NaN}function c(h,d,j,E=G){if(!h)return{cardinality:0,exact:!0};if(h.dict)return{cardinality:N(h.dict),exact:!0};if(h.kind==="bitset")return{cardinality:2,exact:!0};const O=I(h),T=d?d.length:j,A=new Set;for(let P=0;P<T;P++){const L=O(d?d[P]:P);if(L!=null&&(A.add(L),A.size>E))return{cardinality:A.size,exact:!1}}return{cardinality:A.size,exact:!0}}const o=36e5,n=864e5;function t(h,d=B){const j=Number.isFinite(h)&&h>0?h:0,E=Math.max(1,d)*2;return j/o<=E?"hour":j/n<=E?"day":j/(7*n)<=E?"week":j/(30*n)<=E?"month":j/(91*n)<=E?"quarter":"year"}function i(h,d){if(!Number.isFinite(h))return NaN;const j=new Date(h);switch(d){case"hour":return j.setMinutes(0,0,0),j.getTime();case"day":return j.setHours(0,0,0,0),j.getTime();case"week":{j.setHours(0,0,0,0);const E=(j.getDay()+6)%7;return j.setDate(j.getDate()-E),j.getTime()}case"month":return j.setDate(1),j.setHours(0,0,0,0),j.getTime();case"quarter":return j.setMonth(Math.floor(j.getMonth()/3)*3,1),j.setHours(0,0,0,0),j.getTime();default:return j.setMonth(0,1),j.setHours(0,0,0,0),j.getTime()}}function a(h,d){const j=new Date(h);switch(d){case"hour":j.setHours(j.getHours()+1);break;case"day":j.setDate(j.getDate()+1);break;case"week":j.setDate(j.getDate()+7);break;case"month":j.setMonth(j.getMonth()+1);break;case"quarter":j.setMonth(j.getMonth()+3);break;default:j.setFullYear(j.getFullYear()+1);break}return j.getTime()}function r(h,d,j){const E=k(h),O=M(h),T=d?d.length:j;let A=1/0,P=-1/0,L=0,$=0;for(let U=0;U<T;U++){const x=d?d[U]:U;if(O&&!O(x)){L++;continue}const F=E(x);if(!Number.isFinite(F)){L++;continue}F<A&&(A=F),F>P&&(P=F),$++}return{min:A,max:P,nulls:L,finite:$}}function s(h,d,j,E){const O=k(h),T=M(h),A=d?d.length:j,P=A>E?A/E:1,L=[];for(let U=0;U<A;U+=P){const x=d?d[Math.floor(U)]:Math.floor(U);if(T&&!T(x))continue;const F=O(x);Number.isFinite(F)&&L.push(F)}const $=Float64Array.from(L);return $.sort(),$}function u(h,d,j,E={}){const O=E.kind||v(h,E.type);return O==="none"||!h?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?l(h,d,j):O==="category"?p(h,d,j,E):m(h,d,j,O,E)}function l(h,d,j){const E=M(h);let O=0;if(E){const A=d?d.length:j;for(let P=0;P<A;P++)E(d?d[P]:P)||O++}const T=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&T.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:T}}function p(h,d,j,E){const O=E.cardinalityLimit??G,{cardinality:T}=c(h,d,j,O);if(T>O&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:T};const A=I(h),P=d?d.length:j,L=new Map;let $=0;for(let z=0;z<P;z++){const q=A(d?d[z]:z);if(q==null||q===""){$++;continue}if(Array.isArray(q)){if(!q.length){$++;continue}for(const Q of q)L.set(Q,(L.get(Q)||0)+1);continue}L.set(q,(L.get(q)||0)+1)}let U=[...L.entries()];E.order==="alpha"?U.sort((z,q)=>String(z[0]).localeCompare(String(q[0]))):U.sort((z,q)=>q[1]-z[1]);let x=0,F=0;if(U.length>O){F=U.length-O;for(let z=O;z<U.length;z++)x+=U[z][1];U=U.slice(0,O)}const C=U.map(([z])=>({value:z,label:String(z)}));return x>0&&C.push({remainder:!0,label:`Other (${F} values)`}),$>0&&C.push({null:!0,label:"Empty"}),{kind:"category",buckets:C,cardinality:T}}function m(h,d,j,E,O){const{min:T,max:A,nulls:P,finite:L}=r(h,d,j);if(!L)return{kind:E,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const $=Math.max(1,Math.floor(O.buckets||B));let U=[];if(E==="date"){const F=H.includes(O.granularity)?O.granularity:t(A-T,$);let C=i(T,F);for(;C<=A&&U.length<4096;){const z=a(C,F);if(!(z>C))break;U.push({from:C,to:z}),C=z}return{kind:E,buckets:b(U,P),granularity:F}}const x=_.includes(O.strategy)?O.strategy:"equal";if(x==="quantile"){const F=s(h,d,j,D);if(F.length){const C=[F[0]];for(let z=1;z<$;z++){const q=F[Math.min(F.length-1,Math.floor(z/$*F.length))];q>C[C.length-1]&&C.push(q)}C.push(A);for(let z=0;z<C.length-1;z++)U.push({from:C[z],to:C[z+1]})}}else if(x==="log"&&T>0){const F=Math.log10(T),z=(Math.log10(A)-F)/$||1;for(let q=0;q<$;q++)U.push({from:10**(F+q*z),to:10**(F+(q+1)*z)})}if(!U.length){const F=(A-T)/$||1;for(let C=0;C<$;C++)U.push({from:T+C*F,to:T+(C+1)*F})}return U[U.length-1].to=A,{kind:E,buckets:b(U,P),strategy:x,min:T,max:A}}function b(h,d){return d>0?[...h,{null:!0,label:"Empty"}]:h}function g(h,d,j,E,O){const T=E&&E.buckets||[],A=O&&O.length>=T.length?O.subarray(0,T.length):new Uint32Array(T.length);if(A.fill(0),!h||!T.length)return A;const P=T.length-1,L=!!T[P]&&T[P].null===!0,$=d?d.length:j;if(E.kind==="boolean"){const z=I(h);for(let q=0;q<$;q++){const Q=z(d?d[q]:q);if(Q==null){L&&A[P]++;continue}A[Q?1:0]++}return A}if(E.kind==="category"){const z=new Map;for(let Y=0;Y<T.length;Y++)!T[Y].null&&!T[Y].remainder&&z.set(T[Y].value,Y);const q=T.findIndex(Y=>Y.remainder),Q=I(h);for(let Y=0;Y<$;Y++){const J=Q(d?d[Y]:Y);if(J==null||J===""){L&&A[P]++;continue}if(Array.isArray(J)){if(!J.length){L&&A[P]++;continue}for(const ee of J){const re=z.get(ee);re!==void 0?A[re]++:q>=0&&A[q]++}continue}const te=z.get(J);te!==void 0?A[te]++:q>=0&&A[q]++}return A}const U=L?T.length-1:T.length,x=new Float64Array(U+1);for(let z=0;z<U;z++)x[z]=T[z].from;x[U]=U?T[U-1].to:0;const F=k(h),C=M(h);for(let z=0;z<$;z++){const q=d?d[z]:z;if(C&&!C(q)){L&&A[P]++;continue}const Q=F(q);if(!Number.isFinite(Q)){L&&A[P]++;continue}const Y=f(x,U,Q);Y>=0&&A[Y]++}return A}function f(h,d,j){if(!d||j<h[0])return-1;if(j>=h[d])return j===h[d]?d-1:-1;let E=0,O=d-1;for(;E<O;){const T=E+O+1>>>1;j>=h[T]?E=T:O=T-1}return E}function w(h,d,j,E={}){const O=E.bounds||u(h,E.boundsIndices??d,j,E);return{bounds:O,counts:g(h,d,j,O)}}const S=w}),je("packages/core/src/compute/pivotmatrix.js",function(e,V){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return i}});const M=V("packages/core/src/compute/handle.js").valueComparator,N=V("packages/core/src/compute/total.js").total,_=V("packages/core/src/compute/group.js").packKeys,H=V("packages/core/src/compute/pivot.js"),B=H.joinPath,G=H.DEFAULT_PATH_SEPARATOR,D=H.DEFAULT_MAX_COLUMNS,v="";function k(a,r,s={}){const u=s.separator||G,l=a||[],p=r instanceof Uint32Array?r:Uint32Array.from(r||[]),m=p.length;if(l.length===0)return{tuples:[[]],paths:[v],buckets:[p]};const{keyOf:b,readers:g}=_(l,p,0),f=new Map,w=[],S=[],h=[];for(let A=0;A<m;A++){const P=p[A],L=b(P);let $=f.get(L);if($===void 0){$=w.length,f.set(L,$),S.push(L);const U=new Array(g.length);for(let x=0;x<g.length;x++)U[x]=g[x](P);w.push(U),h.push([])}h[$].push(P)}const d=M(s.locale),j=w.map((A,P)=>P);j.sort((A,P)=>{const L=w[A],$=w[P];for(let U=0;U<L.length;U++){const x=y(L[U],$[U],d);if(x!==0)return x}return A-P});const E=new Array(j.length),O=new Array(j.length),T=new Array(j.length);for(let A=0;A<j.length;A++){const P=j[A];E[A]=w[P],O[A]=B(w[P],u),T[A]=Uint32Array.from(h[P])}return{tuples:E,paths:O,buckets:T}}function y(a,r,s){const u=a==null,l=r==null;return u||l?u&&l?0:u?1:-1:s(a,r)}function c(a,r,s){const u=[];for(let l=0;l<a.length;l++)s.has(a[l])&&u.push(a[l]);return Uint32Array.from(u)}function o(a,r,s,u){return{value:r.length?N(a,r,s,u):null,leaves:r,count:r.length}}function n(a){const r=a&&a.opts||{},s=r.separator||G,u=r.totalContext||{locale:r.locale},l=(a.measures||[]).filter(O=>O&&O.handle),p=a.leaves instanceof Uint32Array?a.leaves:Uint32Array.from(a.leaves||[]),m=k(a.rowHandles||[],p,{...r,separator:s}),b=k(a.columnHandles||[],p,{...r,separator:s}),g=r.maxColumns===void 0?D:r.maxColumns,f=b.paths.length*Math.max(1,l.length),w=new Map;if(g&&f>g)return{rowAxis:m,columnAxis:b,measures:l.map(O=>({colId:O.colId,fn:O.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:f,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${f} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:f,maxColumns:g}};const S=new Map,h=new Map,d=new Map,j=new Map,E=b.buckets.map(O=>new Set(O));for(let O=0;O<b.paths.length;O++){const T=b.buckets[O],A=b.paths[O];for(const P of l)d.set(i(A,P.colId),o(P.handle,T,P.fn,u))}for(let O=0;O<m.paths.length;O++){const T=m.buckets[O],A=m.paths[O];for(const P of l)h.set(i(A,P.colId),o(P.handle,T,P.fn,u));for(let P=0;P<b.paths.length;P++){const L=c(T,b.buckets[P],E[P]);if(L.length===0)continue;const $=b.paths[P];for(const U of l)S.set(t(A,$,U.colId),o(U.handle,L,U.fn,u))}}for(const O of l)j.set(O.colId,o(O.handle,p,O.fn,u));return{rowAxis:m,columnAxis:b,measures:l.map(O=>({colId:O.colId,fn:O.fn})),body:S,rowMargin:h,columnMargin:d,grand:j,columns:f,error:null}}function t(a,r,s){return`${a}\0${r}\0${s}`}function i(a,r){return`${a}\0${r}`}}),je("packages/core/src/compute/reference.js",function(e,V){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return n}});const M=V("packages/core/src/internal/util.js").getPath,I=V("packages/core/src/compute/handle.js"),N=I.isMissing,W=I.valueComparator,H=V("packages/core/src/compute/filter.js").testValue,B="",G="\0";function D(a,r){const s=r.includes(".")?M(a,r):a?.[r];return s===void 0?null:s}function v(a,r,s={}){const u=r||[];let l=a.map((p,m)=>m);if(u.length===0)return l;for(let p=u.length-1;p>=0;p--)l=k(a,l,u[p],s);return l}function k(a,r,s,u){const l=s.locale!==void 0?s.locale:u.locale,p=W(l),m=s.descending!==void 0?!!s.descending:s.dir==="desc",b=[],g=[];for(const S of r){const h=D(a[S],s.col);N(h)?g.push(S):b.push(S)}const f=new Map;for(let S=0;S<b.length;S++)f.set(b[S],S);const w=(S,h)=>{const d=D(a[S],s.col),j=D(a[h],s.col);let E;return typeof s.compare=="function"?(E=s.compare(d,j,a[S],a[h],m),m&&(E=-E)):E=m?p(j,d):p(d,j),E!==0?E:f.get(S)-f.get(h)};return b.sort(w),s.nullsFirst?g.concat(b):b.concat(g)}function y(a,r,s={}){const u=[];for(let l=0;l<a.length;l++)c(a[l],r,s,l)&&u.push(l);return u}function c(a,r,s,u){if(!r)return!0;if(Array.isArray(r.conditions)){const l=r.conditions.filter(m=>m!=null);if(l.length===0)return!0;if(r.op==="or")return l.some(m=>c(a,m,s,u));const p=l.every(m=>c(a,m,s,u));return r.op==="not"?!p:p}return r.col===void 0&&typeof s.custom=="function"?!!s.custom(r,a,u):H(D(a,r.col),r,s.locale)}function o(a,r,s,u){const l=s||a.map((g,f)=>f),p=new Map,m=[],b=[];for(const g of l){const f=r.map((h,d)=>{const j=D(a[g],h);return u&&u[d]?u[d](j):j}),w=f.map(h=>h==null?G:String(h)).join(B);let S=p.get(w);S===void 0&&(S=m.length,p.set(w,S),m.push(f),b.push([])),b[S].push(g)}return{keys:m,buckets:b}}function n(a,r,s={}){const u=W(s.locale),l=a.filter(m=>!N(m)),p=l.map(t).filter(m=>m!==null);switch(r){case"count":return a.length;case"countValues":return l.length;case"sum":return p.reduce((m,b)=>m+b,0);case"avg":return l.length===0?null:p.reduce((m,b)=>m+b,0)/l.length;case"min":return l.length===0?null:l.reduce((m,b)=>u(b,m)<0?b:m);case"max":return l.length===0?null:l.reduce((m,b)=>u(b,m)>0?b:m);case"first":return a.length===0?null:i(a[0]);case"last":return a.length===0?null:i(a[a.length-1]);default:return null}}function t(a){if(typeof a=="number")return Number.isNaN(a)?null:a;if(a==null||a===""||typeof a=="boolean")return null;if(a instanceof Date)return a.getTime();const r=Number(a);return Number.isNaN(r)?null:r}function i(a){return a===void 0?null:a}}),je("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 M=V("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return M.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return M.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return M.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return M.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return M.describeSort}});const I=V("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return I.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return I.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return I.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return I.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return I.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return I.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return I.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return I.mentionsColumn}});const N=V("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return N.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return N.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 H=V("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const 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 G=V("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return G.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return G.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return G.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return G.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return G.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return G.referenceValue}});const D=V("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return D.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return D.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return D.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return D.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return D.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return D.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return D.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return D.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return D.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return D.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return D.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return D.isMissing}});const v=V("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return v.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return v.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return v.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return v.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return v.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return v.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return v.SKETCH_BOUNDS}});const k=V("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return k.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return k.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return k.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 c=V("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return c.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return c.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return c.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c.anomalyCondition}});const 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}})}),je("packages/core/src/source/rows.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return N}}),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 H}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isFunction,N=32,W="\0";function _(o){return new H(o)}class H{#e;#t;constructor(n){this.#e=I(n&&n.rowKey)?n.rowKey:null;const t=n&&n.config?n.config.rowHeight:void 0;this.#t=typeof t=="number"||I(t)?t:N}get keyed(){return this.#e!==null}keyOf(n,t){if(this.#e){const i=this.#e(n);if(i!=null)return String(i)}else M("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(n){return I(this.#t)?Number(this.#t(n))||N:this.#t}leaf(n,t,i=0,a=null){const r={key:this.keyOf(n,t),data:n,level:i,parent:a,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return r.height=this.heightOf(r),r}group(n){const t={key:y(n.keyPath||n.path),data:null,level:n.level,parent:n.parent||null,children:[],group:!0,expanded:n.expanded!==!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.column,groupValue:n.value,groupPath:n.path,hasChildren:n.hasChildren!==!1};return n.totals&&(t.totals=n.totals),t.height=this.heightOf(t),t}footer(n){const t={key:`${n.key}${W}footer`,data:null,level:n.level,parent:n,group:!0,footer:!0,expanded:!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.groupColumn,groupValue:n.groupValue,groupPath:n.groupPath,hasChildren:!1,totals:n.totals};return t.height=this.heightOf(t),t}detail(n,t){return{key:`${n.key}${W}detail`,data:n.data,level:n.level+1,parent:n,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:n.key}}grandTotal(n,t){const i={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:n};return i.height=this.heightOf(i),i}skeleton(n,t=0){const i={key:`${W}pending${W}${n}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:n,selected:!1,physical:null};return i.height=this.heightOf(i),i}}function B(o,n,t,i){return{key:`${W}pinned${W}${t}${W}${n}`,data:o,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function G(o,n){return new Proxy([],{get(t,i,a){if(i==="length")return o();if(typeof i=="string"){const r=Number(i);if(Number.isInteger(r)&&r>=0)return n(r)}return Reflect.get(t,i,a)},has(t,i){if(typeof i=="string"){const a=Number(i);if(Number.isInteger(a)&&a>=0)return a<o()}return Reflect.has(t,i)}})}function D(o){return o==null?"":String(o)}const v="";function k(o){if(o==null)return v;const n=String(o);return n.startsWith(v)?v+n:n}function y(o){const n=o||[];let t="g";for(let i=0;i<n.length;i++)t+=W+k(n[i]);return t}function c(o){const n=new Array(o.length),t=[];for(let i=0;i<o.length;i++)t.push(o[i]),n[i]=y(t);return n}}),je("packages/core/src/source/handles.js",function(e,V){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce;class N{#e;#t;#n;#r=new Map;#o=0;constructor(H,B,G){this.#e=H,this.#t=B,this.#n=M(G)?G:()=>!1}get store(){const H=this.#e.store;return H&&M(H.column)?H:null}invalidate(){this.#o++}handle(H){const B=this.store;if(B){const k=B.column(H);if(k)return k}const G=this.#r.get(H);if(G&&G.builtAt===this.#o)return G.handle;const D=this.#i(H);if(!D)return;if(B&&this.#n()){I(`source.dropped.${H}`,`column "${H}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const v=this.#s(D);return this.#r.set(H,{handle:v,builtAt:this.#o}),v}#i(H){const B=this.#e.columns;return B&&M(B.get)?B.get(H):void 0}#s(H){const B=this.#t()||[],G=B.length,D=new Array(G),v=M(H.getValue)?y=>H.getValue(y):y=>y?.[H.field||H.id];for(let y=0;y<G;y++)D[y]=B[y]===void 0?void 0:v(B[y]);const k=this.#o;return{id:H.id,kind:"object",nullable:!1,values:D,presence:null,dict:null,offsets:null,get(y){return D[y]},version:k}}}function W(_,H,B){return new N(_,H,B)}}),je("packages/core/src/compute/incremental.js",function(e,V){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return N}}),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 G}});const M=V("packages/core/src/store/columnstore.js").toFloat,I=Object.freeze(["sum","avg","countValues","min","max"]),N=Object.freeze(["float64"]),W=1e15;function _(D,v){return typeof D!="string"||!I.includes(D)?!1:!!v&&N.includes(v.kind)}function H(D){if(D==null)return null;const v=M(D);return Number.isNaN(v)?null:v}class B{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(v){this.#e=v}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(v){this.#a();for(let k=0;k<v.length;k++){const y=H(v[k]);y!==null&&this.#u(y)}this.#s=!0}seedColumn(v,k,y){this.#a();for(let c=0;c<y.length;c++){const o=y[c];if(k&&k(o)===0)continue;const n=v[o];Number.isNaN(n)||this.#u(n)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(v){if(!Number.isFinite(v)){this.#l=!0;return}const k=this.#t+v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-k+v:v-k+this.#t,this.#t=k,this.#r++,v<this.#o&&(this.#o=v),v>this.#i&&(this.#i=v)}#c(v){const k=this.#t-v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-k-v:-v-k+this.#t,this.#t=k,this.#r--}update(v,k){if(!this.#s)return!1;const y=H(v),c=H(k);return y===null&&c===null?!0:y!==null&&!Number.isFinite(y)||c!==null&&!Number.isFinite(c)?!1:this.#e==="min"||this.#e==="max"?y===null||c===null?!1:this.#e==="min"?c<this.#o?(this.#o=c,!0):y>this.#o:c>this.#i?(this.#i=c,!0):y<this.#i:Math.abs(this.#t)>W?!1:(y!==null&&this.#c(y),c!==null&&this.#u(c),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const G=B}),je("packages/core/src/source/filterwire.js",function(e,V){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return N}}),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 H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return d}});const M=V("packages/core/src/internal/util.js").warnOnce,I="source.remote.hostFilter",N="source.where.pageRelative";function W(O,T){!Array.isArray(O)||!O.length||M(N,`filters.where (${O.join(", ")}) runs over the rows the ${T} 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 _(O){const T=(O||{}).config;!T||!T.hostFilter||M(I,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function B(O,T){M(`${H}:${O}`,`filters.where("${O}") is registered but the ${T} 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 G="source.where.overThreshold";function D(O,T,A,P){!Array.isArray(O)||!O.length||M(`${G}:${T}`,`filters.where (${O.join(", ")}) is not applied to the ${T} pushdown source:`,A===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${A.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 v=new Map;function k(O){let T=v.get(O);return T||(T=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),v.set(O,T)),T}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function c(O,T){const A=k(T).formatToParts(new Date(O)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of A)L.type==="year"?P.y=+L.value:L.type==="month"?P.m=+L.value:L.type==="day"?P.d=+L.value:L.type==="hour"?P.h=+L.value%24:L.type==="minute"?P.mi=+L.value:L.type==="second"&&(P.s=+L.value);return P}function o(O,T){const A=c(O,T);return Date.UTC(A.y,A.m-1,A.d,A.h,A.mi,A.s)-Math.floor(O/1e3)*1e3}function n(O,T,A,P){const L=Date.UTC(O,T-1,A),$=L-o(L,P);return L-o($,P)}function t(O,T,A){const P=new Date(Date.UTC(O.y,O.m-1,O.d+T));return n(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),A)}const i=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function a(O,T){if(typeof O!="string")return null;const A=O.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(A);if(P){const L=P[1]==="n"?"":P[1],$=Number(L||T);return!Number.isFinite($)||$<=0?null:{kind:"lastNDays",n:Math.floor($)}}switch(A){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 r(O,T={}){const A=a(O,T.n);if(!A)return null;const P=T.tz||y(),L=T.now instanceof Date?T.now.getTime():typeof T.now=="number"?T.now:Date.now(),$=c(L,P),U=n($.y,$.m,$.d,P),x=t($,1,P);let F=U,C=x;switch(A.kind){case"today":break;case"yesterday":F=t($,-1,P),C=U;break;case"lastNDays":C=T.includeToday?x:U,F=t($,T.includeToday?-(A.n-1):-A.n,P);break;case"thisWeek":{const z=Number.isFinite(T.weekStartsOn)?Number(T.weekStartsOn):1,Q=(new Date(Date.UTC($.y,$.m-1,$.d)).getUTCDay()-z+7)%7;F=t($,-Q,P),C=t($,-Q+7,P);break}case"thisMonth":F=n($.y,$.m,1,P),C=n($.m===12?$.y+1:$.y,$.m===12?1:$.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const z=Math.floor(($.m-1)/3)*3+1;F=n($.y,z,1,P),C=A.kind==="quarterToDate"?x:z===10?n($.y+1,1,1,P):n($.y,z+3,1,P);break}case"thisYear":case"yearToDate":F=n($.y,1,1,P),C=A.kind==="yearToDate"?x:n($.y+1,1,1,P);break;default:return null}return{from:new Date(F).toISOString(),to:new Date(C).toISOString(),bounds:"[)",tz:P,relative:A.kind==="lastNDays"?`last${A.n}Days`:A.kind,n:A.n}}function s(O){if(!O||typeof O!="object")return null;const T=O.value;if(T&&typeof T=="object"&&!Array.isArray(T)&&"relative"in T)return{token:String(T.relative),n:typeof T.n=="number"?T.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const A=O.meta;return A&&typeof A.relative=="string"&&O.value===void 0?{token:A.relative,n:typeof A.n=="number"?A.n:void 0}:null}function u(){return`Known tokens: ${i.filter(T=>T!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function l(O){const T=s(O);return T?a(T.token,T.n)!==null:!1}function p(O,T={}){const A=s(O);if(!A)return O;const P=r(A.token,{...T,n:A.n});return P?{...O,type:O.type||"date",op:"between",value:[P.from,P.to],bounds:O.bounds||P.bounds,meta:{...O.meta||{},relative:P.relative,tz:P.tz}}:(M(`source.relative.${A.token}`,`unknown relative date token "${A.token}"; sending the condition unresolved.`,u()),O)}function m(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function b(O,T){if(O){if(m(O)){for(const A of O.conditions)b(A,T);return}T(O)}}function g(O,T){if(!O)return null;if(!m(O))return T(O);const A=O;let P=!1;const L=[];for(const $ of A.conditions){const U=g($,T);U!==$&&(P=!0),U&&L.push(U)}return!P&&L.length===A.conditions.length?O:L.length?{...A,conditions:L}:null}function f(O){if(!O)return null;if(!m(O))return O;const T=O,A=[];for(const P of T.conditions){const L=f(P);L&&A.push(L)}return A.length?{op:T.op,conditions:A}:null}function w(O){const T=f(O);return T?m(T)&&T.op==="and"?T:{op:"and",conditions:[T]}:null}function S(O){const T=(O||[]).filter(Boolean);return T.length?{op:"and",conditions:T}:null}function h(O,T={}){const A=g(O,P=>p(P,T));return w(A)}function d(O){const T=j(O.filters??null);return JSON.stringify([T,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,E(O.context)])}function j(O){if(!O)return null;if(m(O)){const P=O;return{op:P.op,conditions:P.conditions.map(j)}}const T=O,A=T.meta&&typeof T.meta.relative=="string"?T.meta.relative:s(T)?.token;return{col:T.col,op:T.op,bounds:T.bounds??null,caseSensitive:T.caseSensitive??!1,value:A?`rel:${A}`:T.value??null}}function E(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return M("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),je("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 H}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N="",W="\0tree:";function _(c,o){return{physical:c,key:o,level:0,children:[],value:void 0}}function H(c,o){const n=[],t=new Map;for(let i=0;i<c.length;i++){const a=c[i],r=o.pathOf(a),s=Array.isArray(r)?r.map(l=>String(l)):[];if(!s.length){const l=_(a,o.keyOf(a));n.push(l);continue}let u=null;for(let l=0;l<s.length;l++){const p=s.slice(0,l+1).join(N),m=l===s.length-1;let b=t.get(p);b&&m&&b.physical===-1&&(b.physical=a,b.key=o.keyOf(a)),b||(b=_(m?a:-1,m?o.keyOf(a):W+p),b.level=l,b.value=s[l],t.set(p,b),u?u.children.push(b):n.push(b)),u=b}}return{roots:n,nodes:t}}function B(c,o){const n=new Map,t=[];for(let s=0;s<c.length;s++){const u=c[s],l=o.keyOf(u),p=_(u,l);n.set(l,p);const m=o.parentOf(u);m!=null&&m!==""&&t.push({node:p,parent:String(m)})}let i=null;const a=new Map;for(const{node:s,parent:u}of t){const l=n.get(u);if(l){a.set(s.key,l);continue}o.orphans&&o.orphans!=="root"&&(i||(i=_(-1,`${W}orphans`),i.value=o.orphans),a.set(s.key,i))}const r=[];for(const s of n.values()){const u=a.get(s.key);u?u.children.push(s):r.push(s)}return i&&i.children.length&&r.push(i),{roots:G(r,n,o.orphans,i),nodes:n}}function G(c,o,n,t){const i=new Set,a=[...c];for(;a.length;){const p=a.pop();if(!i.has(p.key)){i.add(p.key);for(const m of p.children)a.push(m)}}const r=[];for(const p of o.values())i.has(p.key)||r.push(p);if(!r.length)return c;const s=!!n&&n!=="root";I("tree.cycle",`tree.parentKey produced ${r.length} row(s) inside a parent cycle; `+(s?`they are shown under "${n}".`:"they are shown at the root."));for(const p of r)p.children=p.children.filter(m=>i.has(m.key));if(!s)return[...c,...r];let u=t;const l=[...c];return u||(u=_(-1,`${W}orphans`),u.value=n,l.push(u)),u.children.push(...r),l}function D(c){let o=0;const n=(t,i)=>{for(const a of t)a.level=i,i>o&&(o=i),a.children.length&&n(a.children,i+1)};return n(c,0),o}function v(c,o){if(!c||typeof c!="object")return null;const n=c.path,t=c.parentKey,i=M(c.hasChildren)?a=>!!c.hasChildren(o.dataAt(a)):null;if(M(n))return{mode:"path",pathOf:a=>n(o.dataAt(a)),keyOf:o.keyOf,declaresChildren:i};if(t!=null){const a=M(t)?t:r=>r?.[t];return{mode:"parentKey",parentOf:r=>a(o.dataAt(r)),keyOf:o.keyOf,orphans:c.orphans||"root",declaresChildren:i}}return I("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function k(c,o){const n=o.mode==="path"?H(c,o):B(c,o),t=D(n.roots);return{...n,depth:t}}function y(c,o){const n=new Map,t=i=>{for(let a=0;a<i.length;a++){const r=i[a];if(r.physical>=0){const s=o?o(r.physical):!1,u=s&&r.children.length===0;n.set(r.physical,{level:r.level,posinset:a+1,setsize:i.length,hasChildren:r.children.length>0||s,lazy:u})}r.children.length&&t(r.children)}};return t(c),n}}),je("packages/core/src/source/memory.js",function(e,V){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return x}});const Z=V("packages/core/src/internal/util.js"),M=Z.Lru,I=Z.warnOnce,N=Z.fail,W=Z.isFunction,_=Z.defaultCompare,H=Z.mergeRow,B=V("packages/core/src/source/rows.js"),G=B.createRowFactory,D=B.groupKey,v=B.groupPathElement,k=B.groupPrefixKeys,y=B.lazyRowView,o=V("packages/core/src/source/handles.js").createHandleProvider,n=V("packages/core/src/compute/incremental.js"),t=n.RunningTotal,i=n.isIncremental,r=V("packages/core/src/compute/handle.js").presenceReader,s=V("packages/core/src/source/filterwire.js"),u=s.querySignature,l=s.mapConditions,p=s.resolveRelativeCondition,m=V("packages/core/src/source/tree.js"),b=m.buildTree,g=m.resolveTree,f=m.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),S=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function h(F){const C=F&&typeof F=="object"?F.reason:null;return typeof C=="string"&&S.includes(C)}const d=Object.freeze([]);function j(F,C){if(!F)return null;const z=C==="grand"?F.grandTotal:F.groupTotal;return z??F.total}function E(F){return!!F&&!F.running}function O(F){if(F)return F.value&&W(F.value.compare)?F.value.compare:W(F.compare)?F.compare:void 0}function T(F){const C=F&&F.dataType;return!C||!W(C.items)?null:{items:C.items,type:F.itemType&&F.itemType.name||"text"}}function A(F){return!!F&&(typeof F=="object"||typeof F=="function")&&W(F.then)}const P=new Uint32Array(0),L=4096;function $(F,C){return new x(F,C)}function U(F,C){if(C==="regex")try{const z=new RegExp(F,"iu");return q=>z.test(q)}catch{return z=>z.includes(F)}if(C==="fuzzy"){const z=[...F].filter(q=>q!==" ");return z.length?q=>{let Q=0;for(let Y=0;Y<q.length&&Q<z.length;Y++)q[Y]===z[Q]&&Q++;return Q===z.length}:()=>!0}if(C==="words"){const z=F.split(/\s+/).filter(Boolean);return z.length?q=>z.every(Q=>q.includes(Q)):()=>!0}return z=>z.includes(F)}class x{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=x.#g();static#g(){return{slots:[],groupHeadings:d,unnumbered:d,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#w=new Map;#b=null;#v=new Map;#y=-1;#S=[];#A=new Map;#j=-1;#O=[];#E=null;#C=null;#T=null;#I=null;#N=null;#D=null;#M=null;#x=null;#W=Symbol("unset");#R=new Map;#_=null;get#B(){return this.#p.slots}set#B(C){this.#p.slots=C}get#H(){return this.#p.inlineLeaves}set#H(C){this.#p.inlineLeaves=C}get#ne(){return this.#p.groupHeadings}set#ne(C){this.#p.groupHeadings=C}get#ae(){return this.#p.unnumbered}set#ae(C){this.#p.unnumbered=C}get#le(){return this.#p.pivot}set#le(C){this.#p.pivot=C}constructor(C,z){this.#t=C||{mode:"memory"},this.#e=z||{};const q=this.#e.config||{};this.#n=this.#t.rows||q.rows||[],this.#i=G(this.#e),this.#s=o(this.#e,()=>this.#n,()=>this.#r),this.#f=new M(Number(q.rowCacheSize)||L);for(const Q of w)this.#l.set(Q,{key:null,result:null,id:0,computed:!1})}count(){this.#ee();const C=this.#de();return C?C.length:this.#B.length}#de(){const C=Number(this.#$("pageSize",0))||0;if(C<=0)return null;const z=this.#B.length,q=Math.max(1,Math.ceil(z/C)),Y=Math.min(Math.max(0,Number(this.#$("page",0))||0),q-1)*C;return{offset:Y,length:Math.max(0,Math.min(C,z-Y))}}pageInfo(){this.#ee();const C=Number(this.#$("pageSize",0))||0,z=this.#B.length;if(C<=0)return{page:0,pageSize:0,total:z,pageCount:1};const q=Math.max(1,Math.ceil(z/C));return{page:Math.min(Math.max(0,Number(this.#$("page",0))||0),q-1),pageSize:C,total:z,pageCount:q}}totalCount(){return this.#$e().length}matchCount(){return this.#ee(),this.#p.matchCount}at(C){this.#ee();const z=this.#de();if(z)return C<0||C>=z.length?void 0:this.#st(z.offset+C,C);if(!(C<0||C>=this.#B.length))return this.#st(C,C)}byKey(C){this.#ee(),this.#m||this.#G();const z=this.#m.get(C);if(z!==void 0)return this.#Ae(z);for(let q=0;q<this.#B.length;q++){const Q=this.#B[q];if(typeof Q!="number"&&Q&&Q.key===C)return this.#st(q)}}loaded(C){return C>=0&&C<this.count()}hint(C,z){}display(){return this.#ee(),this.#_||(this.#_=this.#wt()),this.#_}invalidateQuickText(){this.#R.clear(),this.invalidate("filter")}invalidate(C){const z=w.indexOf(C);z<0&&N(`unknown pipeline stage "${C}"; expected one of ${w.join(", ")}`);for(let q=z;q<w.length;q++){const Q=this.#l.get(w[q]);Q.key=null,Q.computed=!1}this.#_=null}apply(C){const z=[],q={added:[],updated:[],removed:[],rejected:z};if(!C)return q;let Q=!1;const Y=new Set;if(C.remove&&C.remove.length)for(const J of C.remove){const te=this.#q(J);if(te===void 0){z.push({operation:"remove",id:this.#z(J),reason:"unknown-id"});continue}q.removed.push(this.#i.keyOf(this.#r?this.#Ye(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#f.delete(te),this.#R.delete(te),Q=!0}if(C.update&&C.update.length){const J=this.#v.size||this.#it()?this.#Xe():null,te=this.#A.size?this.#qe():null,ee=te&&te.length?this.#Xe():null;for(const re of C.update){const se=this.#q(re);if(se===void 0){z.push({operation:"update",id:this.#Z(re),reason:"unknown-id"});continue}const de=this.#r?this.#o&&this.#o.has(se)?this.#o.get(se):this.#Ye(se):this.#n[se],ie=H(de,re);for(const oe of this.#me(de,ie))Y.add(oe);if(this.#r||(this.#n[se]=ie),J&&this.#ke(J,se,de,ie),ee&&this.#yt(te,ee,se,de,ie),this.#m){const oe=this.#i.keyOf(de,se),ue=this.#i.keyOf(ie,se);oe!==ue&&(this.#m.delete(oe),this.#m.set(ue,se))}this.#f.delete(se),this.#R.delete(se),q.updated.push(this.#Ae(se))}}if(C.add&&C.add.length&&this.#r){typeof C.at=="number"&&C.at<this.#Ze()&&(this.#f.clear(),this.#R.clear()),this.#m=null;for(const J of C.add){const te=this.#K(this.#Z(J));te!==void 0&&q.added.push(this.#Ae(te))}Q=!0}else if(C.add&&C.add.length){const J=typeof C.at=="number"?C.at:this.#n.length,te=this.#n.length;let ee=C.add===this.#n?C.add.slice():C.add;if(this.#i.keyed){const re=[];for(const se of ee){const de=this.#Z(se);if(this.#q(de)!==void 0){z.push({operation:"add",id:de,reason:"duplicate-id"});continue}re.push(se)}re.length!==ee.length&&(ee=re)}if(!ee.length)return q;if(J>=te)for(let re=0;re<ee.length;re++)this.#n.push(ee[re]);else this.#n.splice(J,0,...ee),this.#f.clear(),this.#R.clear();for(let re=0;re<ee.length;re++)q.added.push(this.#Ae(J>=te?te+re:J+re));Q=!0}return this.#u++,Q&&(this.#m=null,this.#Je()),this.#s.invalidate(),this.#_=null,Q||this.#Me(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Ue("rows:changed",{companion:!0,added:q.added.length,updated:q.updated.length,removed:q.removed.length}),this.#o=null,q}groupHeadingsAt(C){this.#ee();const z=this.#ne;if(!z.length||!Number.isInteger(C)||C<0)return d;let q=0,Q=z.length-1,Y=-1;for(;q<=Q;){const te=q+Q>>1;z[te].at<=C?(Y=te,q=te+1):Q=te-1}if(Y<0)return d;const J=[];for(let te=z[Y].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(C){this.#ee();const z=this.#ae;if(!z.length||!Number.isInteger(C)||C<0)return 0;let q=0,Q=z.length-1,Y=-1;for(;q<=Q;){const J=q+Q>>1;z[J].at<=C?(Y=J,q=J+1):Q=J-1}return Y+1}moveRow(C,z){if(this.#r)return I("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const q=this.#n;if(!Number.isInteger(C)||!Number.isInteger(z)||C<0||C>=q.length)return!1;const Q=Math.max(0,Math.min(q.length-1,z));if(Q===C)return!1;const[Y]=q.splice(C,1);return q.splice(Q,0,Y),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#R.clear(),this.#Je(),this.#s.invalidate(),this.#_=null,this.invalidate("filter"),this.#Ue("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(C){this.#ie(),this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter"),this.#Ue("model:changed",{reason:"reload"})}destroy(){this.#ie(),this.#f.clear(),this.#R.clear(),this.#m=null,this.#B=[],this.#H=null,this.#_=null,this.#Je();for(const C of w)this.#l.set(C,{key:null,result:null,id:0,computed:!1})}#ie(){for(const{controller:C}of this.#w.values())try{C.abort()}catch{}this.#w.clear()}setRows(C){this.#n=C||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(C){this.#o=C||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#R.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const C=this.#e.store;if(!C||!W(C.source))return this.#n;const z=C.physical||0,q=new Array(z);for(let Q=0;Q<z;Q++)q[Q]=C.live&&!C.live(Q)?void 0:C.source(Q);return q}#oe(){const C=this.#$("detail",null);return!C||!W(C.isOpen)||C.inline===!1?null:C}#te(){const C=(this.#e.config||{}).tree;return this.#W!==C&&(this.#W=C,this.#x=g(C,{dataAt:z=>this.#Ye(z),keyOf:z=>this.#i.keyOf(this.#Ye(z),z)})),this.#x}#V(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#V())return null;this.#ee();const C=this.#p.grand;return C?this.#i.grandTotal(C,this.#he(this.#p.grandLeaves)):null}pivot(){return this.#ee(),this.#le}pivotMatrix(){this.#ee();const C=this.#p.groupLeaves,z=(this.#e.compute||{}).pivotMatrix;if(!W(z))return null;const q=this.#$("groupBy",[]),Q=this.#$("pivotBy",[]);if(!q.length&&!Q.length)return null;const Y=this.#Xe().map(te=>({colId:te.id,handle:this.#s.handle(te.id),fn:j(te,"group")})).filter(te=>te.handle&&te.fn),J=this.#e.config||{};return z({rowHandles:q.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:Q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Y,leaves:C||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(C){const z=[];if(!C)return z;for(let q=0;q<C.length;q++){const Q=this.#Ae(C[q]);Q&&Q.key!=null&&z.push(String(Q.key))}return z}leavesOf(C){this.#ee();const z=this.#l.get("group"),q=z&&z.result;if(!q||!q.nodes)return[];const Q=q.nodes.get(C);if(!Q)return[];const Y=[],J=te=>{const ee=te.row&&te.row.children;if(ee&&ee.length){for(const re of ee){const se=q.nodes.get(re.key);se&&J(se)}return}if(te.leaves)for(let re=0;re<te.leaves.length;re++)Y.push(this.#Ae(te.leaves[re]))};return J(Q),Y}#z(C){return typeof C=="string"?C:this.#Z(C)}#Z(C){try{return this.#i.keyOf(C,-1)}catch{return"(unkeyed)"}}#q(C){if(typeof C=="string")return this.#K(C);if(this.#i.keyed){const q=this.#i.keyOf(C,-1),Q=this.#K(q);if(Q!==void 0)return Q}if(this.#r)return;const z=this.#n.indexOf(C);return z>=0?z:void 0}#K(C){return this.#m||this.#G(),this.#m.get(C)}#G(){this.#m=new Map;const C=this.#Ze(),z=this.#e.store,q=z&&W(z.live)?Q=>z.live(Q):null;for(let Q=0;Q<C;Q++){if(q&&!q(Q))continue;const Y=this.#Ye(Q);Y!==void 0&&this.#m.set(this.#i.keyOf(Y,Q),Q)}}#me(C,z){const q=[];for(const Q of this.#we())this.#Le(Q)&&this.#be(Q,C,z,new Set)&&q.push(Q);return q}#be(C,z,q,Q){if(Q.has(C))return!1;Q.add(C);const Y=this.#Le(C);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#be(String(te),z,q,Q)):W(Y.getValue)?!Object.is(Y.getValue(z),Y.getValue(q)):!1}#we(){const C=new Set;for(const q of this.#$("sort",[]))C.add(q.col);for(const q of this.#$("groupBy",[]))C.add(q);const z=q=>{if(q){if(Array.isArray(q.conditions)){q.conditions.forEach(z);return}q.col&&C.add(q.col)}};return z(this.#$("filters",null)),[...C]}#Me(C){if(!C.size)return!1;if(this.#$("quick",""))return!0;for(const z of this.#we())if(C.has(z))return!0;return!1}#ee(){if(!this.#a){this.#a=!0;try{this.#fe()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#fe(){const C=this.#Y("filter",()=>this.#Ee(),()=>this.#ve()),z=this.#pe(C),q=this.#Y("group",()=>this.#je(),()=>this.#Ne(z)),Q=this.#Y("total",()=>this.#xe(),()=>this.#Ke(q));this.#Y("pivot",()=>this.#De(),()=>this.#bt(q)),this.#Y("flatten",()=>this.#ze(),()=>this.#_e(q)),this.#se(q,Q)}#pe(C){const z=this.#l.get("sort"),q=this.#Te();if(z.computed&&z.key===q&&!this.#w.has("sort"))return z.result;const Q=this.#w.get("sort");return Q&&Q.key===q?z.result:z.result&&this.#U(C)?(this.#L(C,q),z.result):this.#Y("sort",()=>q,()=>this.#Ie(C))}#ge(){if(this.#b===null){const C=this.#e.pipelineWorker,z=W(C)?C():null;this.#b=z||!1}return this.#b||null}#ue(){const C=this.#$("sort",[]);if(!Array.isArray(C)||!C.length)return null;const z=(this.#e.config||{}).locale,q=[],Q=[];for(const Y of C){const J=this.#Le(Y.col);if(J&&J.running)continue;if(J&&J.value&&W(J.value.compare))return null;const te=this.#s.handle(Y.col);if(!te)return null;q.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:z}),Q.push(te)}return q.length?{entries:q,handles:Q,locale:z}:null}#U(C){const z=this.#ge();if(!z)return!1;const q=Number(z.threshold);return Number.isFinite(q)&&C.length<q?!1:!!this.#ue()}#L(C,z){const q=this.#ge(),Q=q&&this.#ue();if(!Q){this.#Y("sort",()=>z,()=>this.#Ie(C));return}const Y=new AbortController;this.#w.set("sort",{key:z,controller:Y});const J=Q.entries.length===1?q.sortColumn(Q.handles[0],C,{descending:Q.entries[0].descending,nullsFirst:Q.entries[0].nullsFirst,locale:Q.locale,signal:Y.signal,key:"sort"}):q.sortMulti(Q.handles,Q.entries.map((te,ee)=>({...te,handle:Q.handles[ee]})),C,{signal:Y.signal,key:"sort"});if(!A(J)){this.#w.delete("sort"),this.#Y("sort",()=>z,()=>J);return}J.then(te=>this.#Oe(z,te),te=>this.#re("sort",z,te))}#Oe(C,z){const q=this.#w.get("sort");if(!(!q||q.key!==C)){if(this.#Te()!==C){this.#w.delete("sort");return}this.#w.delete("sort"),this.#Y("sort",()=>C,()=>z),this.#_=null,this.#ee(),this.#Ue("model:changed",{reason:S[0]})}}#re(C,z,q){const Q=this.#w.get(C);if(!(!Q||Q.key!==z)&&(this.#w.delete(C),!(q&&q.name==="AbortError")&&C==="sort"&&this.#Te()===z)){const Y=this.#Y("filter",()=>this.#Ee(),()=>this.#ve());this.#Y("sort",()=>z,()=>this.#Ie(Y)),this.#_=null,this.#ee(),I("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",q),this.#Ue("model:changed",{reason:S[1]})}}#se(C,z){const q=C&&C.leaves?C.leaves.length:this.#p.slots.length;this.#p.matchCount=q,this.#p.grand=z&&z.grand||null,this.#p.grandLeaves=C&&C.leaves?C.leaves.length:0,this.#p.groupLeaves=C&&C.leaves?C.leaves:null}#Y(C,z,q){const Q=this.#l.get(C),Y=z();return Q.computed&&Q.key===Y||(Q.result=q(),Q.key=Y,Q.computed=!0,Q.id++,C==="flatten"&&(this.#_=null)),Q.result}#k(C){return this.#l.get(C).id}#Ee(){const C=(this.#e.config||{}).hostFilter,z=C&&W(C.active)&&C.active()?1:0,q=this.#$("where",null),Q=q?q.version:0,Y=this.#ut("filter.sig",`${this.#Qe()}`,()=>u({filters:this.#$("filters",null),quick:this.#$("quick",""),quickMode:this.#$("quickMode","contains")}));return`${this.#c}|${Y}|${z}|${Q}`}#Te(){return`${this.#k("filter")}|${JSON.stringify(this.#$("sort",[]))}`}#je(){return`${this.#k("sort")}|${JSON.stringify(this.#$("groupBy",[]))}`}#xe(){const C=this.#Se()?"f":"a",z=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#k("group")}|${JSON.stringify(this.#$("totals",[]))}|${C}${z}|${this.#u}`}#De(){return`${this.#k("group")}|${JSON.stringify(this.#$("pivotBy",[]))}`}#ze(){const z=this.#Ge()||!this.#V()?this.#k("total"):"x",q=`${this.#Qe()}`,Q=this.#ut("flatten.keys",q,()=>{const J=this.#$("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#ut("flatten.detail",q,()=>{const J=this.#$("detail",null);return J&&W(J.signature)?J.signature():""});return`${z}|${this.#k("pivot")}|${Q}|${Y}`}#Ge(){const C=this.#$("groupBy",[]);return Array.isArray(C)&&C.length>0}stageState(){const C=[];for(const[z,q]of this.#l){const Q=q.result;C.push({stage:z,materialised:!!q.computed,bytes:Q&&typeof Q.byteLength=="number"?Q.byteLength:null,rows:Q&&typeof Q.length=="number"?Q.length:null,rebuilds:q.id})}return C}facetIndices(C){return this.#ve(C||null)}facetRows(C){const z=this.facetIndices(C),q=[];for(let Q=0;Q<z.length;Q++){const Y=this.#Ae(z[Q]);Y&&q.push(Y)}return q}invalidateRows(){this.#f.clear(),this.#R.clear(),this.#_=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#$e()}filteredIndices(){const C=this.#l.get("filter");if(C&&C.computed&&C.key===this.#Ee())return C.result||this.#$e();this.#ee();const z=this.#l.get("filter");return(z&&z.computed?z.result:null)||this.#$e()}unfilteredRows(){const C=this.#$e(),z=[];for(let q=0;q<C.length;q++){const Q=this.#Ae(C[q]);Q&&z.push(Q)}return z}#ve(C=null){const z=this.#$e(),q=this.#$("filters",null),Q=C?this.#tt("pruneColumn")(q,C):q,Y=this.#Tt(Q),J=String(this.#$("quick","")||"").trim().toLowerCase(),te=J?U(J,String(this.#$("quickMode","contains")||"contains")):null,ee=(this.#e.config||{}).hostFilter,re=!!(ee&&W(ee.active)&&ee.active()),se=this.#$("where",null),de=!!(se&&se.active);if(!Y&&!J&&!re&&!de)return z;let ie=null;Y&&(ie=this.#tt("evaluateFilters")(Y,{handle:pe=>this.#s.handle(pe),count:this.#Ze(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:pe=>T(this.#Le(pe))}));const oe=new Uint32Array(z.length);let ue=0;for(let ce=0;ce<z.length;ce++){const pe=z[ce];if(!(ie&&!ie[pe])&&!(te&&!this.#Et(pe,te))){if(re||de){const Me=this.#Ae(pe);if(re&&!ee.passes(Me)||de&&!se.passes(Me.data,Me.key))continue}oe[ue++]=pe}}if(ie){const ce=(this.#e.compute||{}).releaseMask;W(ce)&&ce({pool:this.#e.pool},ie)}return oe.subarray(0,ue)}handleFor(C){return this.#s.handle(C)}#Ie(C){const z=this.#$("sort",[]).filter(Y=>{const J=this.#Le(Y.col);return!J||!J.running?!0:(I(`source.sort.running.${Y.col}`,`sort ignores "${Y.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(!z.length)return C;const q=(this.#e.config||{}).locale;if(z.length===1){const Y=z[0],J=this.#s.handle(Y.col);if(!J)return I(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`),C;const te=this.#Le(Y.col);return this.#tt("sortColumn")(J,C,{descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:q,compare:O(te)})}const Q=[];for(const Y of z){const J=this.#s.handle(Y.col);if(!J){I(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`);continue}Q.push({handle:J,descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:q,compare:O(this.#Le(Y.col))})}return Q.length?this.#tt("sortMulti")(Q.map(Y=>Y.handle),Q,C):C}#Ne(C){const z=this.#$("groupBy",[]),q=this.#te();if(q&&!z.length){const ce=b(C,q);return this.#D=f(ce.roots,q.declaresChildren),{roots:null,leaves:C,nodes:new Map,tree:ce}}if(this.#D=null,q&&z.length&&I("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!z.length)return{roots:null,leaves:C,nodes:new Map};const Q=(this.#e.config||{}).timeZone,Y=[],J=[];let te=!1;for(const ce of z){const pe=this.#s.handle(ce);if(!pe){I(`source.group.${ce}`,`grouping ignores unknown column "${ce}".`);continue}Y.push(pe);const Me=this.#Le(ce),$e=Me&&Me.dataType;if($e&&W($e.groupProjector)){const Ae=Me.typeOptions&&Me.typeOptions.timeZone||Me.timeZone||Q||void 0,ke=$e.groupProjector(Me,Ae);J.push(ke||null),ke&&(te=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:C,nodes:new Map};const{keys:ee,buckets:re}=this.#tt("groupByColumns")(Y,C,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),se=this.#$("pivotBy",[]).length>0,de=[],ie=new Map;for(let ce=0;ce<re.length;ce++){const pe=ee[ce];let Me=null;const $e=[];for(let Ae=0;Ae<pe.length;Ae++){$e.push(v(pe[Ae]));const ke=D($e),ge=Ae===pe.length-1;let Ee=ie.get(ke);if(!Ee){const De=this.#i.group({path:[...$e],column:z[Ae],value:pe[Ae],level:Ae,parent:Me,expanded:se&&ge?!1:this.#at(ke,{key:ke,column:z[Ae],value:pe[Ae],level:Ae,path:[...$e]}),hasChildren:!(se&&ge)});Ee={row:De,leaves:null},ie.set(ke,Ee),Me?Me.children.push(De):de.push(De)}Ee.row.leafCount+=re[ce].length,Ae===pe.length-1&&(Ee.leaves=re[ce]),Me=Ee.row}}const oe=this.#$("sort",[])||[],ue=(ce,pe)=>{if(!ce||ce.length<2){if(ce)for(const ke of ce)ue(ke.children,pe+1);return}const Me=z[pe],$e=oe.find(ke=>ke.col===Me),Ae=$e&&$e.dir==="desc"?-1:1;ce.sort((ke,ge)=>Ae*_(ke.groupValue,ge.groupValue));for(const ke of ce)ue(ke.children,pe+1)};return ue(de,0),{roots:de,leaves:C,nodes:ie,keys:ee,buckets:re}}#X(C,z){const q=new Map,Q=new Map,Y=J=>{const te=J.physical>=0?[J.physical]:[];for(const ee of J.children)te.push(...Y(ee));if(J.children.length){const ee=this.#Re(z,Uint32Array.from(te),null);J.physical>=0?q.set(J.physical,ee):Q.set(J.key,ee)}return te};for(const J of C.roots)Y(J);return{byPhysical:q,byKey:Q}}#Ke(C){const z=this.#Xe();if(!z.length)return this.#C=null,this.#T=null,{grand:null};const q={id:this.#k("group"),columns:z.map(oe=>oe.id).join("")},Q=this.#C&&this.#C.id===q.id&&this.#C.columns===q.columns,Y=this.#it()&&Q?this.#E:null,J=Y?z.filter(oe=>Y.has(oe.id)):z,te=Q?this.#T:null,ee=this.#Se()?null:this.#rt(),re=this.#We(z),se=oe=>{const ue=C.nodes.get(oe.key);let ce=ue&&ue.leaves?ue.leaves:null;if(oe.children&&oe.children.length){const $e=oe.children.map(se);let Ae=0;for(const Ee of $e)Ae+=Ee.length;const ke=new Uint32Array(Ae);let ge=0;for(const Ee of $e)ke.set(Ee,ge),ge+=Ee.length;ce=ke}ce=ce||new Uint32Array(0);const pe=ee?ee.get(oe.key)||P:ce,Me=this.#ce(oe,Y?J:z,pe,re);return oe.totals=Y?{...oe.totals,...Me}:Me,ce};if(C.roots&&J.length)for(const oe of C.roots)se(oe);if(this.#M=C.tree?this.#X(C.tree,z):null,this.#C=q,this.#E=this.#it()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const ie=ee?this.#Ce():C.leaves;return this.#T=this.#nt(z,ie,Y,te),{grand:this.#T}}#nt(C,z,q,Q){const Y={},J=this.#k("group");J!==this.#y&&(this.#ot(),this.#y=J);const te=this.#S;this.#S=[];for(const ee of C){if(!E(ee))continue;const re=this.#s.handle(ee.id);if(!re)continue;const se=j(ee,"grand");if(!i(se,re)){if(q&&!q.has(ee.id)&&Q&&ee.id in Q){Y[ee.id]=Q[ee.id];continue}Y[ee.id]=this.#Re([ee],z,null,"grand")[ee.id];continue}let de=this.#v.get(ee.id);if((!de||de.fn!==se)&&(de=new t(se),this.#v.set(ee.id,de)),de.valid){let ie=!0;for(const oe of te)if(oe.colId===ee.id&&!de.update(oe.before,oe.after)){ie=!1;break}if(ie){Y[ee.id]=de.value();continue}de.invalidate()}de.seedColumn(re.values,r(re),z),Y[ee.id]=de.valid?de.value():this.#Re([ee],z,null,"grand")[ee.id]}return Y}#We(C){const z=this.#k("group");z!==this.#j&&(this.#A.clear(),this.#j=z);const q=new Map;for(const Y of C){if(!E(Y))continue;const J=this.#s.handle(Y.id),te=j(Y,"group");i(te,J)&&q.set(Y.id,{fn:te})}if(!q.size)return this.#O.length=0,q;const Q=this.#O;this.#O=[];for(const Y of Q){const{beforeKeys:J,afterKeys:te,colDeltas:ee}=Y,re=J.length?new Set(J):null,se=te.length?new Set(te):null;for(const{colId:de,before:ie,after:oe}of ee)if(q.has(de)){for(const ue of J)se&&se.has(ue)||this.#Be(ue,de,ie,null);for(const ue of te)re&&re.has(ue)||this.#Be(ue,de,null,oe);for(const ue of J)se&&!se.has(ue)||this.#Be(ue,de,ie,oe)}}return q}#Be(C,z,q,Q){const Y=this.#A.get(C),J=Y&&Y.get(z);!J||!J.valid||J.update(q,Q)||J.invalidate()}#ce(C,z,q,Q){if(!Q||!Q.size)return this.#Re(z,q,C);const Y={};let J=null,te=this.#A.get(C.key);for(const ee of z){const re=Q.get(ee.id);if(!re){(J||(J=[])).push(ee);continue}const se=this.#s.handle(ee.id);if(!se)continue;te||(te=new Map,this.#A.set(C.key,te));let de=te.get(ee.id);if((!de||de.fn!==re.fn)&&(de=new t(re.fn),te.set(ee.id,de)),de.valid||de.seedColumn(se.values,r(se),q),de.valid){Y[ee.id]=de.value();continue}(J||(J=[])).push(ee)}return J&&Object.assign(Y,this.#Re(J,q,C)),Y}#ke(C,z,q,Q){const Y=!this.#Se()||this.#P(z);for(const J of C){const te=J.getValue;if(!W(te))continue;const ee=te(q),re=te(Q);Object.is(ee,re)||(this.#E&&this.#E.add(J.id),Y&&this.#v.has(J.id)&&this.#S.push({colId:J.id,before:ee,after:re}))}}#qe(){const C=this.#$("groupBy",[]),z=[];for(const q of C){const Q=this.#Le(q);Q&&z.push(Q)}return z}#mt(C,z){const q=new Array(C.length);for(let Q=0;Q<C.length;Q++){const Y=C[Q].getValue;q[Q]=v(W(Y)?Y(z):void 0)}return q}#yt(C,z,q,Q,Y){if(this.#Se()&&!this.#P(q))return;const J=k(this.#mt(C,Q)),te=k(this.#mt(C,Y)),ee=J.length!==te.length||J.some((se,de)=>se!==te[de]),re=[];for(const se of z){const de=se.getValue;if(!W(de))continue;const ie=de(Q),oe=de(Y);!ee&&Object.is(ie,oe)||re.push({colId:se.id,before:ie,after:oe})}!re.length&&!ee||this.#O.push({beforeKeys:J,afterKeys:te,colDeltas:re})}#P(C){const z=this.#l.get("filter"),q=z&&z.computed?z.result:null;if(!q)return!0;let Q=0,Y=q.length-1;for(;Q<=Y;){const J=Q+Y>>1,te=q[J];if(te===C)return!0;te<C?Q=J+1:Y=J-1}return!1}#Se(){return(this.#e.config||{}).totalFilteredOnly!==!1}#he(C){return this.#Se()?C:this.#Ce().length}#Ce(){return(!this.#I||this.#I.version!==this.#c)&&(this.#I={version:this.#c,indices:this.#$e()}),this.#I.indices}#rt(){const C=this.#$("groupBy",[]),z=`${this.#c}|${JSON.stringify(C)}`;if(this.#N&&this.#N.key===z)return this.#N.map;const q=new Map,Q=[];for(const Y of C){const J=this.#s.handle(Y);J&&Q.push(J)}if(Q.length){const Y=this.#Ce(),{keys:J,buckets:te}=this.#tt("groupByColumns")(Q,Y,{locale:(this.#e.config||{}).locale}),ee=new Map;for(let re=0;re<te.length;re++){const se=J[re],de=[];for(let ie=0;ie<se.length;ie++){de.push(v(se[ie]));const oe=D(de);let ue=ee.get(oe);ue||(ue=[],ee.set(oe,ue));for(let ce=0;ce<te[re].length;ce++)ue.push(te[re][ce])}}for(const[re,se]of ee)q.set(re,Uint32Array.from(se))}return this.#N={key:z,map:q},q}#it(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Je(){this.#ot(),this.#et(),this.#E=null,this.#C=null,this.#T=null}#ot(){this.#v.clear(),this.#S.length=0,this.#y=-1}#et(){this.#A.clear(),this.#O.length=0,this.#j=-1}#bt(C){const z=this.#$("pivotBy",[]);if(!z.length)return this.#le=null,null;const q=(this.#e.compute||{}).pivot;if(!W(q))return I("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Q=z.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#Xe();return this.#le=q(Q,C.leaves,{groups:C.keys&&C.buckets?{keys:C.keys,buckets:C.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>j(Y.find(te=>te.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#_e(C){const z=this.#l.get("total").result,q=!!(this.#e.config||{}).groupFooter,Q=this.#oe();if(C.tree)return this.#Ct(C,z,Q);if(!C.roots&&!Q){if(z&&z.grand&&!this.#V()){const se=this.#i.grandTotal(z.grand,this.#he(C.leaves.length));if(this.#H===C.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=se;else{const de=Array.from(C.leaves);de.push(se),this.#B=de,this.#H=C.leaves}this.#ae=[{at:this.#B.length-1}]}else this.#H=null,this.#B=C.leaves,this.#ae=d;return this.#ne=d,this.#B}const Y=[],J=[],te=[],ee=se=>{if(Y.push(se),!Q)return;const de=this.#Ae(se);!de||!Q.isOpen(de.key)||(de.master=!0,de.expanded=!0,te.push({at:Y.length}),Y.push(this.#i.detail(de,Q.heightOf(de))))};if(!C.roots){for(let se=0;se<C.leaves.length;se++)ee(C.leaves[se]);return z&&z.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(z.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=d,this.#ae=te.length?te:d,this.#B=Y,Y}const re=(se,de,ie)=>{if(se.expanded=se.hasChildren===!1?!1:this.#at(se.key,{key:se.key,column:se.groupColumn,value:se.groupValue,level:se.level,path:se.groupPath}),se.posinset=de+1,se.setsize=ie,J.push({at:Y.length,row:se}),te.push({at:Y.length}),Y.push(se),!!se.expanded){if(se.children&&se.children.length)for(let oe=0;oe<se.children.length;oe++)re(se.children[oe],oe,se.children.length);else{const oe=C.nodes.get(se.key),ue=oe&&oe.leaves?oe.leaves:null;if(ue)for(let ce=0;ce<ue.length;ce++)ee(ue[ce])}q&&se.totals&&(te.push({at:Y.length}),Y.push(this.#i.footer(se)))}};for(let se=0;se<C.roots.length;se++)re(C.roots[se],se,C.roots.length);return z&&z.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(z.grand,this.#he(C.leaves.length)))),this.#ne=J,this.#ae=te,this.#B=Y,Y}#$e(){const C=this.#e.store;if(C&&W(C.liveIndices))return C.liveIndices();const z=new Uint32Array(this.#n.length);let q=0;for(let Q=0;Q<this.#n.length;Q++)this.#n[Q]!==void 0&&(z[q++]=Q);return z.subarray(0,q)}#Ze(){const C=this.#e.store;return C&&typeof C.physical=="number"?C.physical:this.#n.length}#Ye(C){const z=this.#e.store;return z&&W(z.source)?z.source(C):this.#n[C]}#st(C,z=C){const q=this.#B[C];if(typeof q!="number")return q.index=z,q;const Q=this.#Ae(q);return Q.index=z,Q}#Ae(C){let z=this.#f.get(C);z||(z=this.#i.leaf(this.#Ye(C),C),this.#f.set(C,z));const q=this.#D?this.#D.get(C):null;if(q){z.level=q.level,z.posinset=q.posinset,z.setsize=q.setsize,z.hasChildren=q.hasChildren,z.expanded=q.hasChildren&&!q.lazy&&this.#at(z.key);const Q=this.#M?this.#M.byPhysical.get(C):void 0;Q?z.totals=Q:z.totals&&(z.totals=null)}else z.hasChildren&&(z.level=0,z.hasChildren=!1,z.expanded=!1,z.posinset=void 0,z.setsize=void 0);return z}#Ct(C,z,q){const Q=[],Y=[],J=ee=>{if(ee.leafCount!==void 0)return ee.leafCount;let re=ee.physical>=0?1:0;for(const se of ee.children)re+=J(se);return ee.leafCount=re,re},te=ee=>{const re=this.#at(ee.key);if(ee.physical>=0){if(Q.push(ee.physical),q&&q.isOpen(this.#Ae(ee.physical).key)){const se=this.#Ae(ee.physical);Y.push({at:Q.length}),Q.push(this.#i.detail(se,q.heightOf(se)))}}else Q.push(this.#i.group({path:[ee.key],column:null,value:ee.value,level:ee.level,parent:null,expanded:re,hasChildren:ee.children.length>0,leafCount:J(ee),totals:this.#M?this.#M.byKey.get(ee.key):void 0}));if(re)for(const se of ee.children)te(se)};for(const ee of C.tree.roots)te(ee);return z&&z.grand&&!this.#V()&&(Y.push({at:Q.length}),Q.push(this.#i.grandTotal(z.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=d,this.#ae=Y.length?Y:d,this.#B=Q,Q}#wt(){return y(()=>this.count(),C=>this.at(C))}#Et(C,z){let q=this.#R.get(C);if(q===void 0){const Q=this.#Ye(C),Y=this.#kt(),J=[],te=this.#e.columnHidden;for(const ee of Y){if(ee.quickFilter===!1||W(te)&&te(ee.id))continue;const re=ee.value&&W(ee.value.quickFilterText)?ee.value.quickFilterText({value:void 0,data:Q,row:null,column:ee,colId:ee.id,grid:null,context:this.#$("context",null)}):null,se=re??(W(ee.formatValue)?ee.formatValue(W(ee.getValue)?ee.getValue(Q):void 0):"");se!=null&&se!==""&&J.push(String(se))}q=J.join(" ").toLowerCase(),this.#R.set(C,q)}return z(q)}#Xe(){const C=this.#$("totals",[]),z=C&&C.length?new Set(C):null;return this.#kt().filter(q=>z?z.has(q.id):!!(q.total||q.groupTotal||q.grandTotal))}#Re(C,z,q,Q="group"){const Y={},J=(this.#e.compute||{}).total;for(const te of C){if(!E(te))continue;const ee=this.#s.handle(te.id);if(!ee)continue;const re=j(te,Q);if(re)if(W(re)){const se=new Array(z.length);for(let de=0;de<z.length;de++)se[de]=ee.get(z[de]);Y[te.id]=re(se,{row:q,column:te,grid:this.#e.grid||null,context:this.#$("context",null),valueAt:(de,ie)=>{const oe=this.#s.handle(de);return oe&&ie>=0&&ie<z.length?oe.get(z[ie]):null}})}else W(J)&&(Y[te.id]=J(ee,z,re))}return Y}#Tt(C){if(!C)return C;const z=this.#e.config||{},q={tz:z.timeZone,weekStartsOn:z.weekStartsOn};return l(C,Q=>{const Y=p(Q,q);if(Y&&Y.type)return Y;const J=this.#Le(Y&&Y.col),te=J&&(J.dataType?.base||J.type);return te?{...Y,type:te}:Y})}#at(C,z){const q=this.#$("expanded",null);return q?W(q.has)?q.has(C,z):Array.prototype.includes.call(q,C):!0}#$(C,z){if(C==="context"||!W(this.#e.stateVersion))return this.#lt(C,z);const q=this.#Mt(C),Q=this.#d.get(C);if(Q&&Q.version===q)return Q.value;const Y=this.#lt(C,z);return this.#d.set(C,{version:q,value:Y}),Y}#lt(C,z){const q=this.#e.state;if(q&&W(q[C])){const Q=q[C]();return Q??z}return z}#Qe(){const C=this.#e.stateVersion;return W(C)?C():0}#vt(){const C=this.#e.columnsVersion,z=this.#e.permissionsVersion;return`${W(C)?C():0}|${W(z)?z():0}`}#Mt(C){return C==="totals"?this.#vt():`${this.#Qe()}`}#ut(C,z,q){if(!W(this.#e.stateVersion))return q();const Q=this.#h.get(C);if(Q&&Q.version===z)return Q.key;const Y=q();return this.#h.set(C,{version:z,key:Y}),Y}#tt(C){const z=(this.#e.compute||{})[C];return W(z)||N(`ctx.compute.${C} is required by the memory source pipeline`),z}#kt(){const C=this.#e.columns;return C&&W(C.all)?C.all():[]}#Le(C){const z=this.#e.columns;return z&&W(z.get)?z.get(C):void 0}#Ue(C,z){const q=this.#e.emit;W(q)&&q(C,z)}}}),je("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 M}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class Z extends Error{constructor(H,B="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${B}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class M{#e;constructor(H,B,G,D){this.#e=H,this.key=B,this.controller=G,this.signal=G.signal,this.seq=D}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new Z(this.key,H)),this.#e.settle(this)}}class I{#e=new Map;#t=0;begin(H="",B="superseded"){const G=this.#e.get(H);G&&!G.signal.aborted&&G.controller.abort(new Z(H,B));const D=new M(this,H,new AbortController,++this.#t);return this.#e.set(H,D),D}tokenFor(H){return this.#e.get(H)}pending(H=""){const B=this.#e.get(H);return!!B&&!B.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",B="superseded"){const G=this.#e.get(H);G&&G.abort(B)}abortAll(H="superseded"){for(const B of[...this.#e.values()])B.abort(H);this.#e.clear()}}function N(){return new I}function W(_){if(!_||typeof _!="object")return!1;const H=_;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),je("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 M}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return N}});const Z=100,M=32;class I{constructor(_){this.id=_,this.rows=null,this.state="pending",this.token=null,this.error=null}}class N{#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)||M))}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 H=this.#e.get(_);return!!H&&H.state==="pending"}loaded(_){const H=this.#e.get(_);return!!H&&H.state==="loaded"}begin(_,H){let B=this.#e.get(_);return B||(B=new I(_)),B.state="pending",B.token=H,B.error=null,this.#i(_,B),B}fill(_,H){const B=this.#e.get(_)||new I(_);B.rows=H,B.state="loaded",B.token=null,this.#i(_,B)}failed(_,H){const B=this.#e.get(_)||new I(_);B.state="error",B.error=H,B.token=null,this.#i(_,B)}delete(_){return this.#e.delete(_)}rowAt(_){const H=this.blockOf(_),B=this.#e.get(H);if(!(!B||B.state!=="loaded"||!B.rows))return this.#i(H,B),B.rows[_-H*this.#t]}rowLoaded(_){const H=this.blockOf(_),B=this.#e.get(H);return!!B&&B.state==="loaded"&&!!B.rows&&_-H*this.#t<B.rows.length}loadedExtent(){let _=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const B=H.id*this.#t+H.rows.length;B>_&&(_=B)}return _}fillOf(_){const H=this.#e.get(_);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(_,H){this.#r=this.blockOf(Math.max(0,_)),this.#o=this.blockOf(Math.max(0,H))}evict(){const _=[];if(this.#e.size<=this.#n)return _;for(const[H,B]of this.#e){if(this.#e.size-_.length<=this.#n)break;H>=this.#r&&H<=this.#o||B.state!=="pending"&&_.push(H)}for(const H of _)this.#e.delete(H);return _}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(_,H){this.#e.delete(_),this.#e.set(_,H)}}}),je("packages/core/src/source/paged.js",function(e,V){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return s}});const Z=V("packages/core/src/internal/util.js"),M=Z.Lru,I=Z.isFunction,N=Z.warnOnce,W=Z.settleDebounce,_=V("packages/core/src/source/abort.js"),H=_.createAbortScope,B=_.isAbortError,G=V("packages/core/src/source/blockcache.js"),D=G.BlockCache,v=G.DEFAULT_PAGE_SIZE,k=G.DEFAULT_MAX_CACHED_PAGES,c=V("packages/core/src/source/rows.js").createRowFactory,o=V("packages/core/src/source/filterwire.js"),n=o.wireFilters,t=o.querySignature,i=o.warnHostFilterNotApplied,a=120;function r(u,l){return new s(u,l)}class s{mode="paged";#e;#t;#n;#r=H();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(l,p){this.#e=l||{mode:"paged"},this.#t=p||{},this.#n=new D({pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||k}),this.#o=c(this.#t),this.#i=new M(this.#n.pageSize*4),this.#h=W((m,b)=>this.#m(m,b),a),this.#c=this.#v(),I(this.#e.fetch)||N("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),i(this.#t)}count(){if(this.#w(),this.#l!==null)return this.#l;const l=Math.max(this.#u,this.#n.loadedExtent());return this.#a?l:l+this.#n.pageSize}at(l){if(this.#w(),l<0||l>=this.count())return;const p=this.#i.get(l);if(p&&(p.data!==null||!this.#n.rowLoaded(l)))return p;const m=this.#n.rowAt(l);if(m===void 0){const g=this.#o.skeleton(l);return this.#i.set(l,g),g}const b=this.#o.leaf(m,l);return b.index=l,this.#i.set(l,b),this.#s.set(b.key,l),b}byKey(l){const p=this.#s.get(l);return p===void 0?void 0:this.at(p)}loaded(l){return this.#n.rowLoaded(l)}hint(l,p){if(this.#f)return;const m=this.#w(),b=Math.max(0,Math.floor(l)),g=Math.max(b,Math.floor(p));this.#d={start:b,end:g},this.#n.protect(b,g);for(const f of this.#n.evict())this.#g(f);this.#h(b,g),m&&this.#h.flush()}#m(l,p){if(this.#f)return;this.#n.protect(l,p);const m=this.#n.blockOf(l),b=this.#n.blockOf(p);for(let g=m;g<=b&&!(this.#l!==null&&g*this.#n.pageSize>=this.#l);g++)this.#n.has(g)||this.#p(g)}apply(l){const p={added:[],updated:[],removed:[]};if(!l)return p;if(l.update)for(const m of l.update){const b=this.#o.keyOf(m,-1),g=this.#s.get(b);if(g===void 0)continue;const f=this.#o.leaf(m,g);f.index=g,this.#i.set(g,f),p.updated.push(f)}return(l.add&&l.add.length||l.remove&&l.remove.length)&&this.reload(),p}reload(l){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.#s.clear()}exact(){return this.#l!==null||this.#a}pending(){return this.#r.size}async#p(l){if(!I(this.#e.fetch))return;const p=this.#r.begin(`block:${l}`);this.#n.begin(l,p);const{start:m,end:b}=this.#n.rangeOf(l),g=this.#c;try{const f=await this.#e.fetch({range:{start:m,end:b},sort:this.#S("sort",[]),filters:n(this.#S("filters",null),this.#y()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:p.signal});if(!p.current||g!==this.#c||this.#f)return;p.settle();const w=f&&f.rows||[];this.#n.fill(l,w);for(let h=0;h<w.length;h++)this.#i.delete(m+h);const S=f&&typeof f.total=="number"?f.total:f&&typeof f.count=="number"?f.count:null;S!==null?(this.#l=S,this.#a=!0):w.length<this.#n.pageSize?(this.#a=!0,this.#l=m+w.length):this.#u=Math.max(this.#u,m+w.length),this.#A("model:changed",{reason:"page",block:l,from:m,to:m+w.length}),this.#A("rows:changed",{companion:!0,reason:"page",block:l,from:m,to:m+w.length})}catch(f){if(p.settle(),B(f))return;this.#n.failed(l,f),this.#A("source:error",{error:f,block:l,range:{start:m,end:b}})}}#g(l){const{start:p,end:m}=this.#n.rangeOf(l);for(let b=p;b<m;b++){const g=this.#i.peek(b);g&&this.#s.delete(g.key),this.#i.delete(b)}}#w(){const l=this.#v();return l===this.#c?!1:(this.#c=l,this.#b("query"),!0)}#b(l){this.#r.abortAll(l),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#A("model:changed",{reason:l})}#v(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#y(){const l=this.#t.config||{};return{tz:l.timeZone,weekStartsOn:l.weekStartsOn}}#S(l,p){const m=this.#t.state;if(m&&I(m[l])){const b=m[l]();return b??p}return p}#A(l,p){const m=this.#t.emit;I(m)&&m(l,p)}}}),je("packages/core/src/source/remote.js",function(e,V){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return b}});const Z=V("packages/core/src/internal/util.js"),M=Z.Lru,I=Z.isFunction,N=Z.warnOnce,W=Z.settleDebounce,_=V("packages/core/src/source/abort.js"),H=_.createAbortScope,B=_.isAbortError,G=V("packages/core/src/source/blockcache.js"),D=G.BlockCache,v=G.DEFAULT_PAGE_SIZE,k=G.DEFAULT_MAX_CACHED_PAGES,y=V("packages/core/src/source/rows.js"),c=y.createRowFactory,o=y.groupKey,n=V("packages/core/src/source/filterwire.js"),t=n.wireFilters,i=n.querySignature,a=n.warnHostFilterNotApplied,s=V("packages/core/src/source/memory.js").MemorySource,u=1,l=120;function p(g,f){return new b(g,f)}class m{constructor(f,w,S,h){this.path=f,this.keyPath=h||f,this.values=[],this.level=w,this.key=o(this.keyPath),this.cache=new D(S),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null}}class b{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=H();#l;#a;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(f,w){this.#e=f||{mode:"remote"},this.#t=w||{},I(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#A(),this.handleFor=d=>this.#j(d),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#C(),this.unfilteredRows=()=>this.#N(),this.facetIndices=d=>this.#E(d));const S=this.#e.counts;I(S)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const h=this.#e.grandTotals;I(h)&&(this.grandTotalRow=()=>this.#I()),this.#n={pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||k},this.#l=c(this.#t),this.#a=new M(this.#n.pageSize*4),this.#h=W((d,j)=>this.#w(d,j),l),this.#r=new m([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ie(),I(this.#e.fetch)||N("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Z()}count(){const f=this.#v();return f?f.count():(this.#le(),this.#R(this.#r))}at(f){const w=this.#v();if(w)return w.at(f);if(this.#le(),f<0||f>=this.count())return;const S=this.#B(this.#r,f);if(!S)return;const h=this.#H(S.node,S.local);return h&&(h.index=f),h||this.#l.skeleton(f,S.node.level)}byKey(f){const w=this.#v();if(w)return w.byKey(f);const S=this.#u.get(f);if(!S)return;const h=S.lastIndexOf(":"),d=this.#o.get(S.slice(0,h));return d&&this.#H(d,Number(S.slice(h+1)))||void 0}loaded(f){const w=this.#v();if(w)return w.loaded(f);if(f<0||f>=this.count())return!1;const S=this.#B(this.#r,f);return!!S&&S.node.cache.rowLoaded(S.local)}hint(f,w){if(this.#f)return;const S=this.#le(),h=Math.max(0,Math.floor(f)),d=Math.max(h,Math.floor(w));for(const[j,E]of this.#g(h,d)){j.cache.protect(E.min,E.max);for(const O of j.cache.evict())this.#ae(j,O)}this.#h(h,d),S&&this.#h.flush()}#g(f,w){const S=this.count(),h=new Map;for(let d=f;d<=w&&d<S;d++){const j=this.#B(this.#r,d);if(!j)continue;const E=h.get(j.node);E?(E.min=Math.min(E.min,j.local),E.max=Math.max(E.max,j.local)):h.set(j.node,{min:j.local,max:j.local})}return h.size||h.set(this.#r,{min:f,max:f}),h}#w(f,w){if(!this.#f)for(const[S,h]of this.#g(f,w)){S.cache.protect(h.min,h.max);const d=S.cache.blockOf(h.min),j=S.cache.blockOf(h.max);for(let E=d;E<=j&&!(S.count!==null&&E*S.cache.pageSize>=S.count);E++)S.cache.has(E)||this.#M(S,E)}}apply(f){const w={added:[],updated:[],removed:[]};if(!f)return w;if(f.update)for(const S of f.update){const h=this.#u.get(this.#l.keyOf(S,-1));if(!h)continue;this.#a.delete(h);const d=h.lastIndexOf(":"),j=this.#o.get(h.slice(0,d));if(!j)continue;const E=Number(h.slice(d+1)),O=j.cache.blockOf(E);if(!j.cache.loaded(O))continue;const{start:T}=j.cache.rangeOf(O),A=[];for(let L=T;L<T+j.cache.pageSize;L++){const $=j.cache.rowAt(L);if($===void 0)break;A.push(L===E?S:$)}j.cache.fill(O,A);const P=this.#H(j,E);P&&w.updated.push(P)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload({keepExpanded:!0}),w}reload(f){this.#s.abortAll("reload"),this.#h.cancel(),f&&f.keepExpanded===!1&&this.#i.clear(),this.#de(),this.#G("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#de(),this.#o.clear(),this.#i.clear(),this.#m&&I(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(f){this.#i.has(f)||(this.#i.add(f),this.#G("group:toggled",{key:f,expanded:!0}),this.#G("model:changed",{reason:"expand",key:f}))}collapse(f){this.#i.delete(f)&&(this.#G("group:toggled",{key:f,expanded:!1}),this.#G("model:changed",{reason:"collapse",key:f}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}invalidateHandles(){this.#m&&(I(this.#m.invalidateHandles)&&this.#m.invalidateHandles(),I(this.#m.invalidate)&&this.#m.invalidate("filter"))}#b(){const f=this.#e.fullFrame;return I(f)?f():null}#v(){const f=this.#b();return f?(this.#m||(this.#m=new s({mode:"memory"},this.#y())),f.version!==this.#p&&(this.#m.setRows(f.rows),this.#p=f.version),this.#m):null}#y(){const f=this.#t,w=f.state||{};return{...f,state:{...w,page:()=>0,pageSize:()=>0}}}#S(){const f=this.#v();return f?f.filteredIndices():new Uint32Array(0)}#A(){const f=this.#v();return f?f.unfilteredIndices():new Uint32Array(0)}#j(f){const w=this.#v();return w?w.handleFor(f):void 0}#O(){const f=this.#v();return f?f.display():[]}#E(f){const w=this.#v();return w&&I(w.facetIndices)?w.facetIndices(f):new Uint32Array(0)}#C(){const f=this.#v();return f&&I(f.grandTotalRow)?f.grandTotalRow():null}#T(f){const w=this.#v();if(w){const j=f==="match"?w.matchCount:w.totalCount;if(I(j))return j.call(w)}const S=this.#e.counts,h=I(S)?S():null,d=h?h[f]:null;return typeof d=="number"?d:this.count()}#I(){const f=this.#v();if(f&&I(f.grandTotalRow))return f.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const S=this.#e.grandTotals,h=I(S)?S():null;return!h||!h.totals?null:this.#l.grandTotal(h.totals,h.leafCount||0)}#N(){const f=this.#v();if(f&&I(f.unfilteredRows))return f.unfilteredRows();const w=[],S=this.count();for(let h=0;h<S;h++){const d=this.at(h);d&&w.push(d)}return w}#D(f,w,S){const{start:h,end:d}=f.cache.rangeOf(w),j=this.#K("groupBy",[]),E=this.#K("pivotBy",[]),O=this.#K("quick",""),T=this.#te(),A={protocol:u,range:{start:h,end:d},groupPath:f.path,groupValues:f.values,groupBy:j,totals:T,totalFns:this.#V(T),pivotBy:E,pivotMode:E.length>0,filters:t(this.#K("filters",null),this.#q()),sort:this.#K("sort",[]),context:this.#K("context",null),signal:S};O&&(A.quick=O);const P=this.#K("where",null);return P&&P.active&&(A.where=P),A}async#M(f,w){if(!I(this.#e.fetch))return;const S=this.#s.begin(`${f.key}:${w}`);f.cache.begin(w,S);const h=this.#d,{start:d}=f.cache.rangeOf(w);try{const j=await this.#e.fetch(this.#D(f,w,S.signal));if(!S.current||h!==this.#d||this.#f)return;S.settle();const E=j&&j.rows||[];f.cache.fill(w,E);for(let A=0;A<E.length;A++)this.#a.delete(`${f.key}:${d+A}`);const O=j&&typeof j.count=="number"?j.count:j&&typeof j.total=="number"?j.total:null,T=j&&I(j.pendingTotal?.then)?j.pendingTotal:null;O!==null?(f.count=O,f.complete=!0):E.length<f.cache.pageSize?(f.count=d+E.length,f.complete=!0):T&&(f.counting=!0),j&&Array.isArray(j.pivotFields)&&this.#W(j.pivotFields),this.#G("model:changed",{reason:"page",groupPath:f.path,block:w}),this.#G("rows:changed",{companion:!0,reason:"page",groupPath:f.path,block:w}),T&&this.#x(f,T,h)}catch(j){if(S.settle(),B(j))return;f.cache.failed(w,j),this.#G("source:error",{error:j,groupPath:f.path,block:w})}}async#x(f,w,S){let h;try{h=await w}catch(d){if(S!==this.#d||this.#f)return;f.counting=!1,B(d)||this.#G("source:error",{error:d,groupPath:f.path});return}S!==this.#d||this.#f||(f.counting=!1,typeof h=="number"&&(f.count=h,f.complete=!0,this.#G("source:total",{total:h,groupPath:f.path}),this.#G("model:changed",{reason:"total",count:h,groupPath:f.path})))}totalPending(){return this.#r.counting===!0}#W(f){f.length===this.#c.length&&f.every((w,S)=>w===this.#c[S])||(this.#c=f,this.#G("column:pivoted",{pivotFields:f,remote:!0}))}#R(f){let w=this.#_(f);for(const S of f.children.values())this.#oe(S.key)&&(w+=this.#R(S));return w}#_(f){if(f.count!==null)return f.count;const w=f.cache.loadedExtent();return f.complete?w:f.row&&f.row.leafCount>0?Math.max(w,f.row.leafCount):w+f.cache.pageSize}#B(f,w){let S=w,h=0;const d=[...f.children.entries()].filter(([,E])=>this.#oe(E.key)).sort((E,O)=>E[0]-O[0]);for(const[E,O]of d){const T=E-h+1;if(S<T)return{node:f,local:h+S};S-=T,h=E+1;const A=this.#R(O);if(S<A)return this.#B(O,S);S-=A}const j=this.#_(f);return h+S<j?{node:f,local:h+S}:null}#H(f,w){const S=`${f.key}:${w}`,h=this.#a.get(S);if(h)return h;const d=f.cache.rowAt(w);if(d===void 0)return null;const j=this.#K("groupBy",[]);let E;if(f.level<j.length){const O=j[f.level],T=this.#z(d,O),A=T==null,P=[...f.path,A?"":String(T)],L=[...f.keyPath,A?null:String(T)];E=this.#l.group({path:P,keyPath:L,column:O,value:T,level:f.level,parent:f.row,leafCount:Number(d.leafCount)||0,expanded:this.#oe(o(L))}),E.totals=this.#ne(d),E.data=d;let $=this.#o.get(E.key);$?$.row=E:($=new m(P,f.level+1,this.#n,L),$.row=E,this.#o.set($.key,$)),$.values=[...f.values,T],f.children.set(w,$)}else E=this.#l.leaf(d,w,f.level,f.row);return this.#a.set(S,E),this.#u.set(E.key,S),E}#ne(f){const w=f||{};if(w.totals&&typeof w.totals=="object")return w.totals;const S={};for(const h of this.#te())Object.hasOwn(w,h)&&(S[h]=w[h]);return S}#ae(f,w){const{start:S,end:h}=f.cache.rangeOf(w);for(let d=S;d<h;d++){const j=`${f.key}:${d}`,E=this.#a.peek(j);E&&this.#u.delete(E.key),this.#a.delete(j)}}#le(){const f=this.#ie();return f===this.#d?!1:(this.#d=f,this.#s.abortAll("query"),this.#de(),this.#G("model:changed",{reason:"query"}),!0)}#de(){for(const f of this.#o.values())f.cache.clear(),f.count=null,f.complete=!1,f.counting=!1,f.children.clear();this.#a.clear(),this.#u.clear()}#ie(){const f=this.#K("where",null);return`${i({filters:this.#K("filters",null),sort:this.#K("sort",[]),quick:this.#K("quick",""),groupBy:this.#K("groupBy",[]),pivotBy:this.#K("pivotBy",[]),context:this.#K("context",null)})}|${f?f.version:0}`}#oe(f){const w=this.#K("expanded",null);return w?I(w.has)?w.has(f):Array.prototype.includes.call(w,f):this.#i.has(f)}#te(){const f=this.#K("totals",[]);if(f&&f.length)return[...f];const w=this.#t.columns;return!w||!I(w.all)?[]:w.all().filter(S=>!!S.total).map(S=>S.id)}#V(f){const w=this.#t.columns,S={};if(!w||!I(w.get))return S;for(const h of f){const d=w.get(h);if(!d)continue;const j=d.groupTotal!=null?d.groupTotal:d.total;typeof j=="string"&&(S[h]=j)}return S}#z(f,w){const S=this.#t.columns,h=S&&I(S.get)?S.get(w):void 0;return h&&I(h.getValue)?h.getValue(f):f?.[w]}#Z(){a(this.#t)}#q(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#K(f,w){const S=this.#t.state;if(S&&I(S[f])){const h=S[f]();return h??w}return w}#G(f,w){const S=this.#t.emit;I(S)&&S(f,w)}}}),je("packages/core/src/source/gapbuffer.js",function(e,V){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return M}});const Z=64;class M{#e;#t=0;#n=0;constructor(N=Z){this.#e=new Uint32Array(Math.max(1,N)),this.#n=this.#e.length}static from(N,W=Z){const _=new M(N.length+Math.max(1,W));return _.#e.set(N,0),_.#t=N.length,_.#n=_.#e.length,_}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(N){return N<0||N>=this.length?0:N<this.#t?this.#e[N]:this.#e[N+(this.#n-this.#t)]}insert(N,W){const _=N<0?0:N>this.length?this.length:N;this.#r(_),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(N){this.insert(this.length,N)}removeAt(N){return!Number.isInteger(N)||N<0||N>=this.length?!1:(this.#r(N),this.#n++,!0)}toArray(){const N=new Uint32Array(this.length);return N.set(this.#e.subarray(0,this.#t),0),N.set(this.#e.subarray(this.#n),this.#t),N}clear(){this.#t=0,this.#n=this.#e.length}#r(N){if(N!==this.#t)if(N<this.#t){const W=this.#t-N;this.#e.copyWithin(this.#n-W,N,this.#t),this.#t=N,this.#n-=W}else{const W=N-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=N,this.#n+=W}}#o(){const N=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-N),this.#e=W,this.#n=W.length-N}}}),je("packages/core/src/store/ingest.js",function(e,V){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return k}}),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 n}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const Z=V("packages/core/src/internal/util.js"),M=Z.now,I=Z.nextFrame,N=Z.infoOnce,W=Z.warnOnce,_=Z.isFunction,H=Z.pathGetter,G=V("packages/core/src/store/columnstore.js").ColumnStore,D=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function v(i,a={}){if(a.multi)return"multi";if(i.length===0)return"object";let r=0,s=0,u=0,l=0,p=0;for(let b=0;b<i.length;b++){const g=i[b];typeof g=="number"?r++:typeof g=="boolean"?s++:typeof g=="string"?u++:g instanceof Date?l++:Array.isArray(g)&&p++}const m=i.length;return r===m?"float64":s===m?"bitset":l===m?"float64":u===m?"text":p===m?"multi":"object"}function k(i,a,r){return a<=0||i<r*a?"dictionary":"object"}function y(i,a,r){const s=new Map,u=new Map;for(const d of i){if(d.computed)continue;const j=_(d.read)?d.read:H(d.field||d.id);u.set(d.id,j),s.set(d.id,j)}const l=a?.order??[],p=a?.fns??{},m=a?.deps??{},b=a?.wrapDeps??null,g=l.filter(d=>_(p[d])),f=g.some(d=>m[d]==="*");let w=new WeakMap;const S=d=>{const j={};if(f)for(const[E,O]of u)j[E]=O(d);for(const E of g){const O=m[E];let T;if(O==="*")T=j;else{T={};const A=O||[];for(let P=0;P<A.length;P++){const L=A[P];T[L]=L in j?j[L]:u.get(L)?.(d)}}j[E]=p[E](b?b(T,E):T,{data:d,row:null,column:null,grid:null,context:r})}return j},h=d=>{if(d===null||typeof d!="object"&&typeof d!="function")return S(d);let j=w.get(d);return j===void 0&&(j=S(d),w.set(d,j)),j};for(const d of g)s.set(d,j=>h(j)[d]);return{readers:s,reset(){w=new WeakMap}}}class c{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(a,r){this.spec=a,this.read=r,this.kind="object",this.inferred=!1,this.nullable=a.nullable!==!1}}class o{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(a,r={},s={}){this.#e=Array.isArray(a)?a:Array.from(a||[]),this.#i={...D,...s};const u=r.columns??[];this.#r=y(u,r.computed??null,r.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(u,r.computed??null),this.#n=new G(this.#t.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const a=M(),{chunkMs:r,chunkRows:s}=this.#i,u=this.#e.length;do{const l=Math.min(this.#o+s,u);this.#n.append(this.#e.slice(this.#o,l)),this.#d(this.#o,l),this.#o=l,this.#r.reset(),this.#f(!1)}while(this.#o<u&&M()-a<r);return this.#a+=M()-a,this.#i.onProgress?.({loaded:this.#o,total:u}),this.#o>=u?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(a=>({id:a.spec.id,kind:a.kind,nullable:a.nullable,read:a.read,dictionary:a.spec.dictionary})),decisions:this.#t.map(a=>({id:a.spec.id,kind:a.kind,nullable:a.nullable,inferred:a.inferred,distinct:a.candidate||a.change?this.#h(a):null,change:a.change,reason:a.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(a,r){const s=this.#e,u=Math.min(this.#i.sampleSize,s.length),l=this.#i.dictionaryRatio,p=r?.pure instanceof Set?r.pure:new Set(r?.pure??r?.order??[]);for(const m of a){if(!m||!m.id)continue;if(m.computed&&(m.pure===!1||r&&!p.has(m.id))){W(`ingest.impure.${m.id}`,`column "${m.id}" is an impure computed column and is not materialised into the store`);continue}const b=this.#r.readers.get(m.id)??(_(m.read)?m.read:H(m.field||m.id)),g=new c(m,b);if(m.kind)g.kind=m.kind,g.reason="declared by the caller";else if(m.dictionary)g.kind=m.multi?"multi":"dictionary",g.reason="value table supplied (lookup column)";else{const f=[];for(let S=0;S<u&&f.length<this.#i.sampleSize;S++){const h=b(s[S]);h!=null&&f.push(h)}g.inferred=!0;const w=v(f,{multi:m.multi});if(w==="text"){const S=new Set(f).size;g.kind=k(S,f.length,l),g.candidate=this.#u,g.reason=`sampled ${S} distinct in ${f.length}`}else g.kind=w,g.reason=`inferred from ${f.length} sampled values`,w==="object"&&f.length&&N(`ingest.mixed.${m.id}`,`column "${m.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);g.kind==="object"&&g.candidate&&(g.distinct=new Set(f))}this.#t.push(g)}}#d(a,r){const s=this.#e;for(const u of this.#t){if(!u.candidate||!u.distinct)continue;const l=u.distinct;for(let p=a;p<r;p++){const m=u.read(s[p]);m!=null&&l.add(m)}}}#h(a){if(a.distinct)return a.distinct.size;const r=this.#n.column(a.spec.id);return r?.dict?r.dict.size:0}#f(a){const r=this.#i.dictionaryRatio,s=this.#e.length;for(const u of this.#t){if(!u.candidate)continue;const l=this.#h(u);if(u.kind==="dictionary"&&l>=r*s){const p=this.#n.column(u.spec.id);u.distinct=new Set(p?.dict?p.dict.values():[]),this.#n.convert(u.spec.id,"object"),u.kind="object",u.change="demoted",u.reason=`${l} distinct values is at or above ${r*100}% of ${s} rows`;continue}if(u.kind==="object"&&l>=r*s){u.candidate=!1,u.distinct=null,u.reason=`${l} distinct values is at or above ${r*100}% of ${s} rows`;continue}a&&u.kind==="object"&&l<r*s&&(this.#n.convert(u.spec.id,"dictionary"),u.kind="dictionary",u.change=u.change==="demoted"?null:"promoted",u.reason=`${l} distinct values is below ${r*100}% of ${s} rows`,u.distinct=null),a&&(u.candidate=!1)}}}async function n(i,a={},r={}){const s=new o(i,a,r),u=r.scheduler?.frame??I;for(;s.slice();)await new Promise(l=>{u(l)});return s.result()}function t(i,a={},r={}){const s=new o(i,a,{...r,chunkMs:1/0});for(;s.slice(););return s.result()}}),je("packages/core/src/store/columnpack.js",function(e,V){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return o}});const M=V("packages/core/src/internal/util.js").pathGetter,I=V("packages/core/src/store/ingest.js"),N=I.inferKind,W=I.decideText,_=I.INGEST_DEFAULTS,B=V("packages/core/src/store/columnstore.js").toFloat,G=new Set(["float64","int32","bitset","dictionary","object","multi"]);function D(n){if(!Array.isArray(n)||n.length===0)return!1;for(const t of n)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!G.has(t.kind))return!1;return!0}function v(n){const t=B(n);return Number.isFinite(t)?t|0:0}function k(n){return n==null?[]:Array.isArray(n)?n:[n]}function y(n,t,i,a){if(n.kind)return n.kind;const r=[];for(let l=0;l<t.length&&r.length<_.sampleSize;l++){const p=t[l];p!=null&&r.push(p)}const s=N(r,{multi:n.multi});if(s!=="text")return s;const u=new Set(r).size;return W(u,r.length,a)}function c(n,t,i={}){const a=t.length|0,r=i.dictionaryRatio??_.dictionaryRatio,s=[];for(const u of n){const l=M(u.field||u.id),p=u.nullable!==!1,m=new Array(a);for(let S=0;S<a;S++){const h=l(t[S]);m[S]=h===void 0?null:h}const b=y(u,m,a,r),g=p?new Uint8Array(a+7>>3):null,f=S=>{g&&(g[S>>3]|=1<<(S&7))};let w;switch(b){case"float64":{const S=new Float64Array(a);for(let h=0;h<a;h++){const d=m[h],j=d===null;j||f(h),S[h]=j?NaN:B(d)}w={id:u.id,kind:b,nullable:p,values:S,presence:g,offsets:null,table:null};break}case"int32":{const S=new Int32Array(a);for(let h=0;h<a;h++){const d=m[h],j=d===null;j||f(h),S[h]=j?0:v(d)}w={id:u.id,kind:b,nullable:p,values:S,presence:g,offsets:null,table:null};break}case"bitset":{const S=new Uint8Array(a+7>>3);for(let h=0;h<a;h++){const d=m[h],j=d===null;j||f(h),!j&&d&&(S[h>>3]|=1<<(h&7))}w={id:u.id,kind:b,nullable:p,values:S,presence:g,offsets:null,table:null};break}case"dictionary":{const S=new Uint32Array(a),h=[],d=new Map;for(let j=0;j<a;j++){const E=m[j];if(E===null){S[j]=0;continue}f(j);let O=d.get(E);O===void 0&&(O=h.length,h.push(E),d.set(E,O)),S[j]=O}w={id:u.id,kind:b,nullable:p,values:S,presence:g,offsets:null,table:h};break}case"multi":{const S=[],h=new Map,d=new Uint32Array(a+1),j=[];for(let E=0;E<a;E++){const O=m[E];d[E]=j.length,O===null||f(E);const A=k(O);for(let P=0;P<A.length;P++){const L=A[P];let $=h.get(L);$===void 0&&($=S.length,S.push(L),h.set(L,$)),j.push($)}}d[a]=j.length,w={id:u.id,kind:b,nullable:p,values:Int32Array.from(j),presence:g,offsets:d,table:S};break}default:{const S=new Array(a);for(let h=0;h<a;h++){const d=m[h];d!==null&&f(h),S[h]=d}w={id:u.id,kind:"object",nullable:p,values:S,presence:g,offsets:null,table:null};break}}s.push(w)}return{count:a,columns:s}}function o(n){const t=[];if(!n||!Array.isArray(n.columns))return t;const i=a=>{ArrayBuffer.isView(a)&&a.buffer&&!t.includes(a.buffer)&&t.push(a.buffer)};for(const a of n.columns)i(a.values),i(a.presence),i(a.offsets);return t}}),je("packages/core/src/source/stream.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const Z=V("packages/core/src/internal/util.js"),M=Z.Lru,I=Z.isFunction,N=Z.now,W=Z.nextFrame,_=Z.cancelFrame,H=Z.whenIdle,B=Z.defaultCompare,G=Z.warnOnce,D=Z.infoOnce,v=Z.getPath,k=V("packages/core/src/source/abort.js"),y=k.createAbortScope,c=k.isAbortError,o=V("packages/core/src/source/rows.js"),n=o.createRowFactory,t=o.lazyRowView,a=V("packages/core/src/source/gapbuffer.js").GapBuffer,s=V("packages/core/src/source/memory.js").createMemorySource,l=V("packages/core/src/source/filterwire.js").querySignature,m=V("packages/core/src/store/columnpack.js").isPortableSchema,b=25e4,g=Symbol("lattice.stream.storeBacked"),f=8,w=.1,S=1e3,h=50;function d(T){return Math.min(S,Math.max(h,Math.floor(T/4)))}function j(T){if(T instanceof Date)return T.getTime();if(typeof T=="number")return Number.isFinite(T)?T:NaN;if(typeof T=="string"){const A=T.trim();if(!A)return NaN;const P=Date.parse(A);return Number.isNaN(P)?Number(A):P}return NaN}function E(T,A){return new O(T,A)}class O{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=y();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#m=0;#p=0;#g=null;#w=null;#b=null;#v=!1;#y=!1;#S=!1;#A=!1;#j="";#O=0;#E=0;#C=0;#T=null;#I=1/0;#N=!1;#D=null;#M=null;#x=null;#W=null;#R=!1;#_=0;#B=0;#H=!1;constructor(A,P){this.#e=A||{mode:"stream"},this.#t=P||{},this.#s=n(this.#t),this.#l=new M(4096),this.#j=this.#Be();const L=(this.#t.config||{}).ingest;this.#R=!!L&&L.retainSource===!1,I(this.#e.open)||G("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#W=setInterval(()=>{this.#A||this.reload()},$),this.#W&&I(this.#W.unref)&&this.#W.unref()),this.#ae()}#ne(){const A=Number(this.#e.maxAge);return Number.isFinite(A)&&A>0?A:0}#ae(){const A=this.#ne();if(!A)return;const P=this.#e.ageBy;I(P)?this.#M=P:typeof P=="string"&&P?this.#M=L=>v(L,P):this.#M=null,this.#T=[],this.#D=setInterval(()=>{this.#A||this.#le()&&(this.#pe(),this.#je())},d(A)),this.#D&&I(this.#D.unref)&&this.#D.unref()}#le(){const A=this.#ne();return!A||!this.#T?!1:this.#N?!0:this.#I<Date.now()-A*(1+w)}#de(A,P){if(!this.#T)return;const L=this.#M?j(this.#M(P)):Date.now();this.#T[A]=L,Number.isNaN(L)||(L<this.#I&&(this.#I=L),L<Date.now()-this.#ne()&&(this.#N=!0))}#ie(){return this.#ce("groupBy",[]).length>0?!0:!!this.#ce("pivotMode",!1)&&this.#ce("pivotBy",[]).length>0}#oe(){if(this.#g||this.#A)return;const A=this.#ie();if(A&&!this.#w){this.#w=s({mode:"memory",rows:this.#n},this.#te()),this.#v=!1;return}!A&&this.#w&&(this.#w.destroy(),this.#w=null)}#te(){if(this.#b)return this.#b;const A=this,P={liveIndices:()=>A.#V(),live:L=>A.#n[L]!==void 0,source:L=>A.#ve(L),get physical(){return A.#n.length}};return this.#R&&(P.column=L=>{const $=A.#t.store;return $&&I($.column)?$.column(L):void 0}),this.#b=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#b}#V(){const A=new Uint32Array(this.#n.length);let P=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(A[P++]=L);return A.subarray(0,P)}#z(){return this.#g?this.#g:this.#w?(this.#v&&(this.#v=!1,this.#w.setRows(this.#n)),this.#w):null}invalidate(A="filter"){if(this.#g){this.#g.invalidate(A);return}this.#oe(),this.#w&&this.#w.invalidate(A),(A==="filter"||A==="sort")&&this.#L()}count(){const A=this.#z();return A?A.count():this.#r?this.#r.length:this.#O}matchCount(){const A=this.#z();return A&&I(A.matchCount)?A.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const A=this.#z();return A&&I(A.totalCount)?A.totalCount():this.#O}unfilteredRows(){const A=this.#z();if(A&&I(A.unfilteredRows))return A.unfilteredRows();const P=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const $=this.#Ne(L);$&&P.push($)}return P}at(A){const P=this.#z();if(P)return P.at(A);if(A<0||A>=this.count())return;const L=this.#r?this.#r.at(A):A,$=this.#Ne(L);return $.index=A,$}byKey(A){const P=this.#z();if(P)return P.byKey(A);const L=this.#a.get(A);return L===void 0?void 0:this.#Ne(L)}leavesOf(A){const P=this.#z();return P&&I(P.leavesOf)?P.leavesOf(A):[]}loaded(A){return A>=0&&A<this.count()}hint(A,P){if(this.#g){this.#g.hint(A,P);return}this.#Z(),this.#m=Math.max(0,Math.floor(A))}#Z(){this.#A||this.#Be()===this.#j||this.reload()}display(){const A=this.#z();return A?A.display():t(()=>this.count(),P=>this.at(P))}apply(A){if(this.#g)return this.#g.apply(A);const P={added:[],updated:[],removed:[]};if(!A)return P;if(A.update){let L=!1;for(const $ of A.update){const U=this.#a.get(this.#s.keyOf($,-1));if(U===void 0)continue;const x=this.#se(U);this.#R?this.#Ie(U,$):this.#n[U]=$,this.#l.delete(U),this.#Y(U,x),this.#T&&(this.#de(U,$),L=!0),this.#v=!0,P.updated.push(this.#Ne(U))}L&&this.#pe()}if(A.add&&A.add.length){const L=this.#ee(A.add);for(const $ of L)P.added.push(this.#Ne($))}return A.remove&&A.remove.length&&G("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#je(),P}reload(A){this.#u.abortAll("reload"),this.#We(),this.#w&&(this.#w.destroy(),this.#w=null),this.#v=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#E=0,this.#C=0,this.#T&&(this.#T=[]),this.#I=1/0,this.#N=!1,this.#y=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#j=this.#Be(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#A=!0,this.#W!==null&&(clearInterval(this.#W),this.#W=null),this.#D!==null&&(clearInterval(this.#D),this.#D=null),this.#T=null,this.#u.abortAll("destroyed"),this.#We(),this.#d!==null&&(this.#Ge(this.#d),this.#d=null),this.#w&&(this.#w.destroy(),this.#w=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#S||this.#A||!I(this.#e.open))return;this.#S=!0;const A=this.#u.begin("stream");this.#L(),this.#oe();let P;try{P=this.#e.open({sort:this.#ce("sort",[]),filters:this.#ce("filters",null),quick:this.#ce("quick","")||void 0,context:this.#ce("context",null),signal:A.signal})}catch($){this.#ke("source:error",{error:$});return}const L=I(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#x=L;try{for(;;){const $=await L.next();if(!A.current||this.#A)return;if($.done){this.#Te();return}if(await this.#q($.value,A),!A.current||this.#A)return;if($.value&&$.value.done){this.#Te();return}if(await this.#xe(),!A.current||this.#A)return}}catch($){if(c($))return;this.#ke("source:error",{error:$})}finally{A.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#O,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const A=this.#z();A&&(I(A.invalidateHandles)&&A.invalidateHandles(),I(A.invalidate)&&A.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#_,inline:this.#B,storeBacked:this.#R}}#q(A,P){if(!A)return;const L=A.rows;if(L&&L.length&&this.#G(L))return this.#be(A,P);const $=N();L&&L.length&&(this.#ee(L),this.#B++),this.#K(A),this.#f+=N()-$,this.#je()}#K(A){this.#c.loaded=A.progress&&typeof A.progress.loaded=="number"?A.progress.loaded:this.#n.length,A.progress&&typeof A.progress.estimated=="number"&&(this.#c.estimated=A.progress.estimated)}#G(A){if(this.#H||this.#g)return!1;const P=this.#we();if(!P)return!1;const L=this.#t.store;if(!L||!I(L.appendPacked))return!1;const $=this.#Me();return!$||!m($)?(this.#H=!0,D("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):A.length<P.threshold?!1:!this.#me(A)}#me(A){if(!this.#s.keyed)return!1;const P=new Set;for(let L=0;L<A.length;L++){const $=this.#s.keyOf(A[L],this.#n.length+L);if($!=null){if(P.has($)||this.#a.has($))return!0;P.add($)}}return!1}async#be(A,P){const L=A.rows,$=this.#we(),U=this.#Me();let x;try{x=await $.columnize(U,L,{key:"ingest:stream",signal:P&&P.signal})}catch(Q){if(c(Q)||(G("source.stream.columnize","worker columnization failed; columnizing on the main thread",Q),this.#H=!0,P&&(!P.current||this.#A)))return;this.#ee(L),this.#B++,this.#K(A),this.#je();return}if(P&&(!P.current||this.#A))return;const F=this.#t.store,C=this.#R?void 0:L,{from:z}=F.appendPacked(x,C),q=x.count|0;for(let Q=0;Q<q;Q++){const Y=z+Q,J=L[Q],te=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#R?g:J,this.#O++,this.#de(Y,J),te!==null&&this.#a.set(te,Y),!this.#r||!this.#Oe(Y))continue;const ee=this.#k(Y);this.#r.insert(ee,Y),ee<=this.#m&&this.#p++}this.#v=!0,this.#pe(),this.#_++,this.#K(A),this.#je()}#we(){const A=this.#t.ingestWorker;return I(A)?A():null}#Me(){const A=this.#t.storeSchema;return I(A)?A():null}#ee(A){const P=[],L=this.#t.store,$=new Array(A.length),U=[],x=new Set;for(let C=0;C<A.length;C++){const z=this.#s.keyed?this.#s.keyOf(A[C],this.#n.length+U.length):null;$[C]=z,!(z!==null&&(this.#a.has(z)||x.has(z)))&&(z!==null&&x.add(z),U.push(A[C]))}let F=U.length&&L&&I(L.append)?L.append(U).from:this.#n.length;for(let C=0;C<A.length;C++){const z=A[C],q=$[C];if(q!==null&&this.#a.has(q)){const J=this.#a.get(q),te=this.#se(J);this.#R||(this.#n[J]=z,L&&I(L.setSource)&&L.setSource(J,z)),this.#Ie(J,z),this.#l.delete(J),this.#de(J,z),this.#Y(J,te);continue}const Q=F++;if(this.#n[Q]=this.#R?g:z,this.#O++,this.#de(Q,z),q!==null&&this.#a.set(q,Q),P.push(Q),!this.#r||!this.#Oe(Q))continue;const Y=this.#k(Q);this.#r.insert(Y,Q),Y<=this.#m&&this.#p++}return this.#v=!0,this.#pe(),P}#fe(A){const P=this.#n[A];let L=!1;if(this.#r){const F=this.#U(A);F>=0&&F<=this.#m&&(L=!0)}else A<=this.#m&&(L=!0);const $=P===g?this.#ve(A):P,U=this.#s.keyed?this.#s.keyOf($,A):null;U!==null&&this.#a.get(U)===A&&this.#a.delete(U),this.#n[A]=void 0,this.#T&&(this.#T[A]=NaN),this.#l.delete(A);const x=this.#t.store;return x&&I(x.remove)&&x.remove(A),this.#O--,L}#pe(){let A=0,P=0;const L=this.#ue();A+=L.dropped,P+=L.aboveAnchor;const $=this.#ge();A+=$.dropped,P+=$.aboveAnchor,A&&(this.#v=!0,this.#E+=A,this.#L(),this.#p-=P,this.#ke("stream:evicted",{evicted:A,total:this.#E,live:this.#O}))}#ge(){const A=this.#e.maxRows;if(!Number.isFinite(A)||A<=0||this.#O<=A)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(A*(1-w)));let L=0,$=0;for(;this.#O>P&&this.#C<this.#n.length;){const U=this.#C++;this.#n[U]!==void 0&&(this.#fe(U)&&$++,L++)}return{dropped:L,aboveAnchor:$}}#ue(){const A=this.#ne();if(!A||!this.#T||!this.#le())return{dropped:0,aboveAnchor:0};const P=Date.now()-A;let L=0,$=0,U=1/0;for(let x=this.#C;x<this.#n.length;x++){if(this.#n[x]===void 0)continue;const F=this.#T[x];if(!(Number.isNaN(F)||F===void 0)){if(F>=P){F<U&&(U=F);continue}this.#fe(x)&&$++,L++}}for(this.#I=U,this.#N=!1;this.#C<this.#n.length&&this.#n[this.#C]===void 0;)this.#C++;return{dropped:L,aboveAnchor:$}}#U(A){if(!this.#r)return A;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===A)return P;return-1}#L(){this.#o=this.#ce("sort",[]),this.#i=this.#ce("filters",null);const A=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ne()>0,P=this.#ce("where",null),L=(this.#t.config||{}).hostFilter,$=!!(P&&P.active)||!!(L&&I(L.active)&&L.active());if(!(A||this.#o.length>0||!!this.#i||!!this.#ce("quick","")||$)){this.#r=null;return}this.#r=new a(Math.max(64,this.#n.length+64));for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&this.#Oe(x)&&this.#r.insert(this.#k(x),x)}#Oe(A){const P=this.#ve(A);if(this.#i&&!this.#re(this.#i,P))return!1;const L=String(this.#ce("quick","")||"").toLowerCase();if(L&&!this.#Ke(P).includes(L))return!1;const $=(this.#t.config||{}).hostFilter;if($&&I($.active)&&$.active()&&!$.passes(this.#Ne(A)))return!1;const U=this.#ce("where",null);if(U&&U.active){const x=this.#Ne(A);if(!U.passes(x.data,x.key))return!1}return!0}#re(A,P){if(!A)return!0;const L=A;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some(x=>this.#re(x,P)):L.op==="not"?!L.conditions.some(x=>this.#re(x,P)):L.conditions.every(x=>this.#re(x,P));const $=A,U=(this.#t.compute||{}).testValue;return I(U)?!!U(this.#X(P,$.col),$,(this.#t.config||{}).locale):(G("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#se(A){if(!this.#r)return-1;if(!this.#o.length)return this.#U(A);let P=0,L=this.#r.length;for(;P<L;){const $=P+L>>>1;this.#Ee(this.#r.at($),A)<0?P=$+1:L=$}for(let $=P;$<this.#r.length;$++){const U=this.#r.at($);if(U===A)return $;if(this.#Ee(U,A)>0)break}return this.#U(A)}#Y(A,P){if(!this.#r||!this.#o.length)return;const L=this.#Oe(A);if(P>=0&&this.#r.at(P)===A)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!L)return;const $=this.#k(A);this.#r.insert($,A),$<=this.#m&&this.#p++}#k(A){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,L=this.#r.length;for(;P<L;){const $=P+L>>>1;this.#Ee(A,this.#r.at($))<0?L=$:P=$+1}return P}#Ee(A,P){const L=this.#ve(A),$=this.#ve(P);for(const U of this.#o){const x=this.#nt(U.col),F=this.#X(L,U.col),C=this.#X($,U.col),q=(x&&x.value&&I(x.value.compare)?x.value.compare:B)(F,C);if(q!==0)return U.dir==="desc"?-q:q}return 0}#Te(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const A=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:b;!this.#R&&this.#n.length<A&&(this.#g=s({mode:"memory",rows:this.#n},this.#t),this.#D!==null&&(clearInterval(this.#D),this.#D=null),this.#w&&(this.#w.destroy(),this.#w=null)),this.#je(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:A})}#je(){this.#d!==null||this.#A||(this.#d=this.#ze(()=>{this.#d=null,this.#h++;const A=this.#p;this.#p=0,this.#f=0,this.#ke("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:A,anchor:this.#m}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#xe(){return this.#h===0||this.#f<this.#De()?Promise.resolve():(this.#f=0,new Promise(A=>{const P=(this.#t.scheduler||{}).idle;I(P)?P(()=>A()):H(()=>A())}))}#De(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:f}#ze(A){const P=this.#t.scheduler||{};return I(P.frame)?P.frame(A):W(A)}#Ge(A){const P=this.#t.scheduler||{};I(P.cancel)?P.cancel(A):_(A)}#ve(A){const P=this.#n[A];if(P!==void 0&&P!==g)return P;if(P===void 0)return;const L=this.#t.store;return L&&I(L.source)?L.source(A):void 0}#Ie(A,P){const L=this.#t.store;if(!L||!I(L.set))return;const $=this.#Me();if(Array.isArray($))for(const U of $){if(!U||!U.id)continue;const x=I(U.read)?U.read:F=>v(F,U.field||U.id);L.set(U.id,A,x(P))}}#Ne(A){let P=this.#l.get(A);return P||(P=this.#s.leaf(this.#ve(A),A),this.#l.set(A,P)),P}#X(A,P){const L=this.#nt(P);return L&&I(L.getValue)?L.getValue(A):A?.[P]}#Ke(A){const P=this.#t.columns,L=P&&I(P.all)?P.all():[],$=[];for(const U of L){const x=I(U.getValue)?U.getValue(A):void 0;x!=null&&x!==""&&$.push(String(x))}return $.join(" ").toLowerCase()}#nt(A){const P=this.#t.columns;return P&&I(P.get)?P.get(A):void 0}#We(){const A=this.#x;if(this.#x=null,A&&I(A.return))try{A.return()}catch{}}#Be(){return l({context:this.#ce("context",null)})}#ce(A,P){const L=this.#t.state;if(L&&I(L[A])){const $=L[A]();return $??P}return P}#ke(A,P){const L=this.#t.emit;I(L)&&L(A,P)}}}),je("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 v}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isObject,N=Z.isFunction,W=Z.getPath,H=V("packages/core/src/source/abort.js").isAbortError,B=500,G=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),D=Symbol("lattice.url.skip");function v(m,b={}){const g=I(b)?b:{},f=N(g.fetch)?g.fetch:typeof globalThis<"u"&&N(globalThis.fetch)?globalThis.fetch:null,w=g.format==="json"||g.format==="ndjson"?g.format:void 0,S=typeof g.rowsPath=="string"&&g.rowsPath?g.rowsPath:void 0,h=N(g.map)?g.map:void 0,d=I(g.headers)?g.headers:void 0,j=Number.isFinite(g.batchSize)&&g.batchSize>0?Math.floor(g.batchSize):B,E=g.lenient===!0,O=Number.isFinite(g.poll)&&g.poll>0?Math.floor(g.poll):void 0,T=typeof m=="string"&&m.length>0;T||M("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*A(L={}){if(!T)return;if(!f)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const $=L&&L.signal;let U;try{U=await f(m,d?{signal:$,headers:d}:{signal:$})}catch(C){throw H(C)?C:new Error(`[lattice] createUrlSource: request to ${m} failed — ${C&&C.message||C}`)}if(!U||!U.ok){const C=U?U.status:"no response";throw new Error(`[lattice] createUrlSource: ${C} for ${m}`)}const x=k(m,w,U),F=U.body&&N(U.body.getReader)?U.body.getReader():null;try{if(!F){const q=await U.text();(x||o(q,m))==="ndjson"?yield*s(null,null,q,0,U,m,j,E):yield*r(q,m,S,h);return}const C=new TextDecoder("utf-8");if(x==="json"){yield*r(await a(F,C,""),m,S,h);return}if(x==="ndjson"){yield*s(F,C,"",0,U,m,j,E);return}const z=await n(F,C,m);z.format==="json"?yield*r(await a(F,C,z.seed),m,S,h):yield*s(F,C,z.seed,z.bytes,U,m,j,E)}finally{if(F&&N(F.cancel))try{await F.cancel()}catch{}}}const P={mode:"stream",open:A,autoStart:g.autoStart!==!1};return O!==void 0&&(P.poll=O),Number.isFinite(g.maxRows)&&(P.maxRows=g.maxRows),Number.isFinite(g.maxAge)&&(P.maxAge=g.maxAge),(typeof g.ageBy=="string"||N(g.ageBy))&&(P.ageBy=g.ageBy),Number.isFinite(g.coalesceMs)&&(P.coalesceMs=g.coalesceMs),Number.isFinite(g.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=g.promoteToMemoryBelow),P}function k(m,b,g){if(b)return b;const f=y(m);if(f)return f;const w=g&&g.headers&&N(g.headers.get)?g.headers.get("content-type"):null;return c(w)}function y(m){const b=String(m).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function c(m){if(!m)return;const b=m.split(";")[0].trim().toLowerCase();if(G.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function o(m,b){const g=m.replace(/^\s+/,""),f=t(g);if(f==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return f}async function n(m,b,g){let f="",w=0;for(;;){const{value:h,done:d}=await m.read();if(h&&(w+=h.byteLength,f+=b.decode(h,{stream:!0})),d){f+=b.decode();break}const j=f.replace(/^\s+/,"");if(j){if(j[0]==="[")return{format:"json",seed:f,bytes:w};if(j[0]!=="{"||f.indexOf(`
|
|
8
8
|
`)!==-1)break}}const S=t(f.replace(/^\s+/,""));if(S==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${g} — pass opts.format: 'json' | 'ndjson'.`);return{format:S,seed:f,bytes:w}}function t(m){if(!m||m[0]==="[")return"json";if(m[0]!=="{")return"error";const b=m.indexOf(`
|
|
9
9
|
`);if(b===-1)return"json";let g=m.slice(0,b);return g.endsWith("\r")&&(g=g.slice(0,-1)),i(g)?"ndjson":"json"}function i(m){try{return JSON.parse(m),!0}catch{return!1}}async function a(m,b,g){let f=g;for(;;){const{value:w,done:S}=await m.read();if(w&&(f+=b.decode(w,{stream:!0})),S)break}return f+=b.decode(),f}function*r(m,b,g,f){let w;try{w=JSON.parse(m)}catch(h){throw new Error(`[lattice] createUrlSource: ${b} is not valid JSON — ${h.message}`)}let S=g!==void 0?W(w,g):w;if(f&&(S=f(S)),!Array.isArray(S)){const h=g!==void 0||f?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${b} did not resolve to an array${h}.`)}yield{rows:S,progress:{loaded:S.length,estimated:S.length}}}async function*s(m,b,g,f,w,S,h,d){const j=p(w);let E=g||"",O=f||0,T=0,A=0,P=[];function*L(){let U;for(;(U=E.indexOf(`
|
|
@@ -53,6 +53,6 @@ ${te}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
53
53
|
`,w),E=g.slice(d,j),O=E.split(`
|
|
54
54
|
`);let T=0;const A=O.map(P=>{if(!m)return T+=S.length,S+P;if(P.startsWith(S))return T-=S.length,P.slice(S.length);const L=P.replace(/^[ \t]/,"");return T-=P.length-L.length,L}).join(`
|
|
55
55
|
`);return A===E?!1:(b.value=g.slice(0,d)+A+g.slice(j),this.#r(Math.max(d,f+(m?-S.length:S.length)),Math.max(d,w+T)),this.revalidate(),!0)}#r(m,b){const g=this.input;g&&(g.selectionStart=m,g.selectionEnd=b===void 0?m:b,H(g.setSelectionRange)&&g.setSelectionRange(g.selectionStart,g.selectionEnd))}format(m){const b=this.input;if(!b||this.language!=="json")return!1;const g=n(b.value);if(!g.ok)return this.revalidate(),!1;if(g.value===null&&b.value.trim()==="")return!1;try{const f=JSON.stringify(g.value,null,m===void 0?this.indent:m);return f===void 0?!1:(b.value=f,this.#r(f.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const m=this.input?this.input.value:"",b=r(m,this.language);this.lastResult=b;const g=this.errorNode;return g&&(g.textContent=b.ok?"":s(b),g.classList.toggle(v.errorOn,!b.ok)),this.input&&(b.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),b.ok||!g?this.input.removeAttribute("aria-errormessage"):(g.id||(g.id=B("lat-err")),this.input.setAttribute("aria-errormessage",g.id))),b}text(){return this.input?this.input.value:""}readValue(){const m=this.text();if(m.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return m;const g=n(m);return g.ok?g.value:m}checkValue(m){if(this.props.allowInvalid===!0)return!0;const b=this.revalidate();return b.ok?!0:s(b)}toClipboard(){return this.text()}fromClipboard(m){const b=m==null?"":String(m);return this.input&&(this.input.value=b),this.revalidate(),b.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:b}:{ok:!0,value:D(b)}}destroy(){for(const m of this.#e)m();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const l=u}),je("packages/dom/src/editors/unit.js",function(e,V){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,H=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/unit.js"),G=B.parseUnit,D=B.formatUnit,v=B.findUnit;function k(o,n){return D(o,n)}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.props,t=this.params.column&&this.params.column.dataType||null,i=t&&t.unitConfig||{};return{system:n.system||i.system||"data",unit:n.unit??i.unit,binary:n.binary===!0||n.binary===void 0&&i.binary===!0,display:n.display??i.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const n=this.props;this.opts=this.buildOptions();const t=this.symbol(),i=`${this.id}-unit`,a=N(this.doc,"input",{class:I.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?i:null}});a.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(a.value=this.params.key),this.input=a;const r=typeof n.step=="number"?n.step:0;return r>0&&this.#e.push(W(a,"keydown",s=>{s.key==="ArrowUp"?(H(s.preventDefault)&&s.preventDefault(),this.nudge(r)):s.key==="ArrowDown"&&(H(s.preventDefault)&&s.preventDefault(),this.nudge(-r))})),this.hint=N(this.doc,"span",{class:`${I.editor}__suffix`,text:t,attrs:{id:i,"aria-hidden":"true"}}),N(this.doc,"div",{class:`${I.editor}__unit`,children:[a,this.hint]})}symbol(){const n=v(this.opts.system,this.opts.unit);return n?n.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&H(n.select)&&n.select()}nudge(n){const t=G(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:a,max:r}=this.props;typeof a=="number"&&i<a&&(i=a),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=k(i,this.opts))}readValue(){const n=this.input?this.input.value:"";if(String(n).trim()==="")return null;const t=G(n,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:i,max:a}=this.props;let r=t;return typeof i=="number"&&r<i&&(r=i),typeof a=="number"&&r>a&&(r=a),r}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:i}=this.props;if(typeof t=="number"&&n<t)return`Must be ${this.describe(t)} or more`;if(typeof i=="number"&&n>i)return`Must be ${this.describe(i)} or less`}return!0}describe(n){return D(n,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return D(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(n){const t=n==null?"":String(n);if(t.trim()==="")return{ok:!0,value:null};const i=G(t,this.opts),a=i===null?NaN:i,r=this.checkValue(a);return r!==!0?{ok:!1,message:r}:{ok:!0,value:a}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const c=y}),je("packages/dom/src/editors/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,_=V("packages/core/src/internal/util.js"),H=_.isFunction,B=_.uid,G=V("packages/core/src/columns/types/radix.js"),D=G.compileRadixFormat,v=G.compileRadixParse,k=G.normaliseRadixOptions,y=G.radixRange,c=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"]),n=new Map;function t(s){const u=s||"";let l=n.get(u);if(l)return l;try{l=new Intl.NumberFormat(s||void 0,{maximumFractionDigits:0})}catch{l={format:p=>String(p)}}return n.set(u,l),l}function i(s,u){const l=u||{},p={};if(s){for(const b of o)s[b]!==void 0&&(p[b]=s[b]);const m=y(s.bitWidth??null,s.signed!==!1);typeof s.min=="number"&&s.min>m.min&&(p.min=s.min),typeof s.max=="number"&&s.max<m.max&&(p.max=s.max)}for(const m of o)l[m]!==void 0&&(p[m]=l[m]);return typeof l.min=="number"&&(p.min=l.min),typeof l.max=="number"&&(p.max=l.max),k(p)}class a extends M{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const u=this.params.column&&this.params.column.dataType;this.options=i(u&&u.radix||null,this.props),this.format=D(this.options),this.parse=v(this.options);const l=N(this.doc,"input",{class:I.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}});l.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(l.value=this.params.key),this.input=l;const p=N(this.doc,"span",{class:c.hint,attrs:{"aria-live":"polite"}});this.hint=p,this.#e.push(W(l,"input",()=>this.refresh())),this.#e.push(W(l,"keydown",b=>this.#n(b)));const m=N(this.doc,"div",{class:c.root,children:[l,p]});return this.refresh(),m}focusTarget(){return this.input}attached(){super.attached();const u=this.input;u&&!this.params.key&&this.props.selectOnFocus!==!1&&H(u.select)&&u.select()}#t(u){return u.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(u)}#n(u){const l=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;u.key==="ArrowUp"?(H(u.preventDefault)&&u.preventDefault(),this.nudge(l)):u.key==="ArrowDown"&&(H(u.preventDefault)&&u.preventDefault(),this.nudge(-l))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(u){const{min:l,max:p}=this.options;return u<l?l:u>p?p:u}evaluate(){const u=this.input?String(this.input.value):"";if(u.trim()==="")return{value:null,message:null};const l=this.parse(u);return l.ok?{value:this.mode()==="clamp"?this.clamp(l.value):l.value,message:null}:this.mode()==="clamp"&&typeof l.value=="number"&&(l.reason==="range"||l.reason==="negative")?{value:this.clamp(l.value),message:null}:{value:NaN,message:this.messageFor(l.reason)}}messageFor(u){const l=this.options;return u==="negative"?`This column holds an unsigned ${l.bitWidth}-bit pattern; enter ${this.format(0)} or more`:u==="range"?`Must be between ${this.format(l.min)} and ${this.format(l.max)}`:`Enter a ${l.name} value, e.g. ${this.format(l.radix===2?5:26)}`}refresh(){const{value:u,message:l}=this.evaluate();if(this.input&&this.input.classList&&(l?this.input.classList.add(I.invalid):this.input.classList.remove(I.invalid),this.input.setAttribute("aria-invalid",l?"true":"false"),l&&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(l){this.hint.textContent=l,this.hint.classList&&this.hint.classList.add(c.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(c.hintInvalid),this.hint.textContent=u===null?"":`= ${t(this.params.locale).format(u)}`}}nudge(u){if(!this.input)return;const l=this.parse(this.input.value);let p;typeof l.value=="number"?p=l.value:typeof this.params.value=="number"?p=this.params.value:p=0,this.input.value=this.format(this.clamp(p+u)),this.refresh()}readValue(){return this.evaluate().value}checkValue(u){return u===null?!0:typeof u!="number"||Number.isNaN(u)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&u<0?this.messageFor("negative"):this.mode()==="reject"&&(u<this.options.min||u>this.options.max)?this.messageFor("range"):!0}toClipboard(){const u=this.readValue();return u===null||Number.isNaN(u)?this.input?String(this.input.value):"":this.format(u)}fromClipboard(u){const l=u==null?"":String(u);if(l.trim()==="")return{ok:!0,value:null};const p=this.parse(l);let m;if(p.ok)m=p.value;else if(this.mode()==="clamp"&&typeof p.value=="number"&&(p.reason==="range"||p.reason==="negative"))m=this.clamp(p.value);else return{ok:!1,message:this.messageFor(p.reason)};const b=this.checkValue(m);return b!==!0?{ok:!1,message:b}:{ok:!0,value:m}}destroy(){for(const u of this.#e)u();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const r=a}),je("packages/dom/src/editors/segmented.js",function(e,V){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,_=Z.keyOf,H=Z.normaliseLookup,B=Z.documentFor,G=Z.lookupFor,v=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,n=6;class t extends M{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(s){const u=s||{},l=i(u),p=G(u,l,{colId:u.column&&(u.column.id||u.column.field)}),m=Number(l.max??n),b=p.options().length;if(Number.isFinite(m)&&b>m){const g=new v;g.init(u),this.#e=g,this.params=u,this.doc=B(u),this.props=l,this.lookup=p,this.popup=g.popup;return}super.init(u),(!this.lookup||!this.lookup.options().length)&&(this.lookup=p)}usesFallback(){return this.#e!==null}build(){const s=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const u=N(s,"div",{class:`${I.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 l=0;l<this.options.length;l++)u.appendChild(this.buildSegment(this.options[l],l));return this.props.allowClear===!0&&u.appendChild(this.buildClear()),this.#t.push(W(u,"keydown",l=>this.onKeyDown(l))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),u}buildSegment(s,u){const l=this.doc,p=N(l,"button",{class:`${I.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":u,"data-variant":s.variant??null,"aria-disabled":s.disabled===!0?"true":null}});return s.icon&&p.appendChild(o(l,s.icon,{className:I.icon})),p.appendChild(N(l,"span",{class:`${I.editor}__segment-label`,text:s.label})),this.#t.push(W(p,"mousedown",m=>{m&&y(m.preventDefault)&&m.preventDefault(),s.disabled!==!0&&(this.focused=u,this.select(u,{commit:!0}))})),this.segments.push(p),p}buildClear(){const s=N(this.doc,"button",{class:`${I.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(s,"mousedown",u=>{u&&y(u.preventDefault)&&u.preventDefault(),this.clearSelection()})),s}indexOf(s){if(s==null)return-1;const u=_(s);for(let l=0;l<this.options.length;l++)if(_(this.options[l].id)===u)return l;return-1}paint(){for(let s=0;s<this.segments.length;s++){const u=s===this.indexOf(this.selected),l=this.segments[s];l.setAttribute("aria-checked",u?"true":"false"),l.setAttribute("tabindex",s===this.focused?"0":"-1"),l.classList.toggle(`${I.editor}__segment--active`,u),l.classList.toggle(`${I.editor}__segment--disabled`,this.options[s].disabled===!0)}}select(s,u){const l=this.options[s];!l||l.disabled===!0||(this.selected=l.id,this.paint(),u&&u.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(s){const u=this.segments.length;if(!u)return;let l=this.focused;for(let p=0;p<u;p++)if(l=(l+s+u)%u,this.options[l].disabled!==!0){this.focusAt(l);return}}focusAt(s){if(s<0||s>=this.segments.length)return;this.focused=s,this.paint();const u=this.segments[s];u&&y(u.focus)&&u.focus()}edgeIndex(s){const u=this.options.length;for(let l=0;l<u;l++){const p=s===1?l:u-1-l;if(this.options[p].disabled!==!0)return p}return-1}onKeyDown(s){const u=()=>{y(s.preventDefault)&&s.preventDefault()};switch(s.key){case"ArrowRight":case"ArrowDown":u(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":u(),this.moveFocus(-1);break;case"Home":u(),this.focusAt(this.edgeIndex(1));break;case"End":u(),this.focusAt(this.edgeIndex(-1));break;case"Enter":u(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":u(),this.select(this.focused);break;case"Escape":u(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(s){return s==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(s)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(s)}" 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 s=this.indexOf(this.selected);return this.segments[s>=0?s:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const s=this.lookup.ready();!s||!y(s.then)||s.then(()=>{if(!super.element()||this.options.length)return;const u=super.element();this.options=this.lookup.options();for(let l=0;l<this.options.length;l++)u.appendChild(this.buildSegment(this.options[l],l));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(s){return this.#e?this.#e.validate(s):super.validate(s)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(s){return this.#e?this.#e.fromClipboard(s):super.fromClipboard(s)}destroy(){for(const s of this.#t)s();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function i(r){return{...r.column&&r.column.edit&&r.column.edit.props||{},...r.props||{}}}const a=t}),je("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 i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,H=V("packages/dom/src/cell/icons.js").createIcon,B=V("packages/dom/src/cell/renderers/rating.js"),G=B.ratingFills,D=B.fillState,v=B.ratingText,k=B.clampRating,y=B.DEFAULT_RATING_ICON,c=B.DEFAULT_RATING_MAX,n=V("packages/core/src/internal/util.js").isFunction;class t extends M{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const s=Math.floor(Number(this.props.max??c));return Number.isFinite(s)&&s>0?s:c}step(){return this.props.allowHalf===!0?.5:1}build(){const s=this.doc,u=this.max();this.rating=i(this.params.value,u,this.props.allowHalf===!0);const l=N(s,"div",{class:`${I.editor}__rating`}),p=N(s,"div",{class:`${I.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(u),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let b=0;b<u;b++)p.appendChild(this.buildItem(b));l.appendChild(p),this.slider=p;const m=N(s,"span",{class:`${I.editor}__rating-value`});return l.appendChild(m),this.readout=m,this.props.allowClear===!0&&l.appendChild(this.buildClear()),this.#e.push(W(p,"keydown",b=>this.onKeyDown(b))),this.props.hoverPreview!==!1&&this.#e.push(W(p,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),u)),this.paint(),l}buildItem(s){const u=this.doc,l=String(this.props.icon??y),p=N(u,"span",{class:`${I.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[H(u,l,{className:I.icon})]}),m=N(u,"span",{class:`${I.editor}__rating-item`,attrs:{"data-index":s,"data-icon":l,"aria-hidden":"true"},children:[H(u,l,{className:I.icon}),p]});return this.fills.push(p),this.#e.push(W(m,"mousedown",b=>{b&&n(b.preventDefault)&&b.preventDefault(),this.setRating(this.ratingAt(s,b),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(m,"mousemove",b=>{const g=this.ratingAt(s,b);g!==this.preview&&(this.preview=g,this.paint())})),this.items.push(m),m}buildClear(){const s=N(this.doc,"button",{class:`${I.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(s,"mousedown",u=>{u&&n(u.preventDefault)&&u.preventDefault(),this.setRating(null)})),s}ratingAt(s,u){if(this.props.allowHalf!==!0)return s+1;const l=this.items[s],p=l&&Number(l.offsetWidth),m=u&&Number(u.offsetX);return!Number.isFinite(p)||p<=0||!Number.isFinite(m)?s+1:m*2<p?s+.5:s+1}focusTarget(){return this.slider}setRating(s,u){this.rating=s===null?null:k(s,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),u&&u.commit&&this.commit()}nudge(s){const u=this.rating===null?0:this.rating;this.setRating(u+s)}paint(){const s=this.max(),u=this.props.allowHalf===!0,l=this.preview===null?this.rating:this.preview,p=G(l===null?0:l,s,{allowHalf:u});for(let g=0;g<this.items.length;g++){const f=D(p[g]);this.items[g].setAttribute("data-fill",f),this.items[g].classList.toggle(`${I.editor}__rating-item--filled`,f!=="empty"),this.fills[g]&&this.fills[g].style.setProperty("--lat-rating-fill",`${(p[g]*100).toFixed(2)}%`)}const m=l===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:v(l),max:s}),b=this.slider;b&&(b.setAttribute("aria-valuenow",l===null?"0":String(l)),b.setAttribute("aria-valuetext",m),b.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=m)}onKeyDown(s){const u=()=>{n(s.preventDefault)&&s.preventDefault()},l=this.step();if(/^[0-9]$/.test(s.key)){u(),this.setRating(Math.min(Number(s.key),this.max()));return}switch(s.key){case"ArrowRight":case"ArrowUp":u(),this.nudge(l);break;case"ArrowLeft":case"ArrowDown":u(),this.nudge(-l);break;case"Home":u(),this.setRating(0);break;case"End":u(),this.setRating(this.max());break;case"Enter":u(),this.commit();break;case"Escape":u(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(u(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(s){if(s==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof s!="number"||!Number.isFinite(s))return"Enter a rating";const u=this.max();return s<0?"Must be 0 or more":s>u?`Must be ${u} or less`:this.props.allowHalf!==!0&&!Number.isInteger(s)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":v(this.rating)}fromClipboard(s){const u=String(s??"").trim();if(u==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const l=Number(u);if(!Number.isFinite(l))return{ok:!1,message:`"${u}" is not a rating`};const p=this.checkValue(l);return p!==!0?{ok:!1,message:p}:{ok:!0,value:l}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function i(r,s,u){if(r==null||r==="")return null;const l=Number(r);return Number.isFinite(l)?k(l,s,u,!1):null}const a=t}),je("packages/dom/src/editors/slider.js",function(e,V){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,_=V("packages/dom/src/editors/number.js"),H=_.parseNumberText,B=_.presentNumber,D=V("packages/core/src/internal/util.js").isFunction,v=0,k=100;class y extends M{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const a=Number(this.props.min??v);return Number.isFinite(a)?a:v}max(){const a=Number(this.props.max??k);return Number.isFinite(a)?a:k}step(){const a=Number(this.props.step??1);return Number.isFinite(a)&&a>0?a:1}build(){const a=this.doc,r=this.min(),s=this.max(),u=this.step(),l=n(this.props.marks);this.marks=l,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const p=N(a,"div",{class:`${I.editor}__slider`});this.root=p;const m=N(a,"input",{class:`${I.editor}__slider-input`,attrs:{type:"range",min:String(r),max:String(s),step:String(u),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:l.length?`${this.id}-marks`:null}});if(this.range=m,p.appendChild(m),l.length){const g=N(a,"datalist",{attrs:{id:`${this.id}-marks`}}),f=N(a,"div",{class:`${I.editor}__slider-marks`});for(const w of l){g.appendChild(N(a,"option",{attrs:{value:String(w.value),label:w.label}}));const S=N(a,"span",{class:`${I.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});S.style&&D(S.style.setProperty)&&S.style.setProperty("--lat-slider-mark",`${(c(w.value,r,s)*100).toFixed(2)}%`),f.appendChild(S)}p.appendChild(g),p.appendChild(f)}const b=N(a,"input",{class:`${I.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=b,p.appendChild(b),this.props.showValue!==!1){const g=N(a,"span",{class:`${I.editor}__slider-value`});p.appendChild(g),this.readout=g}return this.#e.push(W(m,"input",()=>this.setAmount(Number(m.value),"range"))),this.#e.push(W(m,"change",()=>this.setAmount(Number(m.value),"range"))),this.#e.push(W(m,"keydown",g=>this.onKeyDown(g))),this.#e.push(W(b,"input",()=>this.onFieldInput())),this.#e.push(W(b,"change",()=>this.paint())),this.#e.push(W(b,"keydown",g=>this.onKeyDown(g))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(b.value=this.params.key,this.onFieldInput()),this.paint(),p}focusTarget(){return this.field}attached(){super.attached();const a=this.field;a&&!this.params.key&&this.props.selectOnFocus!==!1&&D(a.select)&&a.select()}snap(a){if(!Number.isFinite(a))return this.min();const r=this.min(),s=this.max(),u=this.step(),l=Math.min(Math.max(a,r),s),p=r+Math.round((l-r)/u)*u,m=o(u),b=m>0?Number(p.toFixed(m)):Math.round(p);return Math.min(Math.max(b,r),s)}setAmount(a,r){this.amount=a===null?null:this.snap(a),this.paint(r)}onFieldInput(){const a=this.field?String(this.field.value):"";if(a.trim()===""){this.amount=null,this.paint("field");return}const r=H(a,this.params.locale);if(r===null||Number.isNaN(r)){this.paint("field");return}this.setAmount(r,"field")}paint(a){const r=this.min(),s=this.max(),u=this.amount,l=u===null?r:u;this.range&&a!=="range"&&(this.range.value=String(l)),this.field&&a!=="field"&&(this.field.value=u===null?"":B(u,this.props));const p=this.root;p&&p.style&&D(p.style.setProperty)&&p.style.setProperty("--lat-slider-pos",`${(c(l,r,s)*100).toFixed(2)}%`),p&&p.setAttribute&&p.setAttribute("data-empty",u===null?"true":"false");const m=this.labelFor(u);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",m),this.readout&&(this.readout.textContent=m)}labelFor(a){if(a===null)return String(this.props.emptyLabel??"");const r=this.marks.find(u=>u.value===a),s=B(a,this.props);return r&&r.label!==s?`${s} (${r.label})`:s}onKeyDown(a){if(a.key==="Escape"){D(a.preventDefault)&&a.preventDefault(),this.cancel();return}if(a.key==="Enter"){D(a.preventDefault)&&a.preventDefault(),this.commit();return}a.key==="Tab"&&this.commit()}readValue(){const a=this.field?String(this.field.value):"";if(a.trim()==="")return null;const r=H(a,this.params.locale);return r===null||Number.isNaN(r)?NaN:this.snap(r)}checkValue(a){return a==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof a!="number"||Number.isNaN(a)?"Enter a number":a<this.min()?`Must be ${this.min()} or more`:a>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(a){const r=String(a??"").trim();if(r==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const s=H(r,this.params.locale);if(s===null||Number.isNaN(s))return{ok:!1,message:"Enter a number"};const u=this.snap(s),l=this.checkValue(u);return l!==!0?{ok:!1,message:l}:{ok:!0,value:u}}destroy(){for(const a of this.#e)a();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function c(i,a,r){const s=r-a;return!Number.isFinite(s)||s===0?0:Math.min(1,Math.max(0,(Number(i)-a)/s))}function o(i){if(!Number.isFinite(i))return 0;const a=String(i),r=a.indexOf("e");if(r>=0){const u=a.slice(0,r),l=u.indexOf("."),p=l<0?0:u.length-l-1;return Math.min(15,Math.max(0,p-Number(a.slice(r+1))))}const s=a.indexOf(".");return s<0?0:Math.min(15,a.length-s-1)}function n(i){if(!i)return[];const a=[];if(Array.isArray(i)){for(const r of i){if(r&&typeof r=="object"){const u=Number(r.value);Number.isFinite(u)&&a.push({value:u,label:String(r.label??u)});continue}const s=Number(r);Number.isFinite(s)&&a.push({value:s,label:String(s)})}return a}if(typeof i=="object")for(const[r,s]of Object.entries(i)){const u=Number(r);Number.isFinite(u)&&a.push({value:u,label:String(s)})}return a}const t=y}),je("packages/dom/src/editors/colour.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"toSwatches",{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"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,_=V("packages/dom/src/cell/renderers/colour.js"),H=_.normaliseColour,B=_.parseColour,D=V("packages/core/src/internal/util.js").isFunction,v=Object.freeze(["neutral","info","success","warning","danger","accent"]),k=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(a){if(a==null)return null;if(typeof a=="object"){const u=a,l=y(u.token??u.value??u.colour??u.color);return l?{...l,label:u.label==null?l.label:String(u.label)}:null}const r=String(a).trim();if(r==="")return null;const s=H(r);return s?{token:null,hex:s,label:s}:Object.hasOwn(k,r)?{token:r,hex:k[r],label:r}:null}function c(a,r){const s=a&&a.ownerDocument,u=s&&s.defaultView;if(!u||!D(u.getComputedStyle))return null;try{const l=u.getComputedStyle(a);return!l||!D(l.getPropertyValue)?null:H(String(l.getPropertyValue(`--lattice-variant-${r}-solid`)).trim())}catch{return null}}class o extends M{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const r=this.doc;this.swatches=n(this.props.swatches);const s=N(r,"div",{class:`${I.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=N(r,"span",{class:`${I.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),s.appendChild(this.preview),this.swatches.length){const l=N(r,"div",{class:`${I.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let p=0;p<this.swatches.length;p++)l.appendChild(this.buildSwatch(this.swatches[p],p));s.appendChild(l)}this.native=N(r,"input",{class:`${I.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),s.appendChild(this.native),this.hex=N(r,"input",{class:`${I.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),s.appendChild(this.hex),this.props.allowClear===!0&&s.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",l=>this.onKeyDown(l))),this.#e.push(W(s,"keydown",l=>this.onKeyDown(l)));const u=H(this.params.value,{alpha:this.alpha()});return this.hex.value=u===null?this.params.value==null?"":String(this.params.value):u,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),s}buildSwatch(r,s){const u=N(this.doc,"button",{class:`${I.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":r.label,"data-index":s,"data-variant":r.token}});return r.token||t(u,r.hex),this.#e.push(W(u,"mousedown",l=>{l&&D(l.preventDefault)&&l.preventDefault(),this.setColour(this.swatches[s].hex)})),this.buttons.push(u),u}buildClear(){const r=N(this.doc,"button",{class:`${I.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(r,"mousedown",s=>{s&&D(s.preventDefault)&&s.preventDefault(),this.setColour(null)})),r}focusTarget(){return this.hex}attached(){super.attached();for(let r=0;r<this.swatches.length;r++){const s=this.swatches[r];if(!s.token)continue;const u=c(this.buttons[r]||this.element(),s.token);u&&(s.hex=u)}this.paint()}setColour(r){const s=r===null?null:H(r,{alpha:this.alpha()});this.hex&&(this.hex.value=s===null?"":s),this.paint()}current(){const r=this.hex?String(this.hex.value).trim():"";return r===""?null:H(r,{alpha:this.alpha()})}paint(){const r=this.current(),s=r===null?null:r.slice(0,7);t(this.preview,s),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",r===null?"true":"false"),this.native&&(this.native.value=s===null?"#000000":s);for(let u=0;u<this.buttons.length;u++){const l=r!==null&&this.swatches[u].hex.toLowerCase()===r.toLowerCase();this.buttons[u].setAttribute("aria-checked",l?"true":"false"),this.buttons[u].classList.toggle(`${I.editor}__colour-swatch--selected`,l),this.swatches[u].token||t(this.buttons[u],this.swatches[u].hex)}}onKeyDown(r){if(r.key==="Escape"){D(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){D(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.hex?String(this.hex.value).trim():"";if(r==="")return null;const s=H(r,{alpha:this.alpha()});return s===null?r:s}checkValue(r){if(r==null||r==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const s=B(r);return s?!this.alpha()&&s.a<1?"This column does not accept transparency":!0:`"${String(r)}" is not a colour`}toClipboard(){const r=this.current();return r===null?"":r}fromClipboard(r){const s=String(r??"").trim();if(s==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const u=H(s,{alpha:this.alpha()});if(u===null)return{ok:!1,message:`"${s}" is not a colour`};const l=this.checkValue(u);return l!==!0?{ok:!1,message:l}:{ok:!0,value:u}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function n(a){const r=Array.isArray(a)&&a.length?a:a===!1?[]:v,s=[];for(const u of r){const l=y(u);l&&s.push(l)}return s}function t(a,r){const s=a&&a.style;if(s){if(r===null){D(s.removeProperty)&&s.removeProperty("--lat-swatch");return}D(s.setProperty)&&s.setProperty("--lat-swatch",r)}}const i=o}),je("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 i}});const M=V("packages/dom/src/editors/select.js").SelectEditorBase,N=V("packages/dom/src/cell/icons.js").createIcon,W=V("packages/dom/src/editors/common.js"),_=W.CLS,H=W.el,B=W.on,G=W.clear,D=W.keyOf,v=W.rawOptions,k=W.lookupKey,y=V("packages/core/src/internal/util.js"),c=y.isFunction,o=y.isObject,n="\0";class t extends M{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 r=super.build();return r.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),r}initSelection(){this.rebuild(),this.selected=this.params.value??null;const r=this.nodeById(this.selected);if(r)for(let s=r.parent;s;s=s.parent)this.expanded.add(s.key)}rebuild(){const r=v(this.params,this.props),s=this.props.keys||{},u=s.value||k(this.params,"valueKey")||"id",l=s.label||k(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const p of r){if(!o(p)){this.addNode(null,String(p??""),p,null);continue}Array.isArray(p.path)&&p.path.length?this.addByPath(p,u,l):this.addByChildren(p,null,u,l)}if(this.props.defaultExpanded===!0)for(const p of this.nodes.keys())this.expanded.add(p)}addNode(r,s,u,l){const p=r?`${r.key}${n}${s}`:s;let m=this.nodes.get(p);return m?m.id===void 0&&u!==void 0&&(m.id=u):(m={id:u,label:s,key:p,parent:r,children:[],depth:r?r.depth+1:0,disabled:!1},this.nodes.set(p,m),(r?r.children:this.roots).push(m)),l&&(l.disabled===!0&&(m.disabled=!0),l.icon!==void 0&&(m.icon=l.icon),l.variant!==void 0&&(m.variant=l.variant)),m}addByPath(r,s,u){const l=r.path;let p=null;for(let m=0;m<l.length;m++){const b=m===l.length-1,g=String(l[m]),f=b&&r[u]!=null?String(r[u]):g,w=this.addNode(p,g,b?r[s]:void 0,b?r:null);b&&(w.label=f),p=w}}addByChildren(r,s,u,l){const p=r[u],m=r[l]!=null?String(r[l]):String(p??""),b=this.addNode(s,m,p,r),g=Array.isArray(r.children)?r.children:[];for(const f of g)o(f)?this.addByChildren(f,b,u,l):this.addNode(b,String(f??""),f,null)}nodeById(r){if(r==null)return;const s=D(r);for(const u of this.nodes.values())if(u.id!==void 0&&D(u.id)===s)return u}filterOptions(r){const s=String(r||"").trim().toLowerCase(),u=s!=="";this.matched=u?this.computeMatches(s):new Set;const l=[],p=m=>{for(const b of m)u&&!this.matched.has(b.key)||(l.push(b),b.children.length&&(u||this.expanded.has(b.key))&&p(b.children))};return p(this.roots),l}computeMatches(r){const s=new Set,u=l=>{let p=l.label.toLowerCase().includes(r);for(const m of l.children)u(m)&&(p=!0);return p&&s.add(l.key),p};for(const l of this.roots)u(l);return s}repaint(r){if(this.refreshOptions(),!r||!this.list)return;const s=this.visible.findIndex(u=>u.key===r);s>=0&&this.list.setActive(s)}isBranch(r){return!!r&&r.children.length>0}isSelectable(r){return!r||r.disabled||r.id===void 0||r.id===null?!1:!(this.leavesOnly&&this.isBranch(r))}setExpanded(r,s){this.isBranch(r)&&(s?this.expanded.add(r.key):this.expanded.delete(r.key),this.repaint(r.key))}choose(r){if(r){if(!this.isSelectable(r)){this.isBranch(r)&&this.setExpanded(r,!this.expanded.has(r.key));return}this.selected=r.id,this.input&&(this.input.value=""),this.query="",this.repaint(r.key),this.paintDisplay(),this.commit()}}isSelected(r){return this.selected!=null&&r&&r.id!==void 0&&D(r.id)===D(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(r){if(r==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const s=this.nodeById(r);return s&&this.isSelectable(s)?!0:s?`"${s.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(r)}" is not a valid option`}renderOption(r,s,u){G(s),s.setAttribute("role","treeitem"),s.setAttribute("aria-level",String(r.depth+1)),s.setAttribute("data-depth",String(r.depth));const l=H(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<r.depth;w++)l.appendChild(H(this.doc,"span",{class:"lat-tree__guide"}));s.appendChild(l);const p=this.isBranch(r),m=p&&(this.expanded.has(r.key)||this.query.trim()!==""),b=p?m?"chevronDown":"chevronRight":"blank",g=H(this.doc,"span",{class:p?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[N(this.doc,b,{className:_.icon})],attrs:{"data-icon":p?b:null,"aria-hidden":"true"}});p&&B(g,"mousedown",w=>{c(w.preventDefault)&&w.preventDefault(),c(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(r,!this.expanded.has(r.key))}),s.appendChild(g),r.icon&&s.appendChild(N(this.doc,r.icon,{className:_.icon})),s.appendChild(H(this.doc,"span",{class:`${_.option}__label`,text:r.label})),r.variant?s.setAttribute("data-variant",r.variant):s.removeAttribute("data-variant"),p?s.setAttribute("aria-expanded",m?"true":"false"):s.removeAttribute("aria-expanded");const f=this.isSelected(r);s.classList.toggle(_.optionSelected,f),s.classList.toggle(_.optionDisabled,!this.isSelectable(r)),s.classList.toggle("lat-tree__row--branch",p),s.setAttribute("aria-selected",f?"true":"false"),this.isSelectable(r)?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true")}paintDisplay(){const r=this.display;if(!r)return;if(G(r),this.selected==null){r.removeAttribute("data-variant");return}const s=this.nodeById(this.selected);if(!s){r.appendChild(H(this.doc,"span",{text:String(this.selected)}));return}s.icon&&r.appendChild(N(this.doc,s.icon,{className:_.icon})),r.appendChild(H(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(s)})),s.variant?r.setAttribute("data-variant",s.variant):r.removeAttribute("data-variant")}pathLabel(r){const s=[];for(let u=r;u;u=u.parent)s.unshift(u.label);return s.join(String(this.props.pathSeparator??" / "))}onKeyDown(r){const s=this.list,u=s&&s.active>=0?this.visible[s.active]:null;switch(r.key){case"ArrowRight":{if(c(r.preventDefault)&&r.preventDefault(),!u)return;this.isBranch(u)&&!this.expanded.has(u.key)?this.setExpanded(u,!0):this.isBranch(u)&&s&&s.setActive(Math.min(this.visible.length-1,s.active+1));return}case"ArrowLeft":{if(c(r.preventDefault)&&r.preventDefault(),!u)return;this.isBranch(u)&&this.expanded.has(u.key)?this.setExpanded(u,!1):u.parent&&this.focusNode(u.parent.key);return}case"Home":c(r.preventDefault)&&r.preventDefault(),s&&this.visible.length&&s.setActive(0);return;case"End":c(r.preventDefault)&&r.preventDefault(),s&&this.visible.length&&s.setActive(this.visible.length-1);return;default:super.onKeyDown(r)}}focusNode(r){if(!this.list)return;const s=this.visible.findIndex(u=>u.key===r);s>=0&&this.list.setActive(s)}acceptHighlight(r){const s=this.list,u=s&&s.active>=0?this.visible[s.active]:null;if(!u){r&&r.commit&&this.commit();return}if(this.isSelectable(u)){this.choose(u);return}this.isBranch(u)?this.setExpanded(u,!this.expanded.has(u.key)):r&&r.commit&&this.commit()}moveHighlight(r){const s=this.list;if(!s)return;let u=s.active;for(let l=0;l<this.visible.length;l++){if(u+=r,u<0||u>=this.visible.length)return;if(!this.visible[u].disabled){s.setActive(u);return}}}}const i=t}),je("packages/dom/src/editors/objectpicker.js",function(e,V){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const M=V("packages/dom/src/editors/select.js").SelectEditorBase,I=V("packages/dom/src/editors/common.js"),N=I.CLS,W=I.el,_=I.on,H=I.clear,B=I.keyOf,G=I.debounce,D=I.rawOptions,v=I.optionSource,k=I.lookupSearch,y=I.lookupKey,c=V("packages/core/src/internal/util.js"),o=c.isFunction,n=c.isObject,t=c.getPath,a=V("packages/dom/src/cell/icons.js").createIcon;class r extends M{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const b=super.build();if(b.classList.add("lat-objectpicker"),o(this.props.search)&&!(this.lookup&&this.lookup.search)){const g=Number(this.props.searchDebounce)||200;this.#n=G(f=>this.runRemoteSearch(String(f)),g)}return b}onQuery(b){super.onQuery(b),this.#n&&this.#n(b)}initSelection(){const b=D(this.params,this.props).map(g=>this.toOption(g));(b.length||!this.all.length)&&(this.all=b),this.selected=this.params.value??null}toOption(b){if(!n(b)){const d=b==null?"":String(b);return{id:b,label:d,secondary:"",avatar:"",initials:u(d),disabled:!1,raw:{}}}const g=this.props.valueKey||y(this.params,"valueKey")||"id",f=this.props.labelKey||y(this.params,"labelKey")||"label",w=s(b,this.props.template??f,""),S=s(b,this.props.secondary,""),h=s(b,this.props.avatar,"");return{id:b[g],label:w||String(b[g]??""),secondary:S,avatar:h,initials:u(w||String(b[g]??"")),disabled:b.disabled===!0,icon:b.icon,variant:b.variant,raw:b}}attached(){if(super.attached(),this.#t||this.all.length)return;const b=v(this.params,this.props);o(b)&&(this.#t=!0,Promise.resolve(b()).then(g=>{!this.element()||!Array.isArray(g)||(this.all=g.map(f=>this.toOption(f)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(b){const g=String(b||"").trim().toLowerCase();if(g==="")return this.all;const f=l(this.props.searchFields);return this.all.filter(w=>{if(!f)return w.label.toLowerCase().includes(g)||w.secondary.toLowerCase().includes(g);for(const S of f){const h=o(S)?S(w.raw):t(w.raw,S);if(h!=null&&String(h).toLowerCase().includes(g))return!0}return!1})}async runRemoteSearch(b){const g=k(this.params,this.props);if(!g)return;this.#e&&this.#e.abort();const f=new AbortController;this.#e=f;try{const w=await g(b,f.signal);if(f.signal.aborted||this.#e!==f)return;this.refreshOptions(Array.isArray(w)?w.map(S=>this.toOption(S)):[])}catch(w){if(!f.signal.aborted)throw w}finally{this.#e===f&&(this.#e=null)}}choose(b){!b||b.disabled||(this.selected=b.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(b){return this.selected!=null&&b!=null&&B(b.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(b){if(b==null)return;const g=B(b);return this.all.find(f=>B(f.id)===g)}checkValue(b){return b==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(b)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(b)}" is not a valid option`}renderOption(b,g,f){H(g),g.appendChild(this.buildAvatar(b));const w=W(this.doc,"span",{class:"lat-object__text"});w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:b.label})),b.secondary&&w.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:b.secondary})),g.appendChild(w),b.icon&&g.appendChild(a(this.doc,b.icon,{className:N.icon})),b.variant?g.setAttribute("data-variant",b.variant):g.removeAttribute("data-variant");const S=this.isSelected(b);g.classList.add("lat-object__row"),g.classList.toggle(N.optionSelected,S),g.classList.toggle(N.optionDisabled,b.disabled===!0),g.setAttribute("aria-selected",S?"true":"false"),b.disabled?g.setAttribute("aria-disabled","true"):g.removeAttribute("aria-disabled")}buildAvatar(b){const g=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!b.avatar)return g.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),g.setAttribute("data-fallback","initials"),g;const f=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:b.avatar,alt:"",loading:"lazy",decoding:"async"}});return _(f,"error",()=>{f.parentNode===g&&(g.removeChild(f),g.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),g.setAttribute("data-fallback","initials"))}),g.appendChild(f),g}paintDisplay(){const b=this.display;if(!b)return;if(H(b),this.selected==null){b.removeAttribute("data-variant");return}const g=this.optionById(this.selected);if(!g){b.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}b.appendChild(this.buildAvatar(g)),b.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:g.label})),g.variant?b.setAttribute("data-variant",g.variant):b.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 s(m,b,g){if(b==null)return g;const f=o(b)?b(m):t(m,String(b));return f==null?g:String(f)}function u(m){const b=String(m||"").trim().split(/\s+/).filter(w=>w!=="");if(!b.length)return"";const g=[...b[0]][0]||"";if(b.length===1)return g.toUpperCase();const f=[...b[b.length-1]][0]||"";return(g+f).toUpperCase()}function l(m){if(m==null)return null;const g=(Array.isArray(m)?m:[m]).filter(f=>typeof f=="string"||o(f));return g.length?g:null}const p=r}),je("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 c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.VirtualList,W=Z.el,_=Z.on,H=Z.clear,B=V("packages/dom/src/cell/icons.js"),G=B.createIcon,D=B.iconNames,k=V("packages/core/src/internal/util.js").isFunction;class y extends M{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=c(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const i=W(this.doc,"div",{class:["lat-iconpicker",`${I.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${I.editor}__display`}),this.input=W(this.doc,"input",{class:I.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 N({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(a,r,s)=>this.renderRow(a,r,s)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),i.appendChild(this.display),i.appendChild(this.input),t.allowClear===!0&&i.appendChild(this.buildClearButton()),i.appendChild(this.list.element()),this.off.push(_(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(_(this.input,"keydown",a=>this.onKeyDown(a))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),i}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",i=>{k(i.preventDefault)&&i.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(a=>a.toLowerCase().includes(t)),this.rows=[];for(let a=0;a<this.matches.length;a+=this.columns)this.rows.push(this.matches.slice(a,a+this.columns));const i=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=i>=0?i: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 i=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(i)}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,i,a){i.setAttribute("role","row"),i.classList.add("lat-iconpicker__row");let r=i.__latIconCells;if(!r){r=[],H(i);for(let s=0;s<this.columns;s++){const u=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});_(u,"mousedown",l=>{k(l.preventDefault)&&l.preventDefault();const p=u.getAttribute("data-icon");p&&this.choose(p)}),i.appendChild(u),r.push(u)}i.__latIconCells=r}for(let s=0;s<r.length;s++){const u=r[s],l=t[s];if(l===void 0){u.setAttribute("aria-hidden","true"),u.removeAttribute("data-icon"),u.removeAttribute("title"),u.removeAttribute("aria-label"),u.classList.add("lat-iconpicker__cell--empty"),u.classList.remove("lat-iconpicker__cell--active"),u.classList.remove("lat-iconpicker__cell--selected"),u.__latIconName!==void 0&&(H(u),u.__latIconName=void 0);continue}const p=a*this.columns+s;u.removeAttribute("aria-hidden"),u.classList.remove("lat-iconpicker__cell--empty"),u.setAttribute("data-icon",l),u.setAttribute("title",l),u.setAttribute("aria-label",l),u.__latIconName!==l&&(H(u),u.appendChild(G(this.doc,l,{className:I.icon})),u.__latIconName=l);const m=this.selected===l;u.classList.toggle("lat-iconpicker__cell--active",p===this.cursor),u.classList.toggle("lat-iconpicker__cell--selected",m),u.setAttribute("aria-selected",m?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(H(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(G(this.doc,this.selected,{className:I.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const i=this.matches.indexOf(t);i>=0&&(this.cursor=i),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 i=()=>{k(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":i(),this.moveCursor(1);return;case"ArrowLeft":i(),this.moveCursor(-1);return;case"ArrowDown":i(),this.moveCursor(this.columns);return;case"ArrowUp":i(),this.moveCursor(-this.columns);return;case"PageDown":i(),this.moveCursor(this.columns*5);return;case"PageUp":i(),this.moveCursor(-this.columns*5);return;case"Home":i(),this.setCursor(this.matches.length?0:-1);return;case"End":i(),this.setCursor(this.matches.length-1);return;case"Enter":{i();const a=this.cursorName();a&&this.choose(a);return}case"Escape":i(),this.cancel();return;case"Tab":{const a=this.cursorName();a&&(this.selected=a),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 c(n){const t=D();if(Array.isArray(n)&&n.length){const i=new Set(t);return n.map(a=>String(a)).filter(a=>i.has(a))}return t.filter(i=>i!=="blank")}const o=y}),je("packages/dom/src/editors/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,H=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/temperature.js"),G=B.formatTemperature,D=B.parseTemperature,v=B.findScale;function k(o,n){return G(o,{...n,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=v(this.opts.scale),i=t?t.scale.symbol:"",a=`${this.id}-scale`,r=N(this.doc,"input",{class:I.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":i?a:null}});r.value=k(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const s=typeof n.step=="number"?n.step:0;return s>0&&this.#e.push(W(r,"keydown",u=>{u.key==="ArrowUp"?(H(u.preventDefault)&&u.preventDefault(),this.nudge(s)):u.key==="ArrowDown"&&(H(u.preventDefault)&&u.preventDefault(),this.nudge(-s))})),this.hint=N(this.doc,"span",{class:`${I.editor}__suffix`,text:i,attrs:{id:a,"aria-hidden":"true"}}),N(this.doc,"div",{class:`${I.editor}__unit`,children:[r,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&H(n.select)&&n.select()}nudge(n){const t=D(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:a,max:r}=this.props;typeof a=="number"&&i<a&&(i=a),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=k(i,this.opts))}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=D(n,this.opts);return t===null?Number.NaN:t}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n))return"Enter a temperature";const{min:t,max:i}=this.props;return typeof t=="number"&&n<t?`Must be ${t} or more`:typeof i=="number"&&n>i?`Must be ${i} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const c=y}),je("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 c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),M=Z.BaseEditor,I=Z.CLS,N=Z.el,W=Z.on,H=V("packages/core/src/internal/util.js").isFunction,B=V("packages/core/src/columns/types/currency.js"),G=B.parseMoney,D=B.toMoney,v=B.normaliseCode,k=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(n){const t=D(n);return t?String(t.amount):""}class c extends M{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,i=t&&t.currencyConfig||{},a=D(this.params.value),r=v(this.props.code)||a&&a.code||v(i.code)||"USD";let s=this.props.codes||i.codes||k;return s=s.map(u=>v(u)).filter(Boolean),s.includes(r)||(s=[r,...s]),{code:r,codes:s,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const i=N(this.doc,"input",{class:I.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:t.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});i.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const a=N(this.doc,"select",{class:`${I.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const r of this.opts.codes){const s=N(this.doc,"option",{text:r,attrs:{value:r}});r===this.opts.code&&(s.selected=!0),a.appendChild(s)}return this.picker=a,N(this.doc,"div",{class:`${I.editor}__unit`,children:[i,a]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&H(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const i=this.picker?this.picker.value:this.opts.code,a=G(t,{...this.opts,code:i});return a===null?Number.NaN:a}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const i=t.amount,{min:a,max:r}=this.props;return typeof a=="number"&&i<a?`Must be ${a} or more`:typeof r=="number"&&i>r?`Must be ${r} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const o=c}),je("packages/dom/src/editors/index.js",function(e,V){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return N}}),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 D}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return ce}});const M=V("packages/dom/src/editors/text.js").TextEditor,N=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,D=V("packages/dom/src/editors/checkbox.js").CheckboxEditor,k=V("packages/dom/src/editors/select.js").SelectEditor,c=V("packages/dom/src/editors/multiselect.js").MultiSelectEditor,n=V("packages/dom/src/editors/time.js").TimeEditor,i=V("packages/dom/src/editors/datetime.js").DateTimeEditor,r=V("packages/dom/src/editors/duration.js").DurationEditor,u=V("packages/dom/src/editors/ipaddress.js").IpAddressEditor,p=V("packages/dom/src/editors/password.js").PasswordEditor,b=V("packages/dom/src/editors/code.js").CodeEditor,f=V("packages/dom/src/editors/unit.js").UnitEditor,S=V("packages/dom/src/editors/radix.js").RadixEditor,d=V("packages/dom/src/editors/segmented.js").SegmentedEditor,E=V("packages/dom/src/editors/rating.js").RatingEditor,T=V("packages/dom/src/editors/slider.js").SliderEditor,P=V("packages/dom/src/editors/colour.js").ColourEditor,$=V("packages/dom/src/editors/treeselect.js").TreeSelectEditor,x=V("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,C=V("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=V("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=V("packages/dom/src/editors/currency.js").CurrencyEditor,J=V("packages/core/src/internal/util.js"),te=J.isCtor,ee=J.isFunction,re=J.warnOnce,se=V("packages/dom/src/editors/common.js");for(const pe of Object.keys(se))pe!=="default"&&Object.defineProperty(e,pe,{enumerable:!0,get:function(){return se[pe]}});const de=Object.freeze({text:M,textarea:N,number:_,date:B,checkbox:D,select:k,multiSelect:c,temperature:q,currency:Y,time:n,datetime:i,duration:r,ipaddress:u,password:p,code:b,unit:f,radix:S,slider:T,rating:E,segmented:d,treeSelect:$,objectPicker:x,iconPicker:C,colour:P}),ie=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function oe(pe,Me){const $e=pe&&pe.edit&&pe.edit.editor,Ae=Me&&Me.editors||{},ke=!!(pe&&pe.lookup&&pe.lookup.multiple);if(te($e)||ee($e))return $e;if(typeof $e=="string"){if(ke&&$e==="select")return c;const De=Ae[$e]||de[$e];if(De)return De;re(`editor:missing:${$e}`,`unknown editor "${$e}"; falling back to the data type default`)}const ge=pe&&pe.type||"text";if(ge==="lookup"||pe&&pe.lookup)return ke?c:k;const Ee=ie[ge];return Ee&&(Ae[Ee]||de[Ee])||null}function ue(pe,Me){const $e=oe(pe.column||{},Me);if(!$e)return null;const Ae=new $e;return Ae.init(pe),ee(Ae.cancelBeforeStart)&&Ae.cancelBeforeStart()===!0?(ee(Ae.destroy)&&Ae.destroy(),null):Ae}const ce=de}),je("packages/dom/src/ui/statusbar.js",function(e,V){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction;function D(m){let b=0,g=0,f=0,w=null,S=null;for(const h of m||[]){if(h==null||h==="")continue;b++;const d=typeof h=="number"?h:Number(h);Number.isFinite(d)&&(g++,f+=d,(w===null||d<w)&&(w=d),(S===null||d>S)&&(S=d))}return{count:b,numericCount:g,sum:g?f:null,min:w,max:S,avg:g?f/g:null}}class v{root=null;valueNode=null;init(b){this.ctx=b,this.doc=b.document,this.root=N(this.doc,"div",{class:`${M.statusBar}__panel`,attrs:{"data-align":b.align||"end"}}),b.label&&this.root.appendChild(N(this.doc,"span",{class:`${M.statusBar}__label`,text:b.label})),this.valueNode=N(this.doc,"span",{class:`${M.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(b,g){const f=this.ctx&&this.ctx.messages;return(f&&G(f.t)?f:H).t(b,g)}element(){return this.root}refresh(){const b=this.read();this.valueNode&&this.valueNode.textContent!==b&&(this.valueNode.textContent=b)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class k extends v{read(){const b=this.ctx.host||{},g=G(b.totalRowCount)?b.totalRowCount():0;if(g==null)return this.t("status.counting");const f=G(b.rowCount)?b.rowCount():g,w=this.ctx.noun,S=h=>w===void 0?this.t("count.rows",{count:h}):`${s(h,this.ctx.locale)}${w?` ${w}`:""}`;return f===g?this.t("status.total",{rows:S(g)}):this.t("status.shownOfTotal",{shown:s(f,this.ctx.locale),total:S(g)})}}class y extends v{read(){const b=this.ctx.host||{},g=G(b.selectedCount)?b.selectedCount():0;return g?this.t("status.selected",{count:g}):""}}class c extends v{read(){const b=this.ctx.host||{},g=G(b.rangeValues)?b.rangeValues():[],f=D(g);if(!f.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],S=[];for(const h of w){if(h==="count"){S.push(this.t("status.count",{count:f.count}));continue}const d=f[h];d!==null&&S.push(`${this.t(`status.stat.${h}`)} ${l(d,this.ctx.locale)}`)}return S.join(" ")}}class o extends v{read(){const b=this.ctx.host||{},g=G(b.progress)?b.progress():null;if(!g)return"";const{loaded:f,estimated:w,done:S}=g;if(S)return"";if(!w)return this.t("status.loading",{count:f||0});const h=Math.min(100,Math.round((f||0)/w*100));return this.t("status.loadingOf",{loaded:f||0,total:w,percent:h})}}class n extends v{read(){const b=this.ctx.host||{},g=G(b.updateStats)?b.updateStats():null;return g?g.paused?g.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:g.pending})}):this.t("status.paused"):g.coalescedTotal?this.t("status.coalesced",{count:g.coalescedTotal}):"":""}}class t extends v{read(){const b=this.ctx.host||{},g=G(b.hiddenUnresolved)?b.hiddenUnresolved():0;return g?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:g})}):""}}const i=Object.freeze({rowCount:k,selectedCount:y,aggregation:c,progress:o,updates:n,comments:t});class a{panels=[];root=null;init(b){const g=b||{};this.doc=I(g),this.host=g.host||{},this.messages=g.messages||null,this.root=N(this.doc,"div",{class:M.statusBar,attrs:{role:"status","aria-live":"polite"}});const f=g.registry||{},w=Array.isArray(g.panels)&&g.panels.length?g.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const S of w){const h=typeof S=="string"?S:S.name,d=typeof S=="function"?S:f[h]||i[h];if(!d)continue;const j=new d;j.init({document:this.doc,host:this.host,locale:g.locale,messages:this.messages,...typeof S=="object"?S.props||{}:{}}),this.panels.push({name:String(h||"panel"),panel:j}),this.root.appendChild(j.element())}this.refresh()}element(){return this.root}addPanel(b,g,f){const w=new g;return w.init({document:this.doc,host:this.host,messages:this.messages,...f||{}}),this.panels.push({name:b,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(b){const g=this.panels.findIndex(S=>S.name===b);if(g<0)return!1;const[f]=this.panels.splice(g,1),w=f.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),G(f.panel.destroy)&&f.panel.destroy(),!0}refresh(){for(const b of this.panels)b.panel.refresh()}destroy(){for(const b of this.panels)G(b.panel.destroy)&&b.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const r=new Map;function s(m,b){const g=b||"";let f=r.get(g);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:0}),r.set(g,f)),f.format(Number(m)||0)}const u=new Map;function l(m,b){const g=b||"";let f=u.get(g);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:3}),u.set(g,f)),f.format(Number(m)||0)}const p=a}),je("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 c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction,D=V("packages/dom/src/renderer/direction.js").isRtlElement,k=V("packages/dom/src/cell/icons.js").renderIconInto;function y(i,a){const r=[];for(const s of i||[]){const u=B(s)?s(a):s;if(u==null||u===!1)continue;if(u==="separator"){r.push({separator:!0});continue}if(typeof u=="string"){r.push({name:u});continue}const l=u,p=l.subMenu||l.children;p?r.push({...l,subMenu:y(p,a)}):r.push(l)}return r.filter((s,u,l)=>s.separator?u===0||u===l.length-1?!1:!l[u-1].separator:!0)}class c{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(a){const r=a||{};this.doc=I(r),this.host=r.host||this.doc.body,this.ctx=r.ctx||{},this.onClose=r.onClose||null,this.parent=r.parent||null}place(a){const r=this.host,s=B(r.getBoundingClientRect)?r.getBoundingClientRect():{left:0,top:0},u=B(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},l=this.doc.defaultView||{innerWidth:0,innerHeight:0},p=l.innerWidth||0,m=l.innerHeight||0;let b=a.x||0,g=a.y||0;const f=D(r);if(a.anchor&&B(a.anchor.getBoundingClientRect)){const h=a.anchor.getBoundingClientRect();a.placement==="below"?(b=f?h.right-u.width:h.left,g=h.bottom):(b=f?h.left-u.width:h.right,g=h.top)}else f&&(b-=u.width);const w={left:Math.max(0,s.left||0),top:Math.max(0,s.top||0),right:Math.min(p||1/0,(s.left||0)+(s.width||1/0)),bottom:Math.min(m||1/0,(s.top||0)+(s.height||1/0))};b+u.width>w.right&&(b-=u.width),b<w.left&&(b=w.left),g+u.height>w.bottom&&(g-=u.height),g<w.top&&(g=w.top);const S=w.bottom-g;u.height>S&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(S))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(b-s.left+(r.scrollLeft||0))}px`,this.root.style.top=`${Math.round(g-s.top+(r.scrollTop||0))}px`}show(a){return this.hide(),a.ctx&&(this.ctx={...this.ctx||{},...a.ctx}),this.items=y(a.items,this.ctx),this.returnFocus=a.returnFocus||null,this.anchor=a.anchor&&B(a.anchor.setAttribute)&&a.anchor.getAttribute&&a.anchor.getAttribute("aria-haspopup")?a.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=N(this.doc,"div",{class:M.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((r,s)=>{if(r.separator){this.root.appendChild(N(this.doc,"div",{class:M.menuSeparator,attrs:{role:"separator"}}));return}const u=N(this.doc,"div",{class:[M.menuItem,r.cssClass||""],attrs:{role:r.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":r.disabled?"true":null,"aria-checked":r.checked===void 0?null:String(r.checked===!0),"aria-haspopup":r.subMenu?"true":null,"aria-expanded":r.subMenu?"false":null,"data-index":s}});if(r.icon!=null&&r.icon!==""){const p=N(this.doc,"span",{class:M.icon});k(p,r.icon,`menu:${r.name||s}`),u.appendChild(p)}u.appendChild(N(this.doc,"span",{class:`${M.menuItem}__label`,text:r.name||""})),r.shortcut&&u.appendChild(N(this.doc,"span",{class:`${M.menuItem}__shortcut`,text:r.shortcut})),r.subMenu&&u.appendChild(N(this.doc,"span",{class:`${M.menuItem}__arrow`,text:"›"}));const l=this.itemNodes.length;this.off.push(W(u,"click",()=>this.invoke(l))),this.off.push(W(u,"mouseenter",()=>{this.focus(l),r.subMenu?this.openSubMenu(l):this.closeChild()})),this.itemNodes.push(u),this.root.appendChild(u)}),this.host.appendChild(this.root),this.place(a),this.open=!0,this.off.push(W(this.root,"keydown",r=>this.onKeyDown(r))),B(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=r=>{this.root&&!n(this.root,r.target)&&!(this.child&&this.child.root&&n(this.child.root,r.target))&&this.hide()},!0)),B(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let a=0;a<this.itemNodes.length;a++)if(!this.itemAt(a).disabled)return a;return-1}itemAt(a){const r=this.itemNodes[a];return r?this.items[Number(r.getAttribute("data-index"))]||{}:{}}focus(a){if(a<0||a>=this.itemNodes.length)return;const r=this.itemNodes[this.focused];r&&r.classList.remove(`${M.menuItem}--focused`),this.focused=a;const s=this.itemNodes[a];s.classList.add(`${M.menuItem}--focused`),B(s.focus)&&s.focus(),B(s.scrollIntoView)&&s.scrollIntoView({block:"nearest",inline:"nearest"})}move(a){const r=this.itemNodes.length;if(!r)return;let s=this.focused;for(let u=0;u<r;u++)if(s=(s+a+r)%r,!this.itemAt(s).disabled){this.focus(s);return}}invoke(a){const r=this.itemAt(a);if(!(!r||r.disabled)){if(r.subMenu){this.openSubMenu(a);return}B(r.action)&&r.action({...this.ctx,item:r}),this.hideRoot()}}openSubMenu(a){const r=this.itemAt(a);r.subMenu&&(this.closeChild(),this.child=new c({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:r.subMenu,anchor:this.itemNodes[a]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(a){switch(a.key){case"ArrowDown":o(a),this.move(1);break;case"ArrowUp":o(a),this.move(-1);break;case"Home":o(a),this.focus(this.firstEnabled());break;case"End":o(a),this.focus(this.itemNodes.length-1);break;case"ArrowRight":o(a),this.openSubMenu(this.focused);break;case"ArrowLeft":o(a),this.parent&&(this.hide(),B(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":o(a),this.invoke(this.focused);break;case"Escape":o(a),this.hideRoot();break;default:a.key&&a.key.length===1&&this.jumpTo(a.key);break}}jumpTo(a){const r=a.toLowerCase(),s=this.itemNodes.length;for(let u=1;u<=s;u++){const l=(this.focused+u+s)%s,p=this.itemAt(l);if(!p.disabled&&(p.name||"").toLowerCase().startsWith(r)){this.focus(l);return}}}hideRoot(){let a=this;for(;a.parent;)a=a.parent;a.hide()}hide(){this.closeChild();for(const a of this.off)a();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(i){B(i.preventDefault)&&i.preventDefault(),B(i.stopPropagation)&&i.stopPropagation()}function n(i,a){let r=a;for(;r;){if(r===i)return!0;r=r.parentNode}return!1}const t=c}),je("packages/dom/src/viewpicker.js",function(e,V){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),M=Z.documentFor,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction,v=V("packages/dom/src/cell/icons.js").createIcon,k=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,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(t,i)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||H;const i=t||{};this.doc=M(i),this.host=i.host||{},this.props=i.props||{},this.root=I(this.doc,"div",{class:k.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 u of this.off)u();this.off.length=0,W(t),this.diffs=new Map;const i=this.views(),a=i.filter(u=>u.builtin),r=i.filter(u=>!u.builtin);a.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),a.length)),t.appendChild(this.buildList(a))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),r.length)),r.length?t.appendChild(this.buildList(r)):t.appendChild(I(this.doc,"p",{class:k.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const s=this.buildFoot();s&&t.appendChild(s)}buildList(t){const i=I(this.doc,"div",{class:k.list,attrs:{role:"list"}});for(const a of t)i.appendChild(this.buildItem(a));return i}views(){const t=G(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((i,a)=>String(i.name||"").localeCompare(String(a.name||"")))}activeId(){return G(this.host.activeId)?this.host.activeId():null}buildHead(t,i){return I(this.doc,"div",{class:k.head,children:[I(this.doc,"span",{class:k.title,text:String(t)}),I(this.doc,"span",{class:k.count,text:String(i)})]})}buildItem(t){const i=String(t.id),a=this.activeId()===i,r=G(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,s=I(this.doc,"div",{class:[k.item,a?k.itemActive:"",this.editing===i?k.itemEditing:""],attrs:{role:"listitem","data-view":i,"data-shared":t.shared?"true":"false"}});if(this.editing===i)return s.appendChild(this.buildRenameRow(t)),s;const u=I(this.doc,"button",{class:k.apply,attrs:{type:"button","aria-current":a?"true":null,title:[a?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[I(this.doc,"span",{class:k.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});G(this.host.apply)?this.off.push(N(u,"click",()=>this.applyView(i))):u.setAttribute("disabled",""),t.description&&u.appendChild(I(this.doc,"span",{class:k.description,text:String(t.description)}));const l=this.buildDiff(i,a);return l&&u.appendChild(l),s.appendChild(u),t.builtin||s.appendChild(this.confirming===i?this.buildConfirm(t):this.buildActions(t,r)),s}buildBadges(t){const i=I(this.doc,"span",{class:k.badges});return t.isDefault&&i.appendChild(I(this.doc,"span",{class:[k.badge,k.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),i}buildDiff(t,i){if(this.props.showDiff!==!0||!G(this.host.diff))return null;const a=this.diffOf(t);if(!a)return null;if(!a.changed)return I(this.doc,"span",{class:[k.diff,k.diffClean],text:this.t(i?"views.applied":"views.matchesGrid")});const r=c(a);return r.length?I(this.doc,"span",{class:k.diff,text:r.join(" · ")}):null}diffOf(t){if(!G(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let i=null;try{i=this.host.diff(t)}catch{i=null}return this.diffs.set(t,i),i}buildActions(t,i){const a=String(t.id),r=I(this.doc,"span",{class:k.actions});if(i&&G(this.host.rename)&&r.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=a,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&G(this.host.clearDefault)?r.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(a),this.refresh()},"pin")):!t.isDefault&&G(this.host.setDefault)&&r.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(a),this.refresh()},"pin")),G(this.host.export)&&r.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(a),"share")),i&&G(this.host.remove)){const s=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=a,this.refresh()},"trash");s.classList.add(k.actionDanger),r.appendChild(s)}return r}buildConfirm(t){const i=String(t.id),a=I(this.doc,"span",{class:k.confirm});a.appendChild(I(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const r=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(i),this.refresh()});return r.classList.add(k.actionDanger),a.appendChild(r),a.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),a}buildRenameRow(t){const i=String(t.id),a=I(this.doc,"span",{class:k.confirm}),r=I(this.doc,"input",{class:k.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});r.value=String(t.name||""),this.input=r;const s=()=>{const l=String(r.value||"").trim();this.editing=null,l&&l!==t.name&&this.host.rename(i,l),this.refresh()},u=()=>{this.editing=null,this.refresh()};return this.off.push(N(r,"keydown",l=>{l.key==="Enter"?s():l.key==="Escape"&&u()})),a.appendChild(r),a.appendChild(this.buildAction("Save","Save the new name",s)),a.appendChild(this.buildAction("Cancel","Leave the name alone",u)),a}buildFoot(){if(this.props.allowSave===!1||!G(this.host.saveAs))return null;const t=I(this.doc,"div",{class:k.foot}),i=I(this.doc,"input",{class:k.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});i.value=this.draft,this.editing===null&&(this.input=i);const a=()=>{const s=String(i.value||"").trim();if(!s){G(i.focus)&&i.focus();return}this.draft="",this.host.saveAs(s),this.refresh()};this.off.push(N(i,"input",()=>{this.draft=String(i.value||"")})),this.off.push(N(i,"keydown",s=>{s.key==="Enter"&&a()}));const r=I(this.doc,"button",{class:k.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(N(r,"click",a)),t.appendChild(i),t.appendChild(r),t}buildAction(t,i,a,r){const s=I(this.doc,"button",{class:k.action,text:r?null:t,attrs:{type:"button",title:i,"aria-label":i,"data-action":t}});return r&&s.appendChild(v(this.doc,r,{className:k.actionIcon})),this.off.push(N(s,"click",a)),s}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&G(t.focus)&&t.focus(),t&&G(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 c(n,t=3){if(!n||!n.changed)return[];const i=n.counts||{},a=[],r=(s,u,l)=>{s&&a.push((s===1?u:l).replace("%",String(s)))};if(r(i.columnsHidden,"hides % column","hides % columns"),r(i.columnsShown,"shows % column","shows % columns"),r(i.columnsMoved,"moves % column","moves % columns"),r(i.columnsPinned,"repins % column","repins % columns"),r(i.columnsResized,"resizes % column","resizes % columns"),n.filters&&n.filters.changed){const s=i.filterColumns||0;a.push(s?`changes ${s} filter${s===1?"":"s"}`:"changes the filter")}return n.quick&&n.quick.changed&&a.push("changes the search"),n.sort&&n.sort.changed&&a.push("changes the sort"),n.group&&n.group.changed&&a.push("changes the grouping"),n.pivot&&n.pivot.changed&&a.push("changes the pivot"),r(i.columnsTotalled,"changes % total","changes % totals"),n.pagination&&n.pagination.changed&&a.push("changes the page size"),a.length<=t?a:[...a.slice(0,t),`and ${a.length-t} more`]}const o=y}),je("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"),M=Z.CLS,I=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=I(this.doc,"div",{class:`${M.panel}__body`}),this.refresh()}t(B,G){const D=this.host||{};if(typeof D.t=="function")return D.t(B,G);const v=this.ctx||{};if(v.messages&&typeof v.messages.t=="function")return v.messages.t(B,G);const k=v.grid;return(k&&k.messages?k.messages:W).t(B,G)}element(){return this.root}refresh(){}destroy(){for(const B of this.off)B();this.off.length=0,this.root=null}}}),je("packages/dom/src/formattingpanel.js",function(e,V){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction,D=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,v=V("packages/core/src/formatting/rules.js"),k=v.compileRules,y=v.summariseColumn,c=v.needsDistribution,o=v.DISTRIBUTION_LABELS,n="*",t=8,i=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}]),a=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}]),r=Object.freeze([...i,...a]),s=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),u=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),l=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 p(w){const S=r.find(h=>h.op===w);return S?S.values:1}function m(w){if(!w)return"";if(w.scale){const{min:j,max:E,from:O}=w.scale;if(Number.isFinite(j)&&Number.isFinite(E))return`Colour scale, ${j} to ${E}`;const T=l.find(A=>A.from===O);return T?`Colour scale ${T.label}`:"Colour scale"}const S=w.when||{},h=r.find(j=>j.op===S.op),d=h?h.label:S.op;return!h||h.values===0?`Value ${d}`:h.values===2?`Value ${d} ${S.value} and ${S.value2}`:`Value ${d} ${S.value}`}class b extends D{scope=n;mode="condition";refresh(){const S=this.root;if(S){for(const h of this.off)h();this.off.length=0,_(S),S.appendChild(this.#o()),S.appendChild(this.#i()),S.appendChild(this.#l())}}#e(){const S=B(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:n,title:"All columns"},...S]}#t(){return B(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(S){if(!B(this.host.columnSamples))return[];const h=this.host.columnSamples(S);return Array.isArray(h)?h:[...h||[]]}#r(S,h,d){const j=c(S)?y(h):null;return k(S,j)({value:d})}#o(){const S=N(this.doc,"div",{class:`${M.panel}__row`});S.appendChild(N(this.doc,"label",{class:`${M.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const h=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const d of this.#e()){const j=N(this.doc,"option",{text:d.title,attrs:{value:d.id}});d.id===this.scope&&j.setAttribute("selected","selected"),h.appendChild(j)}return h.value=this.scope,this.off.push(W(h,"change",()=>{this.scope=h.value||n,this.refresh()})),S.appendChild(h),S}#i(){const S=N(this.doc,"ul",{class:`${M.panel}__list`}),h=this.#t();if(!h.length)return S.appendChild(N(this.doc,"li",{class:`${M.panel}__empty`,text:this.t("formatting.noRules")})),S;h.forEach((E,O)=>{const T=N(this.doc,"li",{class:`${M.panel}__item`,attrs:{"data-rule":E.id}}),A=N(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${m(E)}`}});A.checked=E.enabled!==!1,this.off.push(W(A,"change",()=>{this.#c("updateRule",this.scope,E.id,{enabled:A.checked})})),T.appendChild(A);const P=N(this.doc,"span",{class:`${M.panel}__swatch`}),L=E.style||{};if(L.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(L.background));else if(E.scale&&E.scale.colours&&P.style&&P.style.setProperty){const F=E.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${F[0]}, ${F[F.length-1]})`)}T.appendChild(P),T.appendChild(N(this.doc,"span",{class:`${M.panel}__text`,text:m(E)}));const $=N(this.doc,"button",{class:`${M.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(W($,"click",()=>this.#c("moveRule",this.scope,E.id,O-1))),T.appendChild($);const U=N(this.doc,"button",{class:`${M.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===h.length-1?{disabled:"disabled"}:{}}});this.off.push(W(U,"click",()=>this.#c("moveRule",this.scope,E.id,O+1))),T.appendChild(U);const x=N(this.doc,"button",{class:`${M.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${m(E)}`}});this.off.push(W(x,"click",()=>this.#c("removeRule",this.scope,E.id))),T.appendChild(x),S.appendChild(T)});const d=this.#s(h);d&&S.appendChild(d);const j=N(this.doc,"button",{class:`${M.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(j,"click",()=>this.#c("clearRules",this.scope))),S.appendChild(j),S}#s(S){const h=this.#n(this.scope);if(!h.length)return null;const d=S.filter(E=>E.enabled!==!1);if(!d.length)return null;const j=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const E of h.slice(0,t)){const O=this.#r(d,h,E),T=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(E)});O&&T.style&&T.style.setProperty&&(O.background&&T.style.setProperty("background",String(O.background)),O.color&&T.style.setProperty("color",String(O.color))),j.appendChild(T)}return j}#l(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),h=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return h.appendChild(N(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),h.appendChild(N(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),h.value=this.mode,this.off.push(W(h,"change",()=>{this.mode=h.value==="scale"?"scale":"condition",this.refresh()})),S.appendChild(h),this.mode==="scale"?S.appendChild(this.#u()):S.appendChild(this.#a()),S}#a(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),h=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),d=N(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const x of i)d.appendChild(N(this.doc,"option",{text:x.label,attrs:{value:x.op}}));h.appendChild(d);const j=N(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const x of a)j.appendChild(N(this.doc,"option",{text:x.label,attrs:{value:x.op}}));h.appendChild(j),h.value="gt",S.appendChild(h);const E=N(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=N(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});S.appendChild(E),S.appendChild(O);const T=()=>{const x=p(h.value);E.style.setProperty("display",x>=1?"":"none"),O.style.setProperty("display",x>=2?"":"none"),$()};this.off.push(W(h,"change",T));const A=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const x of s)A.appendChild(N(this.doc,"option",{text:x.name,attrs:{value:x.name}}));A.value=s[0].name,S.appendChild(A);const P=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(P);const L=()=>{const x=s.find(z=>z.name===A.value)||s[0],F=p(h.value),C={op:h.value};return F>=1&&(C.value=E.value),F>=2&&(C.value2=O.value),{when:C,style:{background:x.background,color:x.color}}},$=()=>{_(P);const x=this.#n(this.scope);if(x.length)for(const F of x.slice(0,t)){const C=this.#r([L()],x,F),z=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(F)});C&&z.style&&z.style.setProperty&&(C.background&&z.style.setProperty("background",String(C.background)),C.color&&z.style.setProperty("color",String(C.color))),P.appendChild(z)}};this.off.push(W(E,"input",$)),this.off.push(W(O,"input",$)),this.off.push(W(A,"change",$)),T();const U=N(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(U,"click",()=>{this.#c("addRule",this.scope,L()),E.value="",O.value=""})),S.appendChild(U),S}#u(){const S=N(this.doc,"div",{class:`${M.panel}__form`}),h=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const A of u)h.appendChild(N(this.doc,"option",{text:A.name,attrs:{value:A.name}}));h.value=u[0].name,S.appendChild(h);const d=N(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const A of l)d.appendChild(N(this.doc,"option",{text:A.label,attrs:{value:A.from}}));d.value=l[0].from,S.appendChild(d);const j=N(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(j);const E=()=>{const A=u.find(P=>P.name===h.value)||u[0];return{scale:{from:d.value,colours:[...A.colours]}}},O=()=>{_(j);const A=this.#n(this.scope);if(A.length)for(const P of A.slice(0,t)){const L=this.#r([E()],A,P),$=N(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(P)});L&&L.background&&$.style&&$.style.setProperty&&$.style.setProperty("background",String(L.background)),j.appendChild($)}};this.off.push(W(h,"change",O)),this.off.push(W(d,"change",O)),O();const T=N(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(T,"click",()=>{this.#c("addRule",this.scope,E())})),S.appendChild(T),S}#c(S,...h){B(this.host[S])&&this.host[S](...h),this.refresh()}}function g(w={}){const S=new b;return S.init({document:I(w),host:w.host||{}}),S}const f=b}),je("packages/dom/src/statisticspanel.js",function(e,V){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return c}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/internal/util.js").isFunction,G=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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"}]),v=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),k=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 n=Math.abs(o);return n!==0&&(n<.001||n>=1e7)?o.toExponential(2):String(Number(o.toPrecision(4)))}class c extends G{column=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const r of this.off)r();this.off.length=0,W(n);const t=this.#e();if(!t.length){n.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(r=>r.id===this.column)||(this.column=t[0].id),n.appendChild(this.#t(t));const i=H(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!i||!i.present){n.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noValues")}));return}if(n.appendChild(I(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:i.rows})})),Array.isArray(i.topValues)){n.appendChild(this.#o(i,v)),n.appendChild(this.#i(i.topValues));return}n.appendChild(this.#o(i));for(const r of k){const s=this.#n(r);s&&n.appendChild(s)}const a=this.#r();a&&n.appendChild(a),i.histogram&&i.histogram.length>1&&n.appendChild(this.#s(i.histogram))}#t(n){const t=I(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const i of n){const a=I(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===this.column?!0:null}});t.appendChild(a)}return t.value=this.column,this.off.push(N(t,"change",()=>{this.column=t.value,this.refresh()})),I(this.doc,"label",{class:`${M.panel}__field`,children:[I(this.doc,"span",{class:`${M.panel}__label`,text:this.t("stats.column")}),t]})}#n(n){const t=this.host.reduceColumn;if(!H(t)||!this.column)return null;const i=[];for(const s of n.kernels){const u=t(this.column,s);u==null||Number.isNaN(u)||i.push([s,u])}if(!i.length)return null;const a=this.doc.createElement("div");a.appendChild(I(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(n.label)}));const r=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const[s,u]of i)r.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(`total.${s}`)})),r.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,text:typeof u=="number"?y(u):String(u)}));return a.appendChild(r),a}#r(){const n=this.host.columnCapability;if(!H(n)||!this.column)return null;const t=n(this.column);if(!t)return null;const i=this.doc.createElement("div");i.appendChild(I(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.section.capability")}));const a=I(this.doc,"dl",{class:`${M.panel}__stats`}),r=[["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[s,u,l]of r){if(u==null)continue;a.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(s)}));const p=[I(this.doc,"span",{text:y(u)})];l&&Number.isFinite(l.lower)&&p.push(I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${y(l.lower)} – ${y(l.upper)}`,attrs:{title:`${Math.round(l.confidence*100)}%`}})),a.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,children:p}))}return i.appendChild(a),i}#o(n,t=D){const i=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const a of t){const r=n[a.key];i.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(a.label)})),i.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,text:a.kind==="count"?String(r??0):y(r)}))}return i}#i(n){const t=this.doc.createElement("div");t.appendChild(I(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.topValues")}));const i=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const a of n)i.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:String(a.value)})),i.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,children:[I(this.doc,"span",{text:String(a.count)}),I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${Math.round(a.share*100)}%`})]}));return t.appendChild(i),t}#s(n){const t=n.reduce((a,r)=>Math.max(a,r.count),0)||1,i=I(this.doc,"div",{class:`${M.panel}__histogram`});i.appendChild(I(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.distribution")}));for(const a of n){const r=I(this.doc,"div",{class:`${M.panel}__bar`,style:{width:`${a.count?Math.max(2,a.count/t*100):0}%`}});i.appendChild(I(this.doc,"div",{class:`${M.panel}__bin`,attrs:{title:this.t("stats.bin",{count:a.count,from:y(a.from),to:y(a.to)})},children:[r]}))}return i}}}),je("packages/dom/src/regressionpanel.js",function(e,V){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.el,N=Z.clear,_=V("packages/core/src/internal/util.js").isFunction,B=V("packages/dom/src/ui/panelbase.js").ToolPanelBase;function G(k,y=4){const c=Number(k);return Number.isFinite(c)?c.toFixed(y):c===1/0?"∞":"—"}class D extends B{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const c=this.ctx&&this.ctx.grid,o=c&&_(c.get)?c.get("regression"):null;return o&&Array.isArray(o.predictors)&&o.response?o:null}refresh(){const y=this.root;if(!y)return;N(y);const c=this.#e();if(!c){y.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.noModel")}));return}const o=_(this.host.regressionModel)?this.host.regressionModel(c):null;if(!o){y.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild(I(this.doc,"p",{class:`${M.panel}__count`,text:this.t("regression.observations",{count:o.n})})),y.appendChild(this.#t(o)),y.appendChild(this.#n(o));const n=this.#r(o,c);n&&y.appendChild(n),y.appendChild(this.#o(o))}#t(y){const c=I(this.doc,"dl",{class:`${M.panel}__stats`}),o=(n,t)=>{c.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-label`,text:n})),c.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,text:t}))};return o(this.t("regression.r2"),G(y.r2,4)),o(this.t("regression.adjR2"),G(y.adjR2,4)),c}#n(y){const c=I(this.doc,"div",{class:`${M.panel}__section`});c.appendChild(I(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.coefficients")}));const o=I(this.doc,"table",{class:`${M.panel}__coef-table`}),n=I(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])n.appendChild(I(this.doc,"th",{text:this.t(t)}));o.appendChild(n);for(const t of y.coefficients){const i=I(this.doc,"tr");i.appendChild(I(this.doc,"td",{text:t.name})),i.appendChild(I(this.doc,"td",{text:`${G(t.estimate)} ± ${G(t.stdError)}`})),i.appendChild(I(this.doc,"td",{text:G(t.stdError)})),i.appendChild(I(this.doc,"td",{text:G(t.t,3)})),i.appendChild(I(this.doc,"td",{text:G(t.p,4)})),o.appendChild(i)}return c.appendChild(o),c}#r(y,c){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const o=I(this.doc,"div",{class:`${M.panel}__section`});o.appendChild(I(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.vif")}));const n=I(this.doc,"dl",{class:`${M.panel}__stats`});return y.vif.forEach((t,i)=>{n.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-label`,text:c.predictors[i]})),n.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,text:G(t,3)}))}),o.appendChild(n),o}#o(y){const c=y.heteroscedasticity,o=I(this.doc,"div",{class:`${M.panel}__section`});return o.appendChild(I(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.heteroscedasticity")})),c?(o.appendChild(I(this.doc,"p",{class:`${M.panel}__flag`,attrs:{"data-heteroscedastic":c.heteroscedastic?"true":"false"},text:this.t(c.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:G(c.statistic,3),p:G(c.p,4)})})),o):(o.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")})),o)}}const v=D}),je("packages/dom/src/comparepanel.js",function(e,V){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return k}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/internal/util.js").isFunction,G=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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 v(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const c=Math.abs(y);return c!==0&&(c<.001||c>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class k extends G{first=null;second=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const c=this.root;if(!c)return;for(const i of this.off)i();this.off.length=0,W(c);const o=this.#e();if(o.length<2){c.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.needTwo")}));return}o.some(i=>i.id===this.first)||(this.first=o[0].id),(!o.some(i=>i.id===this.second)||this.second===this.first)&&(this.second=(o.find(i=>i.id!==this.first)||o[0]).id),c.appendChild(this.#t("compare.first",o,this.first,i=>{this.first=i,this.second===i&&(this.second=(o.find(a=>a.id!==i)||o[0]).id),this.refresh()})),c.appendChild(this.#t("compare.second",o,this.second,i=>{this.second=i,this.first===i&&(this.first=(o.find(a=>a.id!==i)||o[0]).id),this.refresh()}));const n=H(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!n||!n.n){c.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.noPairs")}));return}c.appendChild(I(this.doc,"p",{class:`${M.panel}__count`,text:this.t("compare.pairs",{count:n.n})}));const t=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const i of D){const a=n[i.key];a!=null&&(t.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(i.label)})),t.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,text:v(a)})))}c.appendChild(t)}#t(c,o,n,t){const i=I(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(c)}});for(const a of o)i.appendChild(I(this.doc,"option",{text:a.title,attrs:{value:a.id,selected:a.id===n?!0:null}}));return i.value=n,this.off.push(N(i,"change",()=>t(i.value))),I(this.doc,"label",{class:`${M.panel}__field`,children:[I(this.doc,"span",{class:`${M.panel}__label`,text:this.t(c)}),i]})}}}),je("packages/dom/src/insightspanel.js",function(e,V){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return k}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/internal/util.js").isFunction,G=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,D=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 v(y){if(y==null||!Number.isFinite(y))return"—";if(Number.isInteger(y))return String(y);const c=Math.abs(y);return c!==0&&(c<.001||c>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class k extends G{column=null;by=null;#e(){return H(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const c=this.root;if(!c)return;for(const r of this.off)r();this.off.length=0,W(c);const o=this.#e();if(!o.length){c.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.empty")}));return}const n=this.#t();n&&c.appendChild(n);const t=this.#n();t&&c.appendChild(t),c.appendChild(this.#o(o));const i=this.#s();i&&c.appendChild(i);const a=this.#u();a&&c.appendChild(a)}#t(){if(!H(this.host.subsetVsPopulation))return null;const c=this.host.subsetVsPopulation();if(!c)return null;const o=this.#c("insights.subset");return c.filtered?(o.appendChild(I(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:c.subsetN})})),o.appendChild(this.#r(c.ranked)),o):(o.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.noFilter")})),o)}#n(){const c=this.props&&this.props.other;if(!c||!H(this.host.datasetVsDataset))return null;let o;try{o=this.host.datasetVsDataset(c)}catch{return null}if(!o||!o.ranked)return null;const n=this.#c("insights.dataset");return n.appendChild(this.#r(o.ranked)),n}#r(c){const o=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const n of c||[]){const t=I(this.doc,"dt",{class:`${M.panel}__stat-name`});t.appendChild(I(this.doc,"span",{text:String(n.name??n.column)})),t.appendChild(I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(n.measure||"")}));const i=I(this.doc,"dd",{class:`${M.panel}__stat-value`});i.appendChild(I(this.doc,"span",{text:v(n.magnitude)})),n.reliable===!1&&i.appendChild(I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:this.t("insights.smallSample")})),o.appendChild(t),o.appendChild(i)}return o}#o(c){const o=this.#c("insights.groups");c.some(t=>t.id===this.column)||(this.column=c[0].id),(!c.some(t=>t.id===this.by)||this.by===this.column)&&(this.by=(c.find(t=>t.id!==this.column)||c[0]).id),o.appendChild(this.#d("stats.column",c,this.column,t=>{this.column=t,this.by===t&&(this.by=(c.find(i=>i.id!==t)||c[0]).id),this.refresh()})),o.appendChild(this.#d("insights.by",c,this.by,t=>{this.by=t,this.column===t&&(this.column=(c.find(i=>i.id!==t)||c[0]).id),this.refresh()}));const n=H(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return n?(o.appendChild(this.#i(n)),o):(o.appendChild(I(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.needGroups")})),o)}#i(c){const o=I(this.doc,"dl",{class:`${M.panel}__stats`});Array.isArray(c.groups)&&c.groups.length===2&&this.#a(o,"insights.groups",`${c.groups[0]} · ${c.groups[1]}`),this.#a(o,"insights.test",String(c.method||c.test||""));const n=c.effectSize||{};this.#a(o,"insights.effect",`${n.name||""} ${v(n.value)}`.trim());const t=c.interval;let i="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const r=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";i=`${v(t.lower)} – ${v(t.upper)}${r}`}const a=this.#a(o,"insights.interval",i);return t&&t.method&&a.appendChild(I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(c.pValue)&&this.#a(o,"insights.pValue",v(c.pValue)),o}#s(){if(!H(this.host.anomalies))return null;let c;try{c=this.host.anomalies()}catch{return null}if(!c)return null;const o=this.#c("insights.anomalies");o.appendChild(I(this.doc,"p",{class:`${M.panel}__count`,text:this.t("insights.anomalyCount",{count:c.flagged||0,n:c.n||0})}));const n=I(this.doc,"dl",{class:`${M.panel}__stats`});this.#a(n,"insights.anomalyMethod",String(c.method||""));const t=this.#l(c);t!==null&&this.#a(n,"insights.anomalyThreshold",v(t)),o.appendChild(n);const i=(c.rows||[]).map(a=>({name:a.rowKey!=null?String(a.rowKey):`#${a.index}`,measure:(a.why||[]).map(r=>r.name||r.column).join(", "),magnitude:a.score}));return o.appendChild(this.#r(i)),o}#l(c){if(c.method==="mahalanobis")return Number.isFinite(c.cutoff)?c.cutoff:null;if(c.method==="iqr")return Number.isFinite(c.k)?c.k:null;const o=Array.isArray(c.columns)?c.columns[0]:null;return o&&Number.isFinite(o.threshold)?o.threshold:null}#a(c,o,n){c.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(o)}));const t=I(this.doc,"dd",{class:`${M.panel}__stat-value`});return t.appendChild(I(this.doc,"span",{text:n})),c.appendChild(t),t}#u(){if(!H(this.host.columnCapability)||!this.column)return null;const c=this.host.columnCapability(this.column);if(!c)return null;const o=this.#c("stats.section.capability"),n=I(this.doc,"dl",{class:`${M.panel}__stats`});for(const t of D){const i=c[t.field];if(i==null)continue;n.appendChild(I(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(t.key)}));const a=[I(this.doc,"span",{text:v(i)})],r=t.interval?c[t.interval]:null;r&&Number.isFinite(r.lower)&&a.push(I(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${v(r.lower)} – ${v(r.upper)}`,attrs:{title:`${Math.round(r.confidence*100)}%`}})),n.appendChild(I(this.doc,"dd",{class:`${M.panel}__stat-value`,children:a}))}return o.appendChild(n),o}#c(c){const o=this.doc.createElement("div");return o.appendChild(I(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(c)})),o}#d(c,o,n,t){const i=I(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(c)}});for(const a of o)i.appendChild(I(this.doc,"option",{text:a.title,attrs:{value:a.id,selected:a.id===n?!0:null}}));return i.value=n,this.off.push(N(i,"change",()=>t(i.value))),I(this.doc,"label",{class:`${M.panel}__field`,children:[I(this.doc,"span",{class:`${M.panel}__label`,text:this.t(c)}),i]})}}}),je("packages/dom/src/ui/toolpanel.js",function(e,V){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.cssEscape,N=Z.documentFor,W=Z.el,_=Z.on,H=Z.clear,G=V("packages/core/src/i18n/index.js").defaultMessages,D=V("packages/core/src/internal/util.js"),v=D.isFunction,k=D.nextFrame,y=V("packages/dom/src/cell/icons.js"),c=y.createIcon,o=y.updateIcon,n=y.icon,i=V("packages/dom/src/viewpicker.js").ViewPicker,r=V("packages/dom/src/formattingpanel.js").FormattingPanel,u=V("packages/dom/src/statisticspanel.js").StatisticsPanel,p=V("packages/dom/src/regressionpanel.js").RegressionPanel,b=V("packages/dom/src/comparepanel.js").ComparePanel,f=V("packages/dom/src/insightspanel.js").InsightsPanel,S=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,d=V("packages/core/src/compute/total.js").TOTAL_LABELS;class j extends S{dragging=null;refresh(){const F=this.root;if(!F)return;for(const Y of this.off)Y();this.off.length=0,H(F);const C=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(_(C,"input",()=>{this.query=C.value,this.paintList()})),F.appendChild(C),F.appendChild(this.buildZone("group","Row groups")),F.appendChild(this.buildZone("values","Grouped row calculation")),F.appendChild(this.buildZone("pivot","Pivot"));const z=W(this.doc,"div",{class:`${M.panel}__heading`});z.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(_(q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(_(Q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),z.appendChild(q),z.appendChild(Q),F.appendChild(z),this.list=W(this.doc,"div",{class:`${M.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),F.appendChild(this.list),this.paintList()}columns(){const F=this.host;return v(F.columns)?F.columns()||[]:F.columns&&v(F.columns.all)?F.columns.all():[]}paintList(){const F=this.list;if(!F)return;H(F);const C=String(this.query||"").trim().toLowerCase();for(const z of this.columns()){const q=String(z.title||z.id||"");if(C&&!q.toLowerCase().includes(C))continue;const Q=W(this.doc,"div",{class:`${M.panel}__column`,attrs:{"data-col":z.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});Q.appendChild(W(this.doc,"span",{class:`${M.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Y=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});Y.checked=!(z.layout&&z.layout.hidden),z.layout&&z.layout.lockVisible&&Y.setAttribute("disabled",""),this.off.push(_(Y,"change",()=>this.setVisible(z.id,Y.checked))),Q.appendChild(Y),Q.appendChild(W(this.doc,"span",{text:q})),Q.setAttribute("tabindex","0"),Q.setAttribute("role","listitem"),this.off.push(_(Q,"keydown",J=>this.onRowKey(J,z))),this.off.push(_(Q,"dragstart",()=>{this.dragging=z.id})),this.off.push(_(Q,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(_(Q,"dragover",J=>{if(!this.dragging||this.dragging===z.id)return;v(J.preventDefault)&&J.preventDefault();const te=U(J,Q);Q.setAttribute("data-drop",te?"before":"after")})),this.off.push(_(Q,"dragleave",()=>Q.removeAttribute("data-drop"))),this.off.push(_(Q,"drop",J=>{v(J.preventDefault)&&J.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||te===z.id)&&this.moveColumn(te,z.id,U(J,Q))})),F.appendChild(Q)}}onRowKey(F,C){const z=F&&F.key,q=j.zoneKeys[String(z).toLowerCase()];if(q&&!F.ctrlKey&&!F.metaKey&&!F.altKey){v(F.preventDefault)&&F.preventDefault(),this.toggleZone(q,C);return}if(z!=="ArrowUp"&&z!=="ArrowDown")return;const Q=z==="ArrowUp",Y=this.columns().map(de=>de.id),J=Y.indexOf(C.id);if(J<0)return;if(v(F.preventDefault)&&F.preventDefault(),!F.shiftKey){const de=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ie=de.findIndex(ue=>ue.getAttribute("data-col")===C.id),oe=de[ie+(Q?-1:1)];oe&&v(oe.focus)&&oe.focus();return}const te=C.layout&&(C.layout.movable===!1||C.layout.lockPosition),ee=String(C.title||C.id||"");if(te){this.announce(this.t("a11y.panel.cannotMove",{column:ee}),{repeat:!0});return}const re=Y[J+(Q?-1:1)];if(!re){this.announce(this.t(Q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ee}),{repeat:!0});return}this.moveColumn(C.id,re,Q),this.announce(this.t("a11y.panel.moved",{column:ee,at:Q?J:J+2,of:Y.length}),{repeat:!0});const se=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${I(C.id)}"]`):null;se&&v(se.focus)&&se.focus()}toggleZone(F,C){const z=this.titleOf(C.id),q=this.t(j.zoneLabel[F]||"panel.zone.group");if(this.zoneColumns(F).includes(C.id)){this.dropFromZone(F,C.id),this.announce(this.t("a11y.panel.removedFrom",{column:z,list:q}),{repeat:!0}),this.restoreFocus(C.id);return}if(this.addToZone(F,C.id)){this.announce(this.t("a11y.panel.addedTo",{column:z,list:q}),{repeat:!0}),this.restoreFocus(C.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:z,list:q}),{repeat:!0})}restoreFocus(F){const C=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${I(F)}"]`):null;C&&v(C.focus)&&C.focus()}announce(F,C){const z=this.host||{};v(z.announce)&&z.announce(F,C)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const F of this.list.querySelectorAll("[data-drop]"))F.removeAttribute("data-drop")}moveColumn(F,C,z){const q=this.host||{};v(q.moveColumn)&&(q.moveColumn(F,C,z),this.refresh())}buildZone(F,C){const z=W(this.doc,"div",{class:`${M.panel}__zone`,attrs:{"data-zone":F,role:"group","aria-label":C}});z.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneTitle`,text:C}));const q=this.zoneColumns(F);let Q=j.zoneAbout[F]||"";F==="values"&&q.length&&!this.zoneColumns("group").length&&(Q+=" Add a row group to see them."),Q&&z.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneAbout`,text:Q}));const Y=W(this.doc,"div",{class:`${M.panel}__zoneBody`});q.length||Y.appendChild(W(this.doc,"span",{class:`${M.panel}__zoneHint`,text:this.t(j.zoneHint[F]||"panel.zoneHint.any")})),F==="values"&&Y.classList.add(`${M.panel}__zoneBody--rows`);for(const J of q){const te=W(this.doc,"span",{class:[M.chip,F==="values"?`${M.chip}--row`:""]});if(te.appendChild(W(this.doc,"span",{class:`${M.chip}__label`,text:this.titleOf(J)})),F==="values"&&v(this.host.setValueAggregation)){const re=v(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",se=W(this.doc,"select",{class:`${M.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const de of j.aggregations)se.appendChild(W(this.doc,"option",{text:this.t(`total.${de.name}`),attrs:{value:de.name,selected:de.name===re?"":null}}));se.value=re,this.off.push(_(se,"change",()=>{this.host.setValueAggregation(J,se.value),this.refresh()})),te.appendChild(se)}const ee=W(this.doc,"button",{class:M.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(_(ee,"click",()=>this.dropFromZone(F,J))),te.appendChild(ee),Y.appendChild(te)}return this.off.push(_(z,"dragover",J=>{v(J.preventDefault)&&J.preventDefault(),z.setAttribute("data-over","true")})),this.off.push(_(z,"dragleave",()=>z.removeAttribute("data-over"))),this.off.push(_(z,"drop",J=>{v(J.preventDefault)&&J.preventDefault(),z.removeAttribute("data-over"),this.dragging&&this.addToZone(F,this.dragging)})),z.appendChild(Y),z}static aggregations=Object.freeze(Object.keys(d).map(F=>({name:F})));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(F){const C=j.zoneApi[F],z=this.host;return C&&v(z[C.read])?z[C.read]()||[]:[]}titleOf(F){const C=this.columns().find(z=>z.id===F);return String(C&&(C.title||C.id)||F)}addToZone(F,C){const z=j.zoneApi[F],q=this.columns().find(Y=>Y.id===C);if(!z||!q||q[z.permission]===!1||!v(this.host[z.write]))return!1;const Q=this.zoneColumns(F);return Q.includes(C)?!1:(this.host[z.write]([...Q,C]),this.refresh(),!0)}dropFromZone(F,C){const z=j.zoneApi[F];return!z||!v(this.host[z.write])?!1:(this.host[z.write](this.zoneColumns(F).filter(q=>q!==C)),this.refresh(),!0)}setVisible(F,C){const z=this.host;C&&v(z.showColumns)?z.showColumns([F]):!C&&v(z.hideColumns)&&z.hideColumns([F])}}class E extends S{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 F=this.root;if(!F)return;for(const te of this.off)te();this.off.length=0,H(F);const C=this.host,z=(v(C.columns)?C.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!v(C.filterFor))return;const q=z.filter(te=>this.isFiltered(te.id));F.appendChild(this.buildSearch()),F.appendChild(this.buildSummary(q.length,z.length));const Q=this.query.trim().toLowerCase(),Y=Q?z.filter(te=>String(te.title||te.id).toLowerCase().includes(Q)):z;if(!Y.length){F.appendChild(W(this.doc,"p",{class:`${M.panel}__empty`,text:Q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${M.panel}__filters`});for(const te of Y)J.appendChild(this.buildSection(te));F.appendChild(J)}isFiltered(F){const C=this.host;return v(C.isFiltered)?C.isFiltered(F)===!0:!1}buildSearch(){const F=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return F.value=this.query,this.off.push(_(F,"input",()=>{this.query=F.value||"",this.refresh();const C=this.root&&this.root.querySelector?this.root.querySelector(`.${M.panel}__search`):null;C&&v(C.focus)&&C.focus()})),F}buildSummary(F,C){const z=W(this.doc,"div",{class:`${M.panel}__filterSummary`});if(z.appendChild(W(this.doc,"span",{class:`${M.panel}__filterCount`,text:F?this.t("panel.filterSummaryActive",{active:F,total:C}):this.t("panel.filterSummaryNone",{total:C}),attrs:{"data-active":F?"true":"false"}})),!F)return z;const q=W(this.doc,"button",{class:`${M.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(_(q,"click",()=>{v(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),z.appendChild(q),z}buildSection(F){const C=F.id,z=String(F.title||C),q=this.isFiltered(C),Q=this.open.has(C),Y=W(this.doc,"section",{class:`${M.panel}__filter`,attrs:{"data-col":C,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${M.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Q?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:z})},children:[c(this.doc,Q?"chevronDown":"chevronRight",{className:`${M.panel}__twisty`}),W(this.doc,"span",{class:`${M.panel}__filterName`,text:z})]});q&&J.appendChild(W(this.doc,"span",{class:`${M.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=W(this.doc,"div",{class:`${M.panel}__filterBody`,style:{display:Q?"":"none"}}),ee=()=>{if(te.firstChild)return;const re=this.host.filterFor(C);re&&v(re.element)&&te.appendChild(re.element())};if(this.off.push(_(J,"click",()=>{const re=this.open.has(C);re?this.open.delete(C):this.open.add(C),J.setAttribute("aria-expanded",re?"false":"true"),te.style.display=re?"none":"";const se=J.firstElementChild;se&&o(se,re?"chevronRight":"chevronDown"),re||ee()})),Y.appendChild(J),q){const re=W(this.doc,"button",{class:`${M.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:z}),title:this.t("panel.clearFilter")},children:[c(this.doc,"close",{className:M.icon})]});this.off.push(_(re,"click",se=>{v(se.stopPropagation)&&se.stopPropagation(),v(this.host.clearFilter)&&this.host.clearFilter(C),this.refresh()})),Y.appendChild(re)}return Y.appendChild(te),Q&&ee(),Y}}class O extends S{refresh(){const F=this.root;if(!F)return;if(this.box){const Q=v(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Q&&(this.box.value=Q),this.paintCount();return}for(const Q of this.off)Q();this.off.length=0,H(F);const C=v(this.host.quickFilter)?this.host.quickFilter():"",z=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});z.value=C||"",this.off.push(_(z,"input",()=>{v(this.host.setQuickFilter)&&this.host.setQuickFilter(z.value),this.paintCount()})),F.appendChild(z),this.box=z;const q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(_(q,"click",()=>{z.value="",v(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),v(z.focus)&&z.focus()})),F.appendChild(q),this.count=W(this.doc,"p",{class:`${M.panel}__count`}),F.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){k(()=>{this.box&&v(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const F=v(this.host.rowCount)?this.host.rowCount():null,C=v(this.host.totalRowCount)?this.host.totalRowCount():null;if(F===null||C===null){this.count.textContent="";return}this.count.textContent=F===C?this.t("count.rows",{count:C}):this.t("panel.rowsOf",{shown:F,total:C})}}const T=Object.freeze({columns:j,filters:E,views:i,quick:O,formatting:r,statistics:u,regression:p,compare:b,insights:f}),A=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 L{panels=[];actions=[];root=null;openPanel=null;off=[];t(F,C){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(F,C)}init(F){const C=F||{};this.doc=N(C),this.host=C.host||{},this.messages=C.messages||C.grid&&C.grid.messages||G,this.icons=C.icons===void 0?C.side==="left":!!C.icons,this.side=C.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[M.panel,`${M.panel}--${this.side}`,this.icons?`${M.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${M.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${M.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:`${M.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Q of Array.isArray(C.actions)?C.actions:[])this.registerAction(Q);const z=C.registry||{},q=Array.isArray(C.panels)&&C.panels.length?C.panels:["columns","filters"];for(const Q of q){const Y=typeof Q=="string"?Q:Q.name,J=typeof Q=="function"?Q:z[Y]||T[Y];J&&this.registerPanel(String(Y),J,typeof Q=="object"?Q:{})}C.openPanel&&this.show(C.openPanel)}registerPanel(F,C,z){const q=new C;q.init({document:this.doc,host:this.host,props:z&&z.props||{}});const Q=z&&z.title||F,Y=z&&z.icon||F,J=W(this.doc,"button",{class:`${M.panel}__tab`,text:this.icons?null:Q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":F,title:this.icons?Q:null,"aria-label":this.icons?Q:null}});return this.icons&&J.appendChild(c(this.doc,Y,{className:`${M.panel}__icon`})),this.off.push(_(J,"click",()=>this.toggle(F))),this.tabs.appendChild(J),this.panels.push({name:F,title:Q,panel:q}),q}registerAction(F){if(!F||!F.name)return null;if(F.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${M.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const C=W(this.doc,"button",{class:`${M.panel}__action`,text:this.icons?null:v(F.title)?String(F.title()):F.title,attrs:{type:"button","data-action":F.name,title:v(F.title)?null:F.title,"aria-label":v(F.title)?null:F.title}});if(this.icons){const Q=(v(F.icon)?F.icon():F.icon)||(n(F.name)?F.name:"blank");C.appendChild(c(this.doc,Q,{className:`${M.panel}__icon`})),C.setAttribute("data-icon",Q)}const z=_(C,"click",()=>{v(F.enabled)&&!F.enabled()||(v(F.run)&&F.run(),this.paintActions())});return this.off.push(z),this.actionGroup.appendChild(C),this.actions.push({...F,button:C,offClick:z}),this.paintActions(),C}removeAction(F){const C=this.actions.findIndex(q=>q.name===F);if(C<0)return!1;const z=this.actions[C];return v(z.offClick)&&z.offClick(),z.button&&z.button.parentNode&&z.button.parentNode.removeChild(z.button),this.actions.splice(C,1),!0}paintActions(){for(const F of this.actions){if(!F.button)continue;const C=v(F.enabled)?!!F.enabled():!0;if(F.button.disabled=!C,F.button.setAttribute("aria-disabled",C?"false":"true"),v(F.active)&&F.button.setAttribute("aria-pressed",F.active()?"true":"false"),v(F.title)){const z=String(F.title());F.button.setAttribute("title",z),F.button.setAttribute("aria-label",z),!this.icons&&F.button.textContent!==z&&(F.button.textContent=z)}if(this.icons&&v(F.icon)){const z=String(F.icon());F.button.getAttribute("data-icon")!==z&&(H(F.button),F.button.appendChild(c(this.doc,z,{className:`${M.panel}__icon`})),F.button.setAttribute("data-icon",z))}}}show(F){const C=this.panels.find(z=>z.name===F);return C?(H(this.body),v(C.panel.refresh)&&C.panel.refresh(),this.body.appendChild(C.panel.element()),this.openPanel=F,this.paintTabs(),v(C.panel.focus)&&C.panel.focus(),!0):!1}hide(){H(this.body),this.openPanel=null,this.paintTabs()}toggle(F){this.openPanel===F?this.hide():this.show(F)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let F=0;F<this.tabs.childNodes.length;F++){const C=this.tabs.childNodes[F];C&&C.setAttribute&&C.setAttribute("aria-selected",C.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const F=this.panels.find(C=>C.name===this.openPanel);F&&v(F.panel.refresh)&&!this.#e(F.panel)&&F.panel.refresh(),this.paintActions()}#e(F){const C=this.doc&&this.doc.activeElement;if(!C||C===this.doc.body)return!1;const z=v(F.element)?F.element():null;return!!(z&&v(z.contains)&&z.contains(C))}destroy(){for(const F of this.off)F();this.off.length=0;for(const F of this.panels)v(F.panel.destroy)&&F.panel.destroy();this.panels=[],this.root=null}}const $=L;function U(x,F){if(!F.getBoundingClientRect||typeof x.clientY!="number")return!0;const C=F.getBoundingClientRect();return x.clientY<C.top+C.height/2}}),je("packages/dom/src/ui/groupbyzone.js",function(e,V){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return k}});const M=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=V("packages/dom/src/editors/common.js"),N=I.CLS,W=I.el,_=I.on,H=I.clear,B=I.cssEscape,D=V("packages/core/src/internal/util.js").isFunction,v="text/x-lattice-col";class k extends M{dragging=null;#e=[];init(c){this.ctx=c,this.doc=c.document,this.host=c.host||{},this.props=c.props||{},this.root=W(this.doc,"div",{class:N.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const c=this.host;return D(c.columns)?c.columns()||[]:c.columns&&D(c.columns.all)?c.columns.all():[]}groups(){return D(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(c){D(this.host.setGroupBy)&&this.host.setGroupBy(c)}titleOf(c){const o=this.columns().find(n=>n.id===c);return String(o&&(o.title||o.id)||c)}canGroup(c){const o=this.columns().find(n=>n.id===c);return!!o&&o.allowGroup!==!1&&!o.generated}announce(c,o){D(this.host.announce)&&this.host.announce(c,o)}refresh(){const c=this.root;if(!c)return;for(const t of this.off)t();this.off.length=0,H(c),c.appendChild(W(this.doc,"span",{class:N.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const o=this.groups(),n=W(this.doc,"div",{class:N.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});o.length||n.appendChild(W(this.doc,"span",{class:N.groupZoneHint,text:this.t("groupZone.hint")})),o.forEach((t,i)=>n.appendChild(this.#t(t,i,o.length))),c.appendChild(n),this.chips=n,c.appendChild(this.#i(o)),this.off.push(_(c,"dragover",t=>{this.dragging==null&&!this.#l(t)||(D(t.preventDefault)&&t.preventDefault(),c.setAttribute("data-over","true"))})),this.off.push(_(c,"dragleave",()=>c.removeAttribute("data-over"))),this.off.push(_(c,"drop",t=>{D(t.preventDefault)&&t.preventDefault(),c.removeAttribute("data-over");const i=this.#l(t)||this.dragging;i!=null&&this.#o(i,this.groups().length)})),this.#s()}#t(c,o,n){const t=this.titleOf(c),i=W(this.doc,"div",{class:[N.chip,N.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":c,"aria-label":this.t("groupZone.chip",{column:t,at:o+1,of:n})}});i.appendChild(W(this.doc,"span",{class:N.groupZoneChipText,text:t}));const a=W(this.doc,"button",{class:N.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(_(a,"click",()=>this.#r(c))),i.appendChild(a),this.off.push(_(i,"dragstart",r=>{this.dragging=c,r.dataTransfer&&D(r.dataTransfer.setData)&&r.dataTransfer.setData(v,c)})),this.off.push(_(i,"dragend",()=>{this.dragging=null})),this.off.push(_(i,"dragover",r=>{const s=this.#l(r)||this.dragging;s==null||s===c||D(r.preventDefault)&&r.preventDefault()})),this.off.push(_(i,"drop",r=>{const s=this.#l(r)||this.dragging;s!=null&&(D(r.preventDefault)&&r.preventDefault(),D(r.stopPropagation)&&r.stopPropagation(),this.#o(s,o))})),this.off.push(_(i,"keydown",r=>this.#n(r,c,o))),i}#n(c,o,n){const t=c&&c.key,i=this.groups();if(t==="Delete"||t==="Backspace"){D(c.preventDefault)&&c.preventDefault(),this.#r(o,i,n);return}const a=t==="ArrowLeft"||t==="ArrowUp",r=t==="ArrowRight"||t==="ArrowDown",s=t==="Home",u=t==="End";if(!a&&!r&&!s&&!u)return;if(D(c.preventDefault)&&c.preventDefault(),c.shiftKey&&(a||r)){const m=n+(a?-1:1);if(m<0||m>=i.length){this.announce(this.t(a?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(o)}),{repeat:!0});return}const b=i.slice();b.splice(n,1),b.splice(m,0,o),this.setGroups(b),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(o),at:m+1,of:b.length}),{repeat:!0}),this.#a(o);return}let l=n+(a?-1:r?1:0);s&&(l=0),u&&(l=i.length-1);const p=i[l];p&&this.#a(p)}#r(c,o=this.groups(),n=o.indexOf(c)){const t=this.titleOf(c);this.setGroups(o.filter(a=>a!==c)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const i=this.groups();i.length?this.#a(i[Math.min(n,i.length-1)]):this.#u()}#o(c,o){if(!this.canGroup(c)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(c),list:this.t("panel.zone.group")}),{repeat:!0});return}const n=this.groups(),t=n.indexOf(c),i=n.slice();t>=0&&(i.splice(t,1),t<o&&(o-=1)),i.splice(Math.max(0,Math.min(o,i.length)),0,c),this.setGroups(i);const a=i.indexOf(c);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(c),at:a+1,of:i.length}:{column:this.titleOf(c),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(c)}#i(c){const o=new Set(c),n=W(this.doc,"label",{class:N.groupZoneAdd}),t=W(this.doc,"select",{class:N.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const i of this.columns())o.has(i.id)||!this.canGroup(i.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(i.id),attrs:{value:i.id}}));return this.off.push(_(t,"change",()=>{const i=t.value;i&&this.#o(i,this.groups().length)})),this.adderSelect=t,n.appendChild(t),n}#s(){for(const o of this.#e)o();this.#e.length=0;const c=this.props&&this.props.header;if(!(!c||!D(c.querySelectorAll)))for(const o of c.querySelectorAll("[data-col]")){const n=D(o.getAttribute)?o.getAttribute("data-col"):null;!n||!this.canGroup(n)||(D(o.setAttribute)&&o.setAttribute("draggable","true"),this.#e.push(_(o,"dragstart",t=>{this.dragging=n,t.dataTransfer&&D(t.dataTransfer.setData)&&t.dataTransfer.setData(v,n)})),this.#e.push(_(o,"dragend",()=>{this.dragging=null})))}}#l(c){const o=c&&c.dataTransfer;if(o&&D(o.getData)){const n=o.getData(v);if(n)return n}return null}#a(c){const o=this.chips&&D(this.chips.querySelector)?this.chips.querySelector(`[data-col="${B(c)}"]`):null;o&&D(o.focus)&&o.focus()}#u(){this.adderSelect&&D(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const c of this.#e)c();this.#e.length=0,super.destroy()}}}),je("packages/dom/src/ui/tooltip.js",function(e,V){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/internal/util.js").isFunction;class G{root=null;init(y){this.doc=y.document,this.root=N(this.doc,"div",{class:`${M.tooltip}__text`}),this.update(y.content)}update(y){if(!this.root)return;const c=y==null?"":String(y);this.root.textContent!==c&&(this.root.textContent=c)}element(){return this.root}destroy(){this.root=null}}class D{root=null;component=null;timer=null;target=null;off=[];constructor(y){const c=y||{};this.doc=I(c),this.host=c.host||this.doc.body,this.delay=c.delay??400,this.hideDelay=c.hideDelay??0,this.components={text:G,...c.components||{}}}show(y){this.cancelTimer();const c=y.delay??this.delay;if(!c){this.showNow(y);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(y)},c)}showNow(y){const c=y.component||"text",o=typeof c=="function"?c:this.components[c]||G;return this.root||(this.root=N(this.doc,"div",{class:M.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(),c=this.doc.defaultView||{};this.root.style.left=`${y.left+(c.scrollX||0)}px`,this.root.style.top=`${y.bottom+(c.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,c,o){const n=()=>this.show({target:y,content:c(),...o||{}}),t=()=>this.hide(),i=[W(y,"mouseenter",n),W(y,"mouseleave",t),W(y,"focus",n),W(y,"blur",t)],a=()=>{for(const r of i)r()};return this.off.push(a),a}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 v=D}),je("packages/dom/src/ui/pagination.js",function(e,V){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.on,_=Z.clear,B=V("packages/core/src/i18n/index.js").defaultMessages,D=V("packages/core/src/internal/util.js").isFunction;function v(c){const o=Math.max(1,Number(c.pageSize)||100),n=c.total==null?null:Math.max(0,Number(c.total)),t=n==null?null:Math.max(1,Math.ceil(n/o)),i=Math.max(0,t==null?Number(c.page)||0:Math.min(Number(c.page)||0,t-1)),a=n===0?0:i*o+1,r=n==null?(i+1)*o:Math.min(n,(i+1)*o);return{page:i,pageSize:o,pageCount:t,from:a,to:r,first:i===0,last:t==null?c.hasMore!==!0:i>=t-1,total:n}}class k{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(o){const n=o||{};this.doc=I(n),this.host=n.host||{},this.pageSize=Number(n.pageSize)||100;const t=Array.isArray(n.pageSizes)&&n.pageSizes.length?[...n.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((i,a)=>i-a),this.page=Number(n.page)||0,this.total=n.total===void 0?null:n.total,this.locale=n.locale,this.messages=n.messages||null,this.onChange=n.onChange||null,this.root=N(this.doc,"nav",{class:M.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(o,n){const t=this.messages;return(t&&typeof t.t=="function"?t:B).t(o,n)}element(){return this.root}model(){return v({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 n=this.page;this.page=o;const t=this.model();return this.page=t.page,this.paint(),this.page!==n&&D(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 n=this.page*this.pageSize;this.pageSize=Math.max(1,Number(o)||1),this.page=Math.floor(n/this.pageSize),this.paint(),D(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const o=this.root;if(!o)return;for(const l of this.off)l();this.off.length=0,_(o);const n=this.model(),t=N(this.doc,"select",{class:`${M.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const l of this.pageSizes)t.appendChild(N(this.doc,"option",{text:String(l),attrs:{value:l}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),o.appendChild(t);const i=n.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:n.from,to:n.to}):this.t("pagination.summary",{from:n.from,to:n.to,total:n.total});o.appendChild(N(this.doc,"span",{class:`${M.pagination}__summary`,text:i}));const a=(l,p,m,b)=>{const g=N(this.doc,"button",{class:`${M.pagination}__button`,text:l,attrs:{type:"button","aria-label":b,disabled:m?"":null}});return m||this.off.push(W(g,"click",p)),g};o.appendChild(a("«",()=>this.goTo(0),n.first,this.t("pagination.first"))),o.appendChild(a("‹",()=>this.previous(),n.first,this.t("pagination.previous")));const r=N(this.doc,"span",{class:`${M.pagination}__page`});r.appendChild(N(this.doc,"span",{text:`${this.t("pagination.page")} `}));const s=N(this.doc,"input",{class:`${M.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":n.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:n.pageCount}),size:String(Math.max(2,String(n.pageCount??n.page+1).length))}});s.value=String(n.page+1);const u=()=>{const l=parseInt(String(s.value).trim(),10);if(!Number.isFinite(l)){s.value=String(this.model().page+1);return}this.goTo(l-1)};this.off.push(W(s,"keydown",l=>{l.key==="Enter"?(u(),l.preventDefault?.()):l.key==="Escape"?(s.value=String(this.model().page+1),s.blur?.()):l.stopPropagation?.()})),this.off.push(W(s,"blur",()=>u())),this.off.push(W(s,"focus",()=>s.select?.())),r.appendChild(s),n.pageCount!=null&&r.appendChild(N(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:n.pageCount})}`})),o.appendChild(r),o.appendChild(a("›",()=>this.next(),n.last,this.t("pagination.next"))),o.appendChild(a("»",()=>this.last(),n.last||n.pageCount==null,this.t("pagination.last")))}destroy(){for(const o of this.off)o();this.off.length=0,this.root=null}}const y=k}),je("packages/dom/src/ui/overlay.js",function(e,V){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Z=V("packages/dom/src/editors/common.js"),M=Z.CLS,I=Z.documentFor,N=Z.el,W=Z.clear,H=V("packages/core/src/internal/util.js").isFunction,G=V("packages/core/src/i18n/index.js").defaultMessages;function D(n,t){const i=n&&n.grid&&n.grid.messages;return(i&&H(i.t)?i:G).t(t)}class v{root=null;init(t){this.doc=t.document,this.root=N(this.doc,"div",{class:`${M.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[N(this.doc,"span",{class:`${M.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),N(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||D(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class k{root=null;init(t){this.doc=t.document,this.root=N(this.doc,"div",{class:`${M.overlay}__empty`,attrs:{role:"status"},children:[N(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||D(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:v,empty:k});class c{root=null;slot=null;component=null;current=null;init(t){const i=t||{};this.doc=I(i),this.components={...y,...i.components||{}},this.root=N(this.doc,"div",{class:M.overlay,attrs:{"data-open":"false"}}),this.slot=N(this.doc,"div",{class:`${M.overlay}__slot`}),this.root.appendChild(this.slot),i.host&&i.host.appendChild(this.root)}element(){return this.root}show(t,i){const a=typeof t=="function"?t:this.components[t];return a?(this.hide(),this.component=new a,this.component.init({document:this.doc,message:i&&i.message,...i&&i.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&&H(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,i){this.components[t]=i}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const o=c}),je("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 M=V("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return M.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return M.resolveMenuItems}});const I=V("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return I.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return I.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return I.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return I.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return I.toolPanels}});const N=V("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return N.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 H=V("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return H.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return H.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return H.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return H.overlays}})}),je("packages/dom/src/ui/celltooltip.js",function(e,V){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const Z=V("packages/dom/src/editors/common.js"),M=Z.documentFor,I=Z.el,N=Z.on,W=Z.clear,_=V("packages/core/src/internal/util.js"),H=_.isFunction,B=_.warnOnce,D=V("packages/dom/src/cell/sanitise.js").sanitiseHtml,k=V("packages/dom/src/detailhost.js").insideDetail,c=V("packages/dom/src/renderer/renderer.js").displayIndexOf,o=V("packages/dom/src/renderer/viewport.js"),n=o.CLASS,t=o.NAMESPACE,a=V("packages/dom/src/themeof.js").carryTheme,r={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"},s=400,u=140,l=6;let p=0;class m{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(f){const w=f||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=M(w),p+=1,this.#s=`lat-cell-tooltip-${p}`}mount(){const f=this.#n&&this.#n.root;if(!f||!H(f.addEventListener))return;const w=this.#e.on("cell:mouseover",d=>this.#b(d));H(w)&&this.#f.push(w);const S=this.#e.on("cell:mouseout",()=>this.#A());H(S)&&this.#f.push(S),this.#f.push(N(f,"focusin",d=>this.#v(d))),this.#f.push(N(f,"focusout",()=>this.#A())),this.#f.push(N(this.#r,"keydown",d=>this.#y(d),!0));const h=this.#r.defaultView;h&&H(h.addEventListener)&&this.#f.push(N(h,"scroll",()=>this.hide(),!0))}#p(){const f=H(this.#e.get)?this.#e.get("tooltip"):null,w=f&&typeof f=="object"?f:{},S=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):s,h=w.maxWidth;return{delay:S,hideDelay:u,maxWidth:typeof h=="number"&&Number.isFinite(h)?`${h}px`:typeof h=="string"&&h?h:null}}#g(f){const w=f&&f.cell?f.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!H(w.render)&&!H(w.mount)?null:w}#w(f){if(!f||!H(f.closest))return null;const w=f.closest(`.${n.row}`);if(!w)return null;const S=c(w);if(S<0)return null;const h=this.#t.rowAt(S);if(!h)return null;const d=f.getAttribute("data-col");if(!d)return null;const j=this.#t.columns.get(d);return j?{row:h,key:h.key,index:S,colId:d,column:j,value:this.#t.cellValue?this.#t.cellValue(h,j):void 0,text:this.#t.cellText?this.#t.cellText(h,j):"",cell:f,grid:this.#e}:null}#b(f){const w=f&&f.target;if(!this.#g(f&&f.column)){this.#A();return}this.#S(w)}#v(f){const w=f&&f.target;if(!w||!H(w.closest)||k(w,this.#n.root))return;const S=w.closest(`.${n.cell}`);if(!S||S!==w){this.#A();return}const h=S.getAttribute("data-col"),d=h?this.#t.columns.get(h):null;if(!this.#g(d)){this.#A();return}this.#S(S)}#y(f){!f||f.key!=="Escape"||f.defaultPrevented||this.#l&&(H(f.preventDefault)&&f.preventDefault(),this.hide())}#S(f){if(this.#m||!f||(this.#D(),this.#l&&this.#a===f))return;this.#N();const{delay:w}=this.#p();if(!w){this.#C(f);return}this.#d=setTimeout(()=>{this.#d=null,this.#C(f)},w)}#A(){if(this.#N(),!this.#l||this.#h!==null)return;const{hideDelay:f}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},f)}#j(){if(this.#o)return this.#o;const f=this.#r,w=I(f,"div",{class:[t,r.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=I(f,"div",{class:r.body}),w.appendChild(this.#i),this.#f.push(N(w,"mouseenter",()=>this.#D())),this.#f.push(N(w,"mouseleave",()=>this.#A()));const S=f.body;return S&&H(S.appendChild)&&S.appendChild(w),this.#o=w,w}#O(f,w){const S=this.#i;if(W(S),f==null||f==="")return!1;if(typeof f=="string")return S.textContent=f,!0;if(typeof f=="object"){if(typeof f.nodeType=="number")return S.appendChild(f),!0;const h=f;if(typeof h.html=="string")return S.innerHTML=D(h.html),!0;if(h.title!==void 0||h.rows!==void 0||h.note!==void 0)return this.#E(h),!0}return B(`tooltip-content:${w}`,`Column '${w}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#E(f){const w=this.#r,S=this.#i,h=j=>j==null?"":String(j);f.title!==void 0&&f.title!==null&&f.title!==""&&S.appendChild(I(w,"div",{class:r.title,text:h(f.title)}));const d=Array.isArray(f.rows)?f.rows:[];if(d.length){const j=I(w,"div",{class:r.rows});for(const E of d){if(!E||typeof E!="object")continue;const O=I(w,"div",{class:r.row});O.appendChild(I(w,"span",{class:r.label,text:h(E.label)})),O.appendChild(I(w,"span",{class:r.value,text:h(E.value)})),j.appendChild(O)}S.appendChild(j)}f.note!==void 0&&f.note!==null&&f.note!==""&&S.appendChild(I(w,"div",{class:r.note,text:h(f.note)}))}#C(f){if(this.#m)return;const w=this.#w(f);if(!w){this.hide();return}const S=this.#g(w.column);if(!S){this.hide();return}this.hide();const h=this.#j();a(h,this.#n&&this.#n.root);let d;if(H(S.render))try{d=S.render(w)}catch(O){B(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const j=this.#O(d,w.colId);if(H(S.mount))try{S.mount(this.#i,w),this.#u=S}catch(O){B(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!j)return;const{maxWidth:E}=this.#p();E&&(h.style.maxWidth=E),this.#a=f,this.#l=!0,h.setAttribute("data-open","true"),this.#T(f),this.#I(f)}#T(f){if(!H(f.setAttribute))return;const w=H(f.getAttribute)?f.getAttribute("aria-describedby"):null;this.#c={cell:f,previous:w},f.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#I(f){const w=this.#o;if(!w||!H(f.getBoundingClientRect))return;const S=this.#r.defaultView;if(!S)return;const h=f.getBoundingClientRect(),d=H(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},j=S.innerWidth||0,E=S.innerHeight||0,O=d.width||0,T=d.height||0;let A=h.bottom+l;const P=h.top-l-T;A+T>E-l&&P>=l&&(A=P),E&&(A=Math.max(l,Math.min(A,Math.max(l,E-T-l))));let L=h.left;j&&(L=Math.min(L,Math.max(l,j-O-l))),L=Math.max(l,L),w.style.left=`${Math.round(L)}px`,w.style.top=`${Math.round(A)}px`}hide(){if(this.#N(),this.#D(),!this.#l)return;if(this.#l=!1,this.#u&&H(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){B("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",w)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const f=this.#c;f&&H(f.cell.setAttribute)&&(f.previous?f.cell.setAttribute("aria-describedby",f.previous):H(f.cell.removeAttribute)&&f.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#D(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const f of this.#f)f();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const b=m}),je("packages/dom/src/platform.js",function(e,V){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Z}});function Z(){const M=globalThis.navigator,I=String(M&&(M.userAgentData?.platform||M.platform)||"");return/mac|iphone|ipad/i.test(I)}}),je("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 n}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/dom/src/platform.js").macLike,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/dom/src/ui/contextmenu.js").ContextMenu,D=V("packages/core/src/compute/total.js"),v=D.aggregatesFor,k=D.totalLabel,y=10,c=150;function o(S,h){const d=(te,ee)=>(S&&S.messages?S.messages:H).t(te,ee),j=S.columns.get(h);if(!j)return[];const E=S.sort.get(),O=E.find(te=>te.col===h),T=j.layout&&j.layout.pin,A=S.state.get().group||[],P=A.includes(h);if(j.generated&&Array.isArray(j.groupedIds))return a(S,j,A);const L=!j.sort||j.sort.enabled!==!1,$=!j.filter||j.filter.enabled!==!1,U=[];L&&U.push({name:d("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>S.sort.set([{col:h,dir:"asc"}])},{name:d("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>S.sort.set([{col:h,dir:"desc"}])},{name:d("menu.clearSort"),disabled:!O,action:()=>S.sort.set(E.filter(te=>te.col!==h))},{separator:!0}),$&&U.push({name:d("menu.filterEllipsis"),action:()=>S.emit("column:filter:open",{colId:h})},{separator:!0}),U.push({name:d("menu.columnStatistics"),action:()=>S.emit("column:profile:open",{colId:h})},{separator:!0}),U.push({name:d("menu.pinColumn"),children:[{name:d("menu.pinStart"),disabled:T==="start",action:()=>S.columns.pin(h,"start")},{name:d("menu.pinEnd"),disabled:T==="end",action:()=>S.columns.pin(h,"end")},{name:d("menu.unpin"),disabled:!T,action:()=>S.columns.pin(h,null)}]});const x=!(j.layout&&(j.layout.movable===!1||j.layout.lockPosition)),F=!(j.layout&&j.layout.resizable===!1),C=te=>{const ee=S.columns.get(te);return Number(ee&&ee.layout&&ee.layout.width)||c},z=S.columns.visible().filter(te=>!te.generated).map(te=>te.id),q=z.indexOf(h);if(U.push({name:d("menu.sizeToFit"),action:()=>S.columns.autoSize(h)},{name:d("menu.sizeAllToFit"),action:()=>S.columns.fit()},{name:d("menu.width"),disabled:!F,children:[{name:d("menu.narrower"),disabled:!F,action:()=>S.columns.resize(h,Math.max(1,C(h)-y))},{name:d("menu.wider"),disabled:!F,action:()=>S.columns.resize(h,C(h)+y)},{name:d("menu.autosize"),disabled:!F,action:()=>S.columns.autoSize(h)}]},{separator:!0},{name:d("menu.moveColumn"),disabled:!x,children:[{name:d("menu.moveLeft"),disabled:!x||q<=0,action:()=>S.columns.move(h,Math.max(0,q-1))},{name:d("menu.moveRight"),disabled:!x||q<0||q>=z.length-1,action:()=>S.columns.move(h,Math.min(z.length-1,q+1))},{name:d("menu.moveToStart"),disabled:!x||q<=0,action:()=>S.columns.move(h,0)},{name:d("menu.moveToEnd"),disabled:!x||q<0||q>=z.length-1,action:()=>S.columns.move(h,z.length-1)}]},{separator:!0}),j.allowGroup!==!1&&U.push({name:d(P?"menu.ungroup":"menu.groupBy"),action:()=>S.columns.group(P?A.filter(te=>te!==h):[...A,h])}),A.length&&U.push({name:d("menu.expandAll"),action:()=>S.rows.expandAll()},{name:d("menu.collapseAll"),action:()=>S.rows.collapseAll()}),M(S.columns.groupColumns)){const te=j.groupPath||[],ee=te.length?te[te.length-1]:null,re=[{name:d("columngroup.group"),disabled:z.length<2||q<0,action:()=>{const se=z[q+1]??z[q-1];if(!se)return;const de=(S.columns.get(se)||{}).groupPath||[],ie=de.length?de[de.length-1]:null;ie?S.columns.groupColumns([h],{groupId:ie}):S.columns.groupColumns([h,se],{title:d("columngroup.newGroup")})}}];ee&&re.push({name:d("columngroup.dissolve"),action:()=>S.columns.dissolveGroup(ee)}),U.push({separator:!0},...re)}const Q=S.state&&M(S.state.get)?S.state.get().pivot:null,Y=Q&&Q.columns||[],J=Y.includes(h);if(j.allowPivot!==!1&&U.push({name:d(J?"menu.unpivot":"menu.pivotBy"),action:()=>S.columns.pivot(J?Y.filter(te=>te!==h):[...Y,h])}),j.allowTotal!==!1)if(M(S.get)&&S.get("aggregateChooser")===!0)U.push(n(S,j,d));else{const ee=!!j.total;U.push({name:d(ee?"menu.stopTotalling":"menu.totalColumn"),action:()=>S.columns.setTotal(h,ee?null:"sum")})}return U.push({name:d("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>S.columns.hide(h)}),U}function n(S,h,d){const j=h.id,E=typeof h.total=="string"?h.total:null,O=[{name:d("menu.aggregateNone"),checked:!h.total,action:()=>S.columns.setTotal(j,null)},{separator:!0},...v(h).map(T=>({name:k(T),checked:E===T,action:()=>S.columns.setTotal(j,T)})),{separator:!0},t(S,h,d,"group",d("menu.aggregateGroup")),t(S,h,d,"grand",d("menu.aggregateGrand"))];return{name:d("menu.aggregate"),children:O}}function t(S,h,d,j,E){const O=h.id,T=j==="grand"?h.grandTotal:h.groupTotal,A=typeof T=="string"?T:null,P=[{name:d("menu.aggregateSame"),checked:T==null,action:()=>S.columns.setTotal(O,null,{scope:j})},{separator:!0},...v(h).map(L=>({name:k(L),checked:A===L,action:()=>S.columns.setTotal(O,L,{scope:j})}))];return{name:E,children:P}}function i(S,h){const d=(A,P)=>(S&&S.messages?S.messages:H).t(A,P),j=S.columns.get(h);if(!j)return[];const E=S.redaction,O=!!(E&&E.has(h)),T=[];return E&&(T.push({name:d(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>E.toggle(h)}),(E.list().length>1||E.active&&!O)&&T.push({name:d("menu.stopRedactingAll"),action:()=>E.clear()}),T.push({separator:!0})),T.push({name:d("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>S.columns.hide(h)}),T}function a(S,h,d){const j=(P,L)=>(S&&S.messages?S.messages:H).t(P,L),E=d[0],O=S.sort.get(),T=E?O.find(P=>P.col===E):null,A=[];E&&A.push({name:j("menu.sortGroupsAscending"),icon:"↑",disabled:T&&T.dir==="asc",action:()=>S.sort.set([{col:E,dir:"asc"}])},{name:j("menu.sortGroupsDescending"),icon:"↓",disabled:T&&T.dir==="desc",action:()=>S.sort.set([{col:E,dir:"desc"}])},{separator:!0},{name:j("menu.filterGroups"),action:()=>S.emit("column:filter:open",{colId:h.id})},{separator:!0}),A.push({name:j("menu.expandAll"),action:()=>S.rows.expandAll()},{name:j("menu.collapseAll"),action:()=>S.rows.collapseAll()},{separator:!0});for(const P of d){const L=S.columns.get(P);A.push({name:`Remove "${L&&L.title||P}" from grouping`,action:()=>S.columns.group(d.filter($=>$!==P))})}return A.push({name:j("menu.clearGrouping"),disabled:!d.length,action:()=>S.columns.group([])}),A}function r(){const S=globalThis.navigator&&globalThis.navigator.clipboard;return!!(S&&typeof S.readText=="function")}function s(S){return M(S.get)&&S.get("edit")===!1?!1:(S.columns&&M(S.columns.visible)?S.columns.visible():[]).some(d=>{const j=d&&d.edit;return j?j.enabled===void 0||M(j.enabled)?!0:j.enabled!==!1:!1})}function u(S,h){if(M(S.get)&&S.get("edit")===!1)return!1;const d=h&&h.edit;return d?d.enabled===void 0||M(d.enabled)?!0:d.enabled!==!1:!1}const l=new Set(["number","currency","percent","integer"]);function p(S){const h=M(S.get)?S.get("rangeChart"):void 0;return h?M(h)?{enabled:!0,handler:h}:h&&typeof h=="object"&&M(h.onChart)?{enabled:!0,handler:h.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function m(S){const h=S.selection&&M(S.selection.ranges)?S.selection.ranges():[];if(!Array.isArray(h)||!h.length)return null;const d=h[h.length-1],j=M(S.columns.visible)?S.columns.visible():[],E=new Set(j.filter(O=>O&&l.has(O.type)).map(O=>O.id));return(d.columns||[]).some(O=>E.has(O))?d:null}function b(S,h){const d=(Y,J)=>(S&&S.messages?S.messages:H).t(Y,J),{colId:j,row:E}=h,O=S.selection.keys().length,T=S.selection.cells().length,A=(S.state&&M(S.state.get)?S.state.get().group:null)||[],P=S.ranges||null,L=W()?"Cmd":"Ctrl",$=()=>T||O||0,U=Y=>S.columns&&M(S.columns.get)?S.columns.get(Y):null,x=M(S.selection.cells)?S.selection.cells():[],F=[...new Set(x.map(Y=>Y&&Y.colId).filter(Boolean))];!F.length&&j&&F.push(j);const C=F.length?F.some(Y=>u(S,U(Y))):s(S),z=j?u(S,U(j)):!1,q=p(S),Q=q.enabled?m(S):null;return[{name:T>1?`Copy ${T} cells`:d("menu.copy"),shortcut:`${L}+C`,disabled:!$(),action:()=>P&&T?P.copy():S.export.clipboard({rows:O?"selected":"range"})},{name:d("menu.copyWithHeaders"),disabled:!$(),action:()=>S.export.clipboard({headers:!0,rows:O?"selected":"range"})},...j==null?[]:[{name:d("menu.paste"),shortcut:`${L}+V`,disabled:!P||!C||!r(),action:()=>P&&P.paste()},{separator:!0},{name:d("menu.clearCells",{count:T||1}),shortcut:"Delete",disabled:!P||!C||!T,action:()=>P&&P.clear()},{name:d("menu.fillDown"),shortcut:`${L}+D`,disabled:!P||!C||T<2,action:()=>P&&P.fillDown()}],...Q&&q.handler?[{name:"Chart selection",action:()=>q.handler(S,Q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>S.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>S.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>S.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,action:()=>S.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>S.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>S.export.print()},...S.importer&&M(S.importer.openFile)?[{name:d("menu.importCsv"),action:()=>S.importer.openFile()}]:[],{separator:!0},...A.length?[{name:d("menu.expandAll"),action:()=>S.rows.expandAll()},{name:d("menu.collapseAll"),action:()=>S.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>S.selection.clear()},...M(S.get)&&S.get("rowDelete")===!0?[{name:d("menu.deleteRow",{count:O||1}),disabled:!O&&!E,action:()=>S.edit.deleteRows(O?void 0:E?E.key:void 0)}]:[],...j==null?[]:[{name:"Edit cell",disabled:!E||!j||!z,action:()=>E&&j&&S.edit.start(E.key,j)}]]}function g(S,h,d,j){if(S==null)return{items:h,spoke:!1,suppress:!1};if(S===!1)return{items:h,spoke:!0,suppress:!0};if(S===!0)return{items:h,spoke:!0,suppress:!1};if(Array.isArray(S))return{items:[...h,...S],spoke:!0,suppress:!1};if(M(S)){const E=S(d,h);return{items:Array.isArray(E)?E:h,spoke:!0,suppress:!1}}return I(`menu-layer:${j}`,`${j} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof S}. Ignoring it.`),{items:h,spoke:!1,suppress:!1}}function f(S,h,d){let j=Array.isArray(S)?S:[],E=!1;for(const O of h){if(!O)continue;const T=g(O.layer,j,d,O.where);j=T.items,T.spoke&&(E=T.suppress)}return E?null:j}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(h){this.#n=h.grid,this.#e=h.cellMenu!==!1,this.#t=h.headerMenu!==!1,this.#i=M(h.items)?h.items:null,this.#s=M(h.headerItems)?h.headerItems:null,this.#r=new G({document:h.document,host:h.host,ctx:{grid:h.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",h=>{const d=String(h.colId),j=this.#c(d,o(this.#n,d));j.length&&this.#r.show({items:j,ctx:this.#u(d),anchor:h.element,placement:"below",returnFocus:h.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",h=>{const d=String(h.colId),j=this.#c(d,i(this.#n,d));j.length&&this.#r.show({items:j,ctx:this.#u(d),x:h.x,y:h.y,returnFocus:h.element})})),this.#o.push(this.#n.on("cell:contextmenu",h=>{const d=h.event;this.#e&&d&&M(d.preventDefault)&&d.preventDefault();const j=this.#l(h),E=b(this.#n,j),O=f(E,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(j.column),where:`column '${j.colId}' contextMenu`}],j);!O||!O.length||(!this.#e&&d&&M(d.preventDefault)&&d.preventDefault(),this.#r.show({items:O,ctx:j,x:d?d.clientX:void 0,y:d?d.clientY:void 0}))}))}#l(h){const d=this.#n.columns,j=h.column||(h.colId!=null&&d&&M(d.get)?d.get(h.colId):void 0),E=h.row,O=this.#n.rows,T=h.key!==void 0?h.key:E?E.key:void 0;return{key:T,colId:h.colId,value:h.value!==void 0||T===void 0||h.colId==null?h.value:O&&M(O.value)?O.value(T,h.colId):void 0,row:E,data:E?E.data:void 0,column:j,index:h.index!==void 0?h.index:h.rowIndex,grid:this.#n}}#a(h){if(!(!h||h.contextMenu===void 0||h.contextMenu===null))return h.contextMenu}#u(h){return{colId:h,column:this.#n.columns.get(h),grid:this.#n}}#c(h,d){return this.#s?f(d,[{layer:this.#s,where:"columnMenu"}],this.#u(h))||[]:d}destroy(){for(const h of this.#o)h();this.#o=[],this.#r.destroy()}}}),je("packages/dom/src/shortcutshelp.js",function(e,V){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return k}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/renderer/keyboard.js"),_=W.groupedShortcuts,H=W.SHORTCUT_IDS,G=V("packages/dom/src/platform.js").macLike,D="lat-shortcuts",v='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class k{#e;#t;#n=null;#r=null;#o=[];constructor(c){this.#e=c.grid,this.#t=c.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(c,o){const n=this.#e;return(n&&n.messages?n.messages:N).t(c,o)}#s(c){const o=H[c.combo];if(!o)return c.meaning;const n=`shortcut.${o}`,t=this.#i(n);return t===n?c.meaning:t}mount(){const c=this.#t.viewport?.root;if(!c||!M(c.addEventListener))return;const o=n=>{if(this.open||n.key!=="?")return;const t=n.target,i=t&&t.tagName;i==="INPUT"||i==="TEXTAREA"||t&&t.isContentEditable||(n.preventDefault(),n.stopPropagation(),this.show())};c.addEventListener("keydown",o,!0),this.#o.push(()=>c.removeEventListener("keydown",o,!0))}show(){const c=this.#l();if(!c)return;const o=c.ownerDocument;this.#r=o&&o.activeElement,c.style.display="",M(c.focus)&&c.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const c=this.#r;this.#r=null,c&&M(c.focus)&&c.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const c=this.#t.viewport?.overlays,o=c?.ownerDocument;if(!c||!o?.createElement)return null;const n=o.createElement("div");n.className=D,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("tabindex","-1");const t=`${D}-title`;n.setAttribute("aria-labelledby",t);const i=o.createElement("div");i.className=`${D}__head`;const a=o.createElement("h2");a.className=`${D}__title`,a.id=t,a.textContent=this.#i("shortcuts.title");const r=o.createElement("button");r.className=`${D}__close`,r.type="button",r.setAttribute("aria-label",this.#i("shortcuts.close")),r.textContent="×",i.appendChild(a),i.appendChild(r),n.appendChild(i);const s=o.createElement("div");s.className=`${D}__body`;for(const l of _())l.items.length&&s.appendChild(this.#a(o,l));n.appendChild(s);const u=o.createElement("p");return u.className=`${D}__hint`,u.textContent=this.#i("shortcuts.hint"),n.appendChild(u),c.appendChild(n),this.#n=n,this.#u(n,r),n}#a(c,o){const n=c.createElement("section");n.className=`${D}__group`;const t=c.createElement("h3");t.className=`${D}__group-title`,t.textContent=this.#i(o.messageKey),n.appendChild(t);const i=c.createElement("dl");i.className=`${D}__list`;const a=G();for(const r of o.items){const s=c.createElement("dt");s.className=`${D}__keys`,r.alternatives.forEach((l,p)=>{if(p>0){const m=c.createElement("span");m.className=`${D}__or`,m.textContent=this.#i("shortcuts.or"),s.appendChild(m)}l.forEach((m,b)=>{b>0&&s.appendChild(c.createTextNode("+"));const g=c.createElement("kbd");g.textContent=a&&m==="Ctrl"?this.#i("shortcuts.key.cmd"):m,s.appendChild(g)})});const u=c.createElement("dd");u.className=`${D}__meaning`,u.textContent=this.#s(r),i.appendChild(s),i.appendChild(u)}return n.appendChild(i),n}#u(c,o){const n=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.hide();return}if(i.key!=="Tab")return;const a=[...c.querySelectorAll(v)];if(!a.length){i.preventDefault();return}const r=a[0],s=a[a.length-1],u=c.ownerDocument.activeElement;i.shiftKey&&(u===r||u===c)?(i.preventDefault(),s.focus()):!i.shiftKey&&u===s&&(i.preventDefault(),r.focus())},t=i=>{i.preventDefault?.(),this.hide()};c.addEventListener("keydown",n),o.addEventListener("click",t),this.#o.push(()=>{c.removeEventListener("keydown",n),o.removeEventListener("click",t)})}destroy(){for(const c of this.#o)c();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),je("packages/dom/src/rowreorder.js",function(e,V){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return c}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/renderer.js").displayIndexOf,H="lat-rowdrag",B="lat-rowdrag-marker",G="lat-rowdrag-lifted",D=4,v=new Set;function k(o){if(!o)return null;const n=o===!0?{}:typeof o=="object"?o:null;return n?{send:n.send!==!1,receive:n.receive!==!1,mode:n.mode==="copy"?"copy":"move",group:typeof n.group=="string"?n.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 c{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=y(n.grid.get("rowReorder")),this.#o=k(n.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(n){if(!this.#o||!this.#o.receive)return!1;const t=n&&n.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(n,t){const i=this.#e;return(i&&i.messages?i.messages:N).t(n,t)}#c(n,t){const i=this.#t&&this.#t.announce;M(i)&&i.call(this.#t,n,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const n=this.#e.columns.visible().filter(t=>!t.generated);return n.length?n[0].id:null}paint(){if(!this.draggable)return;const n=this.#d(),t=this.#t.viewport?.root;if(!n||!t)return;const i=t.querySelectorAll(`.lat-cell[data-col="${n}"]`);for(const a of i){if(a.querySelector(`.${H}`))continue;const r=a.parentNode;if(r&&M(r.getAttribute)&&r.getAttribute("data-pinned"))continue;const s=this.#n.createElement("span");s.className=H,s.setAttribute("data-role","row-drag"),s.setAttribute("aria-hidden","true"),s.setAttribute("title",this.#u("a11y.reorder.grab")),s.textContent="⠿",a.insertBefore(s,a.firstChild||null)}}mount(){if(!this.active)return;v.add(this);const n=this.#t.viewport?.root;if(!n||!M(n.addEventListener))return;const t=u=>this.#h(u),i=u=>this.#f(u),a=()=>this.#m(),r=u=>this.#j(u);n.addEventListener("pointerdown",t),n.addEventListener("keydown",r);const s=this.#n.defaultView||this.#n;s.addEventListener?.("pointermove",i),s.addEventListener?.("pointerup",a),this.#a.push(()=>{n.removeEventListener("pointerdown",t),n.removeEventListener("keydown",r),s.removeEventListener?.("pointermove",i),s.removeEventListener?.("pointerup",a)})}#h(n){const t=n.target;if(!t||!M(t.closest)||!t.closest('[data-role="row-drag"]'))return;const i=t.closest(".lat-row"),a=i?_(i):-1;if(a<0)return;const r=this.#e.rows.get(a);if(!r)return;const s=this.#E();if(s&&!(this.#o&&this.#o.send)){this.#c(this.#u(s),{repeat:!0});return}n.preventDefault?.(),this.#i={key:r.key,from:a,at:a,x:n.clientX,y:n.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(n){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(n.clientX-t.x)+Math.abs(n.clientY-t.y)<D)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.#l&&this.#I(n.clientX,n.clientY);const i=this.#A(n.clientX,n.clientY);if(t.target=i,i!==this){this.#M(),i&&i.accepts(this)?(i.showDropTarget(n.clientX,n.clientY),t.hit=i.hitAt(n.clientX,n.clientY)):t.hit=null,this.#w(t,i),this.#b(t,i,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const a=this.#C(n.clientX,n.clientY);if(this.#w(t,i),a<0){this.#b(t,this,null,null);return}t.at=a,this.#D(a);const r=this.#e.rows.get(a);this.#b(t,this,a,r?r.key:null)}#m(){const n=this.#i;this.#i=null,this.#M(),this.#N();for(const a of v)a.hideDropTarget();if(!n||(this.#v(n),!n.armed))return;const t=n.target;if(this.#e.emit("rowDrag:ended",this.#g(n),"user"),t&&t!==this){this.#S(n,t);return}if(n.at===n.from)return;const i=this.#E();if(i){this.#c(this.#u(i),{repeat:!0});return}this.#O(n.key,n.at)}#p(n,t,i,a){const r=this.#e.rows.byKey(n.key);return{key:n.key,data:r?r.data:null,over:t?t.grid:null,at:i,overKey:a}}#g(n){const t=n.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(n,t,null,null),dropped:!1};const i=n.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(n,t,i.at,i.overKey),dropped:!0}}if(t===this){const i=this.#e.rows.get(n.at);return{...this.#p(n,this,n.at,i?i.key:null),dropped:n.at!==n.from&&this.#E()===null}}return{...this.#p(n,null,null,null),dropped:!1}}#w(n,t){if(n.over===t)return;const i=n.over;n.over=t,i&&(this.#v(n),this.#e.emit("rowDrag:left",this.#p(n,i,null,null),"user"))}#b(n,t,i,a){n.pending={over:t,at:i,overKey:a},n.frame===null&&(n.frame=this.#y(()=>{n.frame=null;const r=n.pending;n.pending=null,!(!r||this.#i!==n)&&this.#e.emit("rowDrag:moved",this.#p(n,r.over,r.at,r.overKey),"user")}))}#v(n){n.pending=null,n.frame!==null&&(n.frame(),n.frame=null)}#y(n){const t=this.#n.defaultView||globalThis;if(M(t.requestAnimationFrame)){const a=t.requestAnimationFrame(n);return()=>{M(t.cancelAnimationFrame)&&t.cancelAnimationFrame(a)}}const i=setTimeout(n,16);return()=>clearTimeout(i)}#S(n,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const i=this.#e.rows.byKey(n.key);if(!i)return;const a=this.#o.mode,r=n.key,s=n.hit||{at:t.grid.rows.count(),overKey:null};let u=null;const l=t.receive(i.data,s.at,{overKey:s.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(r),onCancel:m=>{u=m}}),p=m=>{if(m!==!0){const b=m===!1?"a11y.transfer.refused":u==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(b),{repeat:!0});return}a==="move"?(this.#e.rows.apply({remove:[r]}),this.#e.emit("row:sent",{key:r,data:i.data,mode:a})):this.#e.emit("row:copied",{key:r,data:i.data,mode:a}),this.#c(this.#u(a==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};l&&M(l.then)?l.then(p):p(l)}receive(n,t,i={}){const a=this.#e,r=n&&typeof n=="object"?{...n}:n,s=i.overKey??null,u=i.source||null,l=M(i.onCancel)?i.onCancel:null,p=()=>{const w=a.rows.totalCount(),S=a.rows.apply({add:[r],at:Math.max(0,t||0)}),h=a.rows.totalCount()>w;return h&&a.emit("row:received",{data:r,at:t,overKey:s,rejected:S?.rejected||[]}),h},m=()=>{if(s!==null){const w=a.rows.get(t);if(!w||w.key!==s)return!1}return!M(i.revalidate)||i.revalidate()},b=M(a.rendererHost)?a.rendererHost():null;if(!b||!M(b.gateBefore))return p();const g=l?a.on("rowReceive:cancelled",w=>l(w.reason)):null,f=b.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:r,at:t,overKey:s,source:u,origin:"user"},p,m);return g&&(f&&M(f.then)?f.then(g,g):g()),f}hitAt(n,t){const i=this.#C(n,t);if(i<0)return{at:this.#e.rows.count(),overKey:null};const a=this.#e.rows.get(i);return{at:i,overKey:a?a.key:null}}showDropTarget(n,t){const i=this.root;i&&M(i.setAttribute)&&i.setAttribute("data-drop-target","")}hideDropTarget(){const n=this.root;n&&M(n.removeAttribute)&&n.removeAttribute("data-drop-target")}#A(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,a=i&&M(i.closest)?i.closest(".lattice"):null;if(!a)return null;for(const r of v)if(r.root===a)return r;return null}#j(n){if(!n.altKey||!n.shiftKey)return;const t=n.key==="ArrowUp"?-1:n.key==="ArrowDown"?1:0;if(!t)return;const i=this.#n.activeElement,a=i&&M(i.closest)?i.closest(".lat-row"):null,r=a?_(a):-1;if(r<0)return;n.preventDefault?.(),n.stopPropagation?.();const s=this.#E();if(s){this.#c(this.#u(s),{repeat:!0});return}const u=this.#e.rows.get(r);u&&this.#O(u.key,r+t)}#O(n,t){const i=this.#e.rows.count(),a=Math.max(0,Math.min(i-1,t)),r=this.#e.rows.move(n,a);if(!r.moved){r.reason&&r.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${r.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:r.to+1,total:i}),{repeat:!0})}#E(){const n=this.#e;if(n.sort.get().length)return"a11y.reorder.sorted";if((n.state.get().group||[]).length)return"a11y.reorder.grouped";const t=n.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#C(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,a=i&&M(i.closest)?i.closest(".lat-row"):null;return!a||M(a.getAttribute)&&a.getAttribute("data-pinned")?-1:_(a)}#T(n){const t=this.root,i=t&&M(t.querySelector)?t.querySelector(`.lat-row[data-index="${n.from}"]`):null;i&&M(i.classList?.add)&&i.classList.add(G);const a=this.#n.body;if(!a||!M(a.appendChild))return;const r=this.#d(),s=r&&M(this.#e.rows?.text)&&this.#e.rows.text(n.key,r)||this.#u("a11y.reorder.grab"),u=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,l=(m,b)=>u&&u.getPropertyValue(m).trim()||b,p=this.#n.createElement("div");p.textContent=String(s),p.setAttribute("aria-hidden","true"),p.setAttribute("data-role","row-drag-ghost"),p.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${l("--lattice-space","4px")} calc(${l("--lattice-space","4px")} * 2)`,`border-radius:${l("--lattice-radius-sm",l("--lattice-radius","4px"))}`,`border:${l("--lattice-border-width","1px")} solid ${l("--lattice-border-strong","#0003")}`,`background:${l("--lattice-background","#fff")}`,`color:${l("--lattice-foreground","#000")}`,`box-shadow:${l("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${l("--lattice-font-size","13px")} ${l("--lattice-font-family","system-ui, sans-serif")}`].join(";"),a.appendChild(p),this.#l=p}#I(n,t){this.#l&&(this.#l.style.transform=`translate(${Math.round(n)+14}px, ${Math.round(t)+16}px)`)}#N(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const n=this.root,t=n&&M(n.querySelectorAll)?n.querySelectorAll(`.${G}`):[];for(const i of t)i.classList.remove(G)}#D(n){const t=this.#t.viewport?.overlays;if(!t)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=B,t.appendChild(this.#s));const i=this.#t.viewport.root,a=i.querySelector(`.lat-row[data-index="${n}"]`)||i.querySelectorAll(".lat-row")[0];if(!a||!M(a.getBoundingClientRect))return;const r=a.getBoundingClientRect(),s=i.getBoundingClientRect(),u=this.#i&&n>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((u?r.bottom:r.top)-s.top)}px`}#M(){this.#s&&(this.#s.style.display="none")}destroy(){v.delete(this);for(const n of this.#a)n();this.#a=[],this.#i&&this.#v(this.#i),this.#i=null,this.#N(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),je("packages/dom/src/alignedgrids.js",function(e,V){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isFunction,I=["column:resized","column:moved","column:visible","column:pinned"];function N(H){return(H||[]).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 G=[];for(const v of I)G.push(B.on(v,()=>this.#r(B)));G.push(B.on("scroll",v=>this.#i(B,v))),G.push(B.on("destroy",()=>this.remove(B))),this.#t.set(B,G);const[D]=this.#e;D!==B&&this.#o(B,N(D.columns.state()))}remove(B){const G=this.#t.get(B);if(G)for(const D of G)D();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 G=N(B.columns.state());this.#n=!0;try{for(const D of this.#e)D!==B&&this.#o(D,G)}finally{this.#n=!1}}#o(B,G){if(!B.columns||!M(B.columns.apply))return;const D=new Map((B.columns.state()||[]).map(k=>[k.id,k])),v=[];for(const k of G){const y=D.get(k.id);y&&(v.push({...y,...k}),D.delete(k.id))}for(const k of D.values())v.push(k);B.columns.apply(v)}#i(B,G){if(this.#n)return;const D=G&&typeof G.left=="number"?G.left:null;if(D!==null){this.#n=!0;try{for(const v of this.#e)v!==B&&v.scroll?.to?.({left:D})}finally{this.#n=!1}}}}function _(H){const B=new W;for(const G of H||[])B.add(G);return B}}),je("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 H}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function _(G){if(!G)return null;const D=G===!0?{}:typeof G=="object"?G:null;return D?{multiple:D.multiple===!0,label:typeof D.label=="string"?D.label:null}:null}class H{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(D){this.#e=D.grid,this.#t=D.renderer,this.#n=D.document,this.#r=_(D.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(D,v){const k=this.#e;return(k&&k.messages?k.messages:N).t(D,v)}mount(){if(!this.active)return;const D=this.#t.viewport,v=D?.root;if(!v||!M(v.insertBefore))return;const k=this.#n.createElement("div");k.className=W,k.setAttribute("role","toolbar"),k.setAttribute("aria-label",this.#a("tags.label"));const y=this.#n.createElement("label");y.className=`${W}__label`,y.textContent=this.#r.label||this.#a("tags.label");const c=this.#n.createElement("select");c.className=`${W}__select`,this.#r.multiple&&c.setAttribute("multiple","");const o=`${W}-select-${Math.abs(B(String(v.className)))}`;c.id=o,y.setAttribute("for",o),k.appendChild(y),k.appendChild(c),v.insertBefore(k,D.header||v.firstChild),this.#o=k,this.#i=c;const n=()=>{const i=this.#r.multiple?[...c.selectedOptions||[]].map(a=>a.value).filter(Boolean):c.value?[c.value]:[];this.#e.columns.showTagged(i),this.#u(i)};c.addEventListener("change",n),this.#l.push(()=>c.removeEventListener("change",n));const t=this.#e.on("model:changed",()=>this.refresh());this.#l.push(t),this.refresh()}#u(D){const v=this.#t&&this.#t.announce;if(!M(v))return;const k=D.length?D.join(", "):this.#a("tags.all");v.call(this.#t,this.#a("tags.showing",{tag:k}))}refresh(){if(!this.#i||!this.#o)return;const D=this.#e.columns.tags();if(this.#o.style.display=D.length?"":"none",!D.length)return;const v=D.join("\0");if(v===this.#s)return;this.#s=v;const k=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.#a("tags.all"),this.#i.appendChild(y)}for(const y of D){const c=this.#n.createElement("option");c.value=y,c.textContent=y,k.includes(y)&&(c.selected=!0),this.#i.appendChild(c)}this.#r.multiple||(this.#i.value=k.length?k[0]:"")}destroy(){for(const D of this.#l)D();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function B(G){let D=0;for(let v=0;v<G.length;v++)D=D*31+G.charCodeAt(v)|0;return D}}),je("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 G}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function _(D){if(!D)return null;const v=D===!0?{}:typeof D=="object"?D:null;return v?{column:typeof v.column=="string"?v.column:null,label:typeof v.label=="string"?v.label:null}:null}function H(D){return D?typeof D=="string"?{kind:D}:typeof D=="object"?D:null:null}function B(D,v){return D?Array.isArray(D.conditions)?D.conditions.some(k=>B(k,v)):D.col===v&&D.op==="eq"&&D.value===!0:!1}class G{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(v){this.#e=v.grid,this.#t=v.renderer,this.#n=v.document,this.#r=_(v.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(v,k){const y=this.#e;return(y&&y.messages?y.messages:N).t(v,k)}#f(){const v=this.#r&&this.#r.column;let k=null;for(const y of this.#e.columns.all()){const c=H(y.shadow);if(!c||c.kind!=="anomalyFlag")continue;const o=c.of||y.field||y.id;if(v){if(y.id===v||o===v)return this.#d=y.id,y}else k||(k=y,this.#d=y.id)}return v?null:k}#m(){if(!this.#d||!M(this.#e.rows&&this.#e.rows.forEach))return 0;let v=0;try{this.#e.rows.forEach(k=>{!k||k.group||k.key==null||this.#e.rows.value(k.key,this.#d)===!0&&v++})}catch{return 0}return v}mount(){if(!this.active)return;const v=this.#t.viewport,k=v&&v.root;if(!k||!M(k.insertBefore))return;const y=this.#n.createElement("div");y.className=W,y.setAttribute("role","status");const c=this.#n.createElement("button");c.className=`${W}__button`,c.setAttribute("type","button"),c.setAttribute("aria-pressed","false"),y.appendChild(c),k.insertBefore(y,v.header||k.firstChild),this.#o=y,this.#i=c;const o=()=>this.toggle();c.addEventListener("click",o),this.#s.push(()=>c.removeEventListener("click",o));for(const n of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(n,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const v={col:this.#d,op:"eq",value:!0},k=this.#u?{op:"and",conditions:[this.#u,v]}:v;this.#l=!0,this.#a=!0;try{this.#e.filters.set(k)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!B(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#w(this.#c,!0);return}const k=this.#m();if(this.#c=k,!k){this.#o.style.display="none";return}this.#w(k,!1)}#w(v,k){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",k?"true":"false"),this.#i.setAttribute("aria-pressed",k?"true":"false");const y=this.#r&&this.#r.label,c=k?this.#h("anomaly.chipActive",{count:v}):y||this.#h("anomaly.chip",{count:v});this.#i.textContent=c}destroy(){for(const v of this.#s)v();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),je("packages/dom/src/rowform.js",function(e,V){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return i}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/dom/src/editors/index.js").createEditor,G=V("packages/dom/src/renderer/renderer.js").displayIndexOf,v=V("packages/dom/src/themeof.js").themeOf,k="lat-rowform",y='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function c(a){if(!a)return null;const r=a===!0?{}:typeof a=="object"?a:null;if(!r)return null;const s=M(r.load)?r.load:null,u=Array.isArray(r.fields)&&r.fields.length?r.fields:null;return{timeout:t(r.timeout),container:r.container??null,mode:r.container?"inline":r.mode==="dialog"?"dialog":"drawer",load:s,fields:u,title:r.title??null,width:typeof r.width=="string"?r.width:null,trigger:r.trigger===!1?"none":"dblclick"}}function o(a,r){const s=M(a)?a():a;return s?typeof s=="string"?r&&M(r.querySelector)?r.querySelector(s):null:s&&M(s.appendChild)?s:null:null}const n=2e3;function t(a){return a===!1||a===0?0:typeof a!="number"||!Number.isFinite(a)||a<=0?n:a}class i{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=r.registry||null,this.#o=c(r.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(r,s){const u=this.#e;return(u&&u.messages?u.messages:W).t(r,s)}mount(){if(!this.active)return;const r=this.#t.viewport?.root;if(!r||!M(r.addEventListener)||this.#o.trigger==="none")return;const s=u=>{const l=u.target;if(!l||!M(l.closest)||l.closest(".lat-editor-host, .lat-editor--popup"))return;const p=l.closest(".lat-row"),m=p?G(p):-1;if(m<0)return;const b=this.#e.rows.get(m);!b||b.group||b.detail||(u.preventDefault?.(),u.stopPropagation?.(),this.openRow(b.key))};r.addEventListener("dblclick",s,!0),this.#m.push(()=>r.removeEventListener("dblclick",s,!0))}openRow(r){const s=this.#e.rows.byKey(r);if(!s)return!1;const u=this.#g();if(!u)return!1;this.#a=s,this.#c=this.#n.activeElement,u.style.display="",this.#C(u),this.#b(s);const l=this.#o.load;if(!l)this.#E(s.data);else{this.#A();const p=++this.#d;this.#v(p,r),Promise.resolve().then(()=>l({row:s,data:s.data,key:r,grid:this.#e})).then(m=>{p!==this.#d||!this.open||(this.#S(),this.#E(m||s.data))}).catch(m=>{p!==this.#d||!this.open||(this.#S(),this.#j(m,r))})}return M(u.focus)&&u.focus(),this.#e.emit("form:opened",{key:r,row:s}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#R(),this.#i.style.display="none";const r=this.#a?this.#a.key:null;this.#a=null;const s=this.#c;this.#c=null,s&&M(s.focus)&&s.focus(),this.#e.emit("form:closed",{key:r})}save(){if(!this.#a||!this.#u.length)return!1;const r=this.#a.key,s={},u={},l=[],p=[];for(const m of this.#u){const b=M(m.editor.commit)?m.editor.commit():{ok:!0,value:void 0};if(!b.ok)return this.#N(m,b.message),!1;s[m.field]=b.value;const g=m.initial;Object.is(g,b.value)||(u[m.field]=b.value,m.colId?l.push({key:r,colId:m.colId,value:b.value}):p.push(m.field))}return l.length&&this.#e.edit.setCells(l),this.#e.emit("form:saved",{key:r,values:s,changed:u,unmapped:p}),this.close(),!0}#g(){if(this.#i)return this.#i;const r=this.#t.viewport?.overlays,s=this.#n||r?.ownerDocument;if(!s?.createElement)return null;const u=o(this.#o.container,s),l=u||r;if(!l)return null;this.#o.container&&!u&&I("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!u;const p=s.createElement("div"),m=this.#f?"lattice ":"";p.className=`${m}${k} ${k}--${this.#f?"inline":this.#o.mode}`,p.setAttribute("role",this.#f?"region":"dialog"),this.#f||p.setAttribute("aria-modal","true"),p.setAttribute("tabindex","-1"),this.#o.width&&p.style.setProperty("--lattice-rowform-width",this.#o.width);const b=`${k}-title`;p.setAttribute("aria-labelledby",b);const g=s.createElement("div");g.className=`${k}__head`;const f=s.createElement("h2");f.className=`${k}__title`,f.id=b,g.appendChild(f);const w=s.createElement("div");w.className=`${k}__body`;const S=s.createElement("div");S.className=`${k}__foot`;const h=s.createElement("button");h.className=`${k}__cancel`,h.type="button",h.textContent=this.#p("form.cancel");const d=s.createElement("button");return d.className=`${k}__save`,d.type="button",d.textContent=this.#p("form.save"),S.appendChild(h),S.appendChild(d),p.appendChild(g),p.appendChild(w),p.appendChild(S),l.appendChild(p),this.#i=p,this.#s=w,this.#l=d,this.#w(p,d,h),p}#w(r,s,u){const l=b=>{if(b.stopPropagation(),b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab"||this.#f)return;const g=[...r.querySelectorAll(y)];if(!g.length){b.preventDefault();return}const f=g[0],w=g[g.length-1],S=r.ownerDocument.activeElement;b.shiftKey&&(S===f||S===r)?(b.preventDefault(),w.focus()):!b.shiftKey&&S===w&&(b.preventDefault(),f.focus())},p=b=>{b.preventDefault?.(),this.save()},m=b=>{b.preventDefault?.(),this.close()};r.addEventListener("keydown",l),s.addEventListener("click",p),u.addEventListener("click",m),this.#m.push(()=>{r.removeEventListener("keydown",l),s.removeEventListener("click",p),u.removeEventListener("click",m)})}#b(r){const s=this.#i.querySelector(`.${k}__title`);if(!s)return;const u=this.#o.title;M(u)?s.textContent=String(u({row:r,data:r.data})??""):typeof u=="string"?s.textContent=u:s.textContent=this.#p("form.title")}#v(r,s){this.#S();const u=this.#o.timeout;if(!u)return;const l=this.#n.defaultView||globalThis;M(l.setTimeout)&&(this.#h=l.setTimeout(()=>{this.#h=null,!(r!==this.#d||!this.open)&&(this.#d+=1,this.#j(new Error(`Loading the record timed out after ${u}ms`),s,"form.loadTimeout"))},u))}#y(r){this.#l&&(this.#l.disabled=!r,r?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const r=this.#n.defaultView||globalThis;M(r.clearTimeout)&&r.clearTimeout(this.#h),this.#h=null}#A(){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const r=this.#n.createElement("p");r.className=`${k}__note`,r.setAttribute("role","status"),r.textContent=this.#p("form.loading"),this.#s.appendChild(r)}#j(r,s,u="form.loadFailed"){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const l=this.#n.createElement("p");l.className=`${k}__note ${k}__note--error`,l.setAttribute("role","alert"),l.textContent=this.#p(u);const p=this.#n.createElement("button");p.className=`${k}__retry`,p.type="button",p.textContent=this.#p("form.retry"),p.addEventListener("click",()=>this.openRow(s)),this.#s.appendChild(l),this.#s.appendChild(p),this.#e.emit("form:error",{key:s,error:r,timedOut:u==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(r=>typeof r=="string"?{field:r}:r):this.#e.columns.all().filter(r=>!r.generated&&r.field).map(r=>({field:r.field,label:r.title,colId:r.id}))}#E(r){this.#R(),this.#y(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const s=r&&typeof r=="object"?r:{};for(const u of this.#O()){const l=u.field;if(!l)continue;const p=u.colId?this.#e.columns.get(u.colId):this.#W(l),m=this.#x(u,p,l),b=Object.hasOwn(s,l)?s[l]:null,g=this.#n.createElement("div");g.className=`${k}__field`;const f=this.#n.createElement("label");f.className=`${k}__label`,f.textContent=String(u.label??(p&&p.title)??l);const w=this.#n.createElement("div");w.className=`${k}__control`,g.appendChild(f),g.appendChild(w),this.#s.appendChild(g);const S={field:l,colId:p?p.id:null,editor:null,initial:b,opener:null,wrap:g},h=H({grid:this.#e,column:m,colId:p?p.id:l,row:this.#a,data:s,value:b,text:b==null?"":String(b),locale:this.#e.get("locale"),props:u.props||p&&p.edit&&p.edit.props,lookup:u.lookup||p&&p.lookup,document:this.#n,cell:w,overlay:this.#T(),stop:()=>this.#D(S)},this.#r);if(h){S.editor=h;try{M(h.value)&&(S.initial=h.value())}catch{}if(this.#u.push(S),h.popup===!0)this.#I(w,S);else{const d=M(h.element)?h.element():null;d&&w.appendChild(d)}}}}#C(r){if(!this.#f)return;const s=this.#t.viewport?.root;if(!(!s||!M(s.getAttribute)))for(const u of["data-theme","data-density","dir"]){const l=u==="data-theme"?v(s):s.getAttribute(u);l?r.setAttribute(u,l):M(r.removeAttribute)&&r.removeAttribute(u)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#I(r,s){const u=this.#n.createElement("button");u.className=`${k}__opener`,u.type="button",s.opener=u,this.#M(s);const l=()=>{M(s.editor.attached)&&s.editor.attached()};u.addEventListener("click",l),this.#m.push(()=>u.removeEventListener("click",l)),r.appendChild(u)}#N(r,s){const u=r.wrap;u&&M(u.scrollIntoView)&&u.scrollIntoView({block:"nearest"});const l=r.opener||(M(r.editor.focusTarget)?r.editor.focusTarget():null);l&&M(l.focus)&&l.focus();const p=this.#t&&this.#t.announce;M(p)&&s&&p.call(this.#t,String(s))}#D(r){if(!r.opener||!r.editor)return;const s=M(r.editor.popupHandle)?r.editor.popupHandle():null;s&&M(s.hide)&&s.hide(),this.#M(r),M(r.opener.focus)&&r.opener.focus()}#M(r){if(!r.opener)return;let s="";try{const l=r.colId?this.#e.columns.get(r.colId):null,p=l&&l.dataType&&l.dataType.format;M(p)&&(s=p({value:M(r.editor.value)?r.editor.value():null,column:l,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(s===""||s==null)&&M(r.editor.toClipboard)&&(s=r.editor.toClipboard())}catch{s=""}const u=s===""||s==null;r.opener.textContent=u?this.#p("form.choose"):String(s),r.opener.classList.toggle(`${k}__opener--empty`,u)}#x(r,s,u){const l=r.editor||r.type||r.lookup||r.props;if(s&&!l)return s;const p={...s&&s.edit?s.edit:{}};return r.editor&&(p.editor=r.editor),r.props&&(p.props=r.props),{...s||{id:u,field:u},type:r.type||s&&s.type||"text",lookup:r.lookup||s&&s.lookup||void 0,edit:p}}#W(r){for(const s of this.#e.columns.all())if(!s.generated&&s.field===r)return s;return null}#R(){for(const r of this.#u)M(r.editor.destroy)&&r.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#R();for(const r of this.#m)r();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),je("packages/dom/src/toolpanelmount.js",function(e,V){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return g}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,N=V("packages/dom/src/ui/toolpanel.js"),W=N.ToolPanel,_=N.toolPanels,H=N.toolPanelTitles,B=N.toolPanelIcons,D=V("packages/dom/src/filters/index.js").createFilter,v=V("packages/dom/src/editors/common.js"),k=v.CLS,y=v.documentFor,c=v.scannableRows,o=V("packages/dom/src/filtermenu.js"),n=o.mergeColumnFilter,t=o.branchFor,i=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 a(f){const{grid:w,container:S}=f||{};if(!w)throw new Error("[lattice] mountPanel needs a grid");if(!S||!S.appendChild)throw new Error("[lattice] mountPanel needs a container element");const h=M(f.panel)?f.panel:_[String(f.panel)];if(!h)throw new Error(`[lattice] unknown panel "${f.panel}"; known panels are ${Object.keys(_).join(", ")}`);const d=S.ownerDocument||y(S),j=b(w,d,f.announce),E=new h;E.init({document:d,host:j,grid:w,props:f.props||{}});const O=E.element();S.appendChild(O);const T=[];for(const A of i)M(w.on)&&T.push(w.on(A,()=>E.refresh()));return{element:O,refresh(){E.refresh()},destroy(){for(const A of T)A();T.length=0,M(E.destroy)&&E.destroy(),O&&O.parentNode&&O.parentNode.removeChild(O)}}}const r=260,s=30,u=`${k.panel}-dock`;function l(f,w,S){if(!f||!M(f.set))return;const h=t(S.filters.get(),w)||null,d=M(f.get)&&(!M(f.active)||f.active())&&f.get()||null;JSON.stringify(d)!==JSON.stringify(h)&&(h?f.set(h):M(f.clear)?f.clear():f.set(null))}function p(f,w){if(f==="insights"){const d=w&&M(w.get)?w.get("insights"):null;return{other:(d&&typeof d=="object"?d:{}).compareWith||null}}if(f!=="views")return{};const S=w&&M(w.get)?w.get("views"):null,h=S&&typeof S=="object"?S:{};return{allowSave:h.allowSave!==!1,showDiff:h.showDiff===!0,builtinTitle:h.builtinTitle,savedTitle:h.savedTitle}}function m(f){const w=f.pagination&&M(f.pagination.get)?f.pagination.get():null;return w&&Number.isFinite(w.total)?w.total:f.rows.count()}function b(f,w,S){const h=new Map;return{announce(d,j){M(S)&&S(d,j)},t(d,j){return f.messages.t(d,j)},grid:f,document:w,columns:()=>f.columns.all(),showColumns:d=>f.columns.show(d),hideColumns:d=>f.columns.hide(d),groupBy:()=>f.state.get().group||[],setGroupBy:d=>f.columns.group(d),pivotBy:()=>(f.state.get().pivot||{}).columns||[],setPivotBy:d=>f.columns.pivot(d),valueColumns:()=>f.columns.all().filter(d=>d.total).map(d=>d.id),setValueColumns:d=>f.columns.totals(d),valueAggregation(d){const j=f.columns.get(d);return!j||!j.total?"sum":typeof j.total=="string"?j.total:"custom"},setValueAggregation(d,j){f.columns.setTotal(d,j)},quickFilter:()=>f.state.get().quick||"",setQuickFilter:d=>f.filters.quick(d),rowCount:()=>m(f),totalRowCount:()=>M(f.rows.totalCount)?f.rows.totalCount():f.rows.count(),formattableColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id)})),formattingRules:d=>f.formatting.list(d),columnSamples:d=>{let j=d;if(!j||j==="*"){const T=f.columns.visible().find(A=>!A.generated);j=T?T.id:null}if(!j)return[];const E=[],O=new Set;for(const T of c(f)){const A=f.rows.value(T.key,j);if(A==null||A==="")continue;const P=typeof A=="object"?E.length:A;if(!O.has(P)&&(O.add(P),E.push(A),E.length>=24))break}return E},profilableColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id)})),columnProfile:d=>f.statistics.profile(d),reduceColumn:(d,j)=>f.statistics.reduce(d,j),columnCapability:d=>f.statistics.capability(d),regressionModel:d=>M(f.statistics.regressionModel)?f.statistics.regressionModel(d):null,insightsColumns:()=>f.columns.visible().filter(d=>!d.generated).map(d=>({id:d.id,title:String(d.title??d.id),type:d.type})),subsetVsPopulation:()=>f.statistics.subsetVsPopulation(),datasetVsDataset:d=>f.statistics.datasetVsDataset(d),compareGroups:(d,j)=>f.statistics.compareGroups(d,j),anomalies:d=>f.statistics.anomalies(d||{}),compareColumns:(d,j)=>{if(!d||!j||d===j)return null;const E=f.statistics.regression(d,j);return{n:E?E.n:0,pearson:f.statistics.correlation(d,j),spearman:f.statistics.spearman(d,j),kendall:f.statistics.kendall(d,j),covariance:f.statistics.covariance(d,j),slope:E?E.slope:null,intercept:E?E.intercept:null,r2:E?E.r2:null,stdError:E?E.stdError:null,weighted:f.statistics.weightedAverage(d,j)}},addRule:(d,j)=>f.formatting.add(d,j),removeRule:(d,j)=>f.formatting.remove(d,j),updateRule:(d,j,E)=>f.formatting.update(d,j,E),moveRule:(d,j,E)=>f.formatting.move(d,j,E),clearRules:d=>f.formatting.clear(d),views:()=>f.views.list(),activeId:()=>f.views.activeId,apply:d=>{f.views.apply(d)},saveAs:d=>f.views.save(d),rename:(d,j)=>f.views.rename(d,j),setDefault:d=>f.views.setDefault(d),clearDefault:()=>f.views.setDefault(null),remove:d=>f.views.remove(d),export:d=>f.views.export(d),diff:d=>f.views.diff(d),moveColumn(d,j,E){const O=f.columns.all().map(L=>L.id),T=O.indexOf(d),A=O.indexOf(j);if(T<0||A<0)return;let P=E?A:A+1;T<P&&(P-=1),P!==T&&f.columns.move(d,P)},isFiltered(d){return t(f.filters.get(),d)!==null},clearFilter(d){f.filters.set(n(f.filters.get(),d,null));const j=h.get(d);j&&M(j.clear)?j.clear():j&&M(j.set)&&j.set(null)},clearAllFilters(){f.filters.set(null);for(const d of h.values())M(d.clear)?d.clear():M(d.set)&&d.set(null)},filterFor(d){if(h.has(d))return l(h.get(d),d,f),h.get(d);const j=f.columns.get(d);if(!j)return null;const E=D({grid:f,column:j,colId:d,type:j.type,locale:f.get("locale"),props:{...j.filter&&j.filter.props,values:j.filter&&j.filter.props&&j.filter.props.values||(j.lookup?void 0:()=>f.columns.distinct(d))},lookup:j.lookup,document:w,value:O=>f.rows.value(O.row&&O.row.key,d),rows:j.lookup?void 0:()=>c(f),changed:()=>{const T=(M(E.active)?E.active():!0)&&M(E.get)?E.get():null;f.filters.set(n(f.filters.get(),d,T||null))}});return E&&(l(E,d,f),h.set(d,E)),E},destroyFilters(){for(const d of h.values())M(d.destroy)&&d.destroy();h.clear()}}}class g{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root,this.#o=b(w.grid,w.document,w.announce);const h=(w.panels||["columns","filters"]).map(d=>_[d]?{name:d,title:H[d]?w.grid.messages.t(H[d]):d,icon:B[d]||d,Ctor:_[d],props:p(d,w.grid)}:(I(`toolpanel:${d}`,`unknown tool panel "${d}"`),null)).filter(Boolean);this.#l=w.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:w.document,host:this.#o,grid:w.grid,panels:h,actions:w.actions,icons:w.icons,side:this.#l,openPanel:w.openPanel})}mount(){const w=this.#t.createElement("div");w.className=`${u} ${u}--${this.#l}`,w.appendChild(this.#r.element()),this.#n.appendChild(w),this.#i=w;const S=this.#r.show.bind(this.#r),h=this.#r.hide.bind(this.#r);this.#r.show=d=>{const j=S(d);return this.#f(),j},this.#r.hide=()=>{h(),this.#f()};for(const d of[...i,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(d,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",d=>{this.#u=!0;const j=d&&d.options&&Array.isArray(d.options.chrome)?d.options.chrome:[];this.#c=j.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",d=>{const j=d&&d.colId,E=this.#r.panels.find(O=>O.name==="statistics");E&&j!=null&&(E.panel.column=String(j)),this.open("statistics")})),this.#f()}open(w){this.#r.show(w),this.#f()}close(){this.#r.hide(),this.#f()}toggle(w){this.#r.toggle(w),this.#f()}addAction(w){if(!(!w||!w.name)&&!this.#r.actions.some(S=>S.name===w.name)){if(this.#r.registerAction(w),this.#a&&!w.annotation){const S=this.#r.actions.find(h=>h.name===w.name);S&&this.#h(S.button)}else!this.#a&&w.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(w){this.#r.removeAction(w)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(w=>w.annotation&&w.button)?(this.#d(),!0):!1}#d(){const w=this.#r;this.#a={hidden:[],reopen:w.openPanel||null},this.#a.reopen&&w.hide(),this.#h(w.body);for(const S of[...w.tabs?.children||[]])S!==w.actionGroup&&this.#h(S);for(const S of[...w.actionGroup?.children||[]]){const h=w.actions.find(d=>d.button===S);(!h||!h.annotation)&&this.#h(S)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const w=this.#a;if(!w)return!1;this.#a=null;for(const S of w.hidden)S.el&&S.el.style&&(S.el.style.display=S.display);return w.reopen&&this.#r.show(w.reopen),this.#f(),!0}#h(w){if(!w||!w.style||!this.#a)return;const S=w.style.display||"";S!=="none"&&(w.style.display="none",this.#a.hidden.push({el:w,display:S}))}#f(){if(!this.#i)return;const w=!!this.#r.openPanel;this.#i.setAttribute("data-open",w?"true":"false"),this.#i.style.width=w?`${r}px`:"";const S=`${w?r:this.#m()}px`;this.#n.style.paddingLeft=this.#l==="left"?S:"",this.#n.style.paddingRight=this.#l==="left"?"":S,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?S:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":S)}#m(){const w=this.#r&&M(this.#r.element)?this.#r.element().querySelector?.(`.${k.panel}__tabs`):null,S=w&&(w.offsetWidth||w.getBoundingClientRect?.().width)||0;return S>0?Math.ceil(S):s}destroy(){for(const w of this.#s)w();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),je("packages/dom/src/celledit.js",function(e,V){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return k}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,_=V("packages/dom/src/editors/common.js"),H=_.CLS,B=_.markInvalid,D=V("packages/dom/src/detailhost.js").insideDetail,v=`${H.editor}-host`;class k{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-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",l=>this.open(l))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,i=this.#e.get("edit"),a=i&&typeof i=="object"&&i.start||"double",r=l=>{if(D(l.target,t))return;const p=y(l.target,w=>w.getAttribute&&w.getAttribute("data-col"));if(!p)return;const m=y(p,w=>w.getAttribute&&w.getAttribute("data-key"));if(!m)return;const b=this.#e.rows.byKey(m.getAttribute("data-key"));if(!b||b.group)return;const g=p.getAttribute("data-col"),f=this.#e.columns.get(g);!f||!f.edit||!f.edit.enabled||this.#e.edit.start(b.key,g)},s=a==="key"?null:a==="single"?"click":"dblclick";s&&(t.addEventListener(s,r),this.#u.push(()=>t.removeEventListener(s,r)));const u=l=>{!this.#i||!this.#l||this.#m(l.target)||this.commit()};this.#t.addEventListener("mousedown",u,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",u,!0))}get target(){return this.#l}open(t){this.close();const i=t.key||t.row&&t.row.key,a=t.colId;if(!i||!a)return;const r=this.#e.columns.get(a),s=this.#e.rows.byKey(i);if(!r||!s)return;const u=this.#b(i,a);if(this.#c=u,!u){I("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const l=this.#e.permissions,p=!!(l&&M(l.isSecret)&&l.isSecret(a)),m=W({grid:this.#e,column:r,colId:a,row:s,data:s.data,value:p?null:this.#e.rows.value(i,a),text:p?"":this.#e.rows.text(i,a),locale:this.#e.get("locale"),props:r.edit&&r.edit.props,lookup:r.lookup,document:this.#t,cell:u,overlay:this.#n.viewport.overlays,onCommit:f=>this.#f({value:f,key:i,colId:a}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:f=>{this.#d||this.#e.edit.stop(f)}},this.#r);if(!m){I(`celledit.noeditor:${a}`,`column "${a}" has no editor.`);return}this.#i=m,this.#s=u,this.#l={key:i,colId:a},this.#d=!1,this.#a=this.#w(u);const b=m.element();m.popup?(this.#n.viewport.overlays.appendChild(b),c(b,u,this.#n.viewport.root)):u.replaceChildren(b),u.classList.add(v),M(m.attached)&&m.attached(),o(b);const g=f=>this.#h(f);b.addEventListener("keydown",g),this.#u.push(()=>b.removeEventListener("keydown",g))}#h(t){const i=t.key;if(i!=="Enter"&&i!=="Tab"&&i!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),i==="Escape"){this.#e.edit.stop(!0);return}const a=i==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&a&&this.#e.edit.start(a.key,a.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(M(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:i}=this.#l;if(M(this.#i.value)){const a=this.#i.value();if(M(this.#i.validate)){const r=this.#i.validate(a);if(r!==!0){if(B(this.#c,r),M(this.#i.focusTarget)){const s=this.#i.focusTarget();s&&M(s.focus)&&s.focus()}return!1}B(this.#c,null)}this.#f({value:a,key:t,colId:i})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const i=M(this.#i.element)?this.#i.element():null;if(i&&M(i.contains)&&i.contains(t))return!0;const a=this.#c;return!!(a&&M(a.contains)&&a.contains(t))}#p(t){if(!this.#l||this.#a<0)return null;for(let i=this.#a+t;i>=0&&i<this.#e.rows.count();i+=t){const a=this.#e.rows.get(i);if(a&&!a.group)return{key:a.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const i=this.#e.columns.visible(),a=i.findIndex(r=>r.id===this.#l.colId);for(let r=a+t;r>=0&&r<i.length;r+=t){const s=i[r];if(s.edit&&s.edit.enabled)return{key:this.#l.key,colId:s.id}}return null}#w(t){const i=y(t,r=>r.getAttribute&&r.getAttribute("data-index"));if(!i)return-1;const a=Number(i.getAttribute("data-index"));return Number.isFinite(a)?a:-1}#b(t,i){const a=this.#n.viewport.root;if(!a||!a.querySelectorAll)return null;for(const r of a.querySelectorAll(`[data-col="${i}"]`)){const s=y(r,u=>u.getAttribute&&u.getAttribute("data-key"));if(s&&s.getAttribute("data-key")===t)return r}return null}close(){this.#c&&B(this.#c,null);const t=this.#v();if(this.#i&&M(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(v),this.#o&&M(this.#o.releaseCell)){const i=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,i)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#y(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#v(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const i=this.#i&&M(this.#i.element)?this.#i.element():null,a=r=>!!r&&M(r.contains)&&r.contains(t);return a(i)||a(this.#s)}#y(t){const a=M(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;a&&M(a.focus)&&a.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function y(n,t){let i=n;for(;i;){if(t(i))return i;i=i.parentNode}return null}function c(n,t,i){if(!M(t.getBoundingClientRect))return;const a=t.getBoundingClientRect(),r=i.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(a.top-r.top)}px`,n.style.minWidth=`${Math.round(a.width)}px`,n.style.left=`${Math.round(a.left-r.left)}px`;const s=n.offsetWidth||Math.round(a.width),u=Math.round(a.left-r.left)+s-Math.round(r.width);u>0&&(n.style.left=`${Math.max(0,Math.round(a.left-r.left)-u)}px`)}function o(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;M(t.focus)&&t.focus(),M(t.select)&&t.select()}}),je("packages/dom/src/editbar.js",function(e,V){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return G}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,B=`${V("packages/dom/src/editors/common.js").CLS.editor}-bar`;class G{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(v){this.#e=v.grid,this.#t=v.document,this.#n=v.root}mount(){const v=this.#t,k=v.createElement("div");k.className=B;const y=v.createElement("span");y.className=`${B}__ref`,y.textContent="";const c=v.createElement("div");c.className=`${B}__slot`;const o=v.createElement("span");o.className=`${B}__readonly`,k.appendChild(y),k.appendChild(c),this.#n.insertBefore(k,this.#n.firstChild),this.#r=k,this.#o=y,this.#i=c,this.#l=o;for(const n of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(n,t=>this.#f(t)))}bind(v,k){const y=this.#e.columns.get(k),c=v?this.#e.rows.byKey(v):null;this.#a=c&&y&&!c.group?{key:v,colId:k}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:v,colId:k}=this.#a,y=this.#e.columns.get(k);if(!y)return;if(this.#o.textContent=y.title||k,!!!(y.edit&&y.edit.enabled)){this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l);return}const o=this.#e.rows.byKey(v);if(!o)return;const n=W({grid:this.#e,column:y,colId:k,row:o,data:o.data,value:this.#e.rows.value(v,k),text:this.#e.rows.text(v,k),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:s=>s?this.cancel():this.commit(!0)});if(!n){I(`editbar.noeditor:${k}`,`column "${k}" has no editor.`),this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l);return}this.#s=n;const t=n.element();n.popup?(this.#l.textContent=this.#e.rows.text(v,k),this.#i.appendChild(this.#l)):this.#i.appendChild(t),M(n.attached)&&n.attached();const i=s=>this.#m(s),a=()=>{this.#u=!0},r=[t,this.#i];for(const s of r)s.addEventListener("keydown",i),s.addEventListener("input",a),s.addEventListener("change",a);this.#c=()=>{for(const s of r)s.removeEventListener("keydown",i),s.removeEventListener("input",a),s.removeEventListener("change",a)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&M(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(v){if(v&&v.colId&&(v.key||v.row&&v.row.key)){this.bind(v.key||v.row.key,v.colId);return}this.refresh()}#m(v){if(v.key==="Enter"){v.preventDefault(),this.commit();return}v.key==="Escape"&&(v.preventDefault(),this.cancel())}commit(v){if(!this.#a||!this.#u&&!v)return!1;const{key:k,colId:y}=this.#a;if(!this.#s||!M(this.#s.value))return!1;const c=this.#s.value();return this.#u=!1,this.#e.edit.start(k,y),this.#e.edit.stop(!1,{value:c,key:k,colId:y}),this.refresh(),!0}destroy(){this.#h();for(const v of this.#d)v();this.#d=[],this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),je("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 D}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,H=W.clear,B="lat-pastepreview",G='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class D{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(k,y){const c=this.#e;return(c&&c.messages?c.messages:N).t(k,y)}#d(k){const y=`paste.preview.reason.${k}`,c=this.#c(y);return c===y?k:c}#h(k){return k==null||k===""?"":String(k)}#f(k,y){const c=this.#e.columns&&M(this.#e.columns.get)?this.#e.columns.get(y):null;return`${c&&(c.title||c.headerName)||y} · ${k}`}show(k,y){const c=this.#b();if(!c)return!1;this.#l=y&&y.onConfirm,this.#a=y&&y.onCancel||null;const o=k&&k.changes||[],n=k&&k.rejected||[],t=o.filter(a=>a.changed);this.#m(t,n);const i=c.ownerDocument;return this.#s=i&&i.activeElement,c.style.display="",M(c.focus)&&c.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:n.length}),{repeat:!0}),!0}#m(k,y){const c=this.#r.ownerDocument;H(this.#r);const o=_(c,"p",{class:`${B}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:k.length,changes:k.length,rejected:y.length})});if(this.#r.appendChild(o),!k.length&&!y.length){this.#r.appendChild(_(c,"p",{class:`${B}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!k.length;return}this.#o.disabled=!k.length,k.length&&(this.#r.appendChild(_(c,"h3",{class:`${B}__heading`,text:this.#c("paste.preview.changesHeading",{count:k.length})})),this.#r.appendChild(this.#p(c,k))),y.length&&(this.#r.appendChild(_(c,"h3",{class:`${B}__heading ${B}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(c,y)))}#p(k,y){const c=_(k,"tr",{children:[_(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),_(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),_(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),o=y.map(n=>_(k,"tr",{children:[_(k,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),_(k,"td",{class:`${B}__old`,text:this.#h(n.oldValue)}),_(k,"td",{class:`${B}__new`,text:this.#h(n.newValue)})]}));return _(k,"table",{class:`${B}__table`,children:[_(k,"thead",{children:[c]}),_(k,"tbody",{children:o})]})}#g(k,y){const c=_(k,"tr",{children:[_(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),_(k,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),o=y.map(n=>_(k,"tr",{children:[_(k,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),_(k,"td",{class:`${B}__reason`,text:this.#d(n.reason)})]}));return _(k,"table",{class:`${B}__table ${B}__table--rejected`,children:[_(k,"thead",{children:[c]}),_(k,"tbody",{children:o})]})}confirm(){const k=this.#l;this.#w(),M(k)&&k()}cancel(){const k=this.#a;this.#w(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),M(k)&&k()}#w(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const k=this.#s;this.#s=null,k&&M(k.focus)&&k.focus()}#b(){if(this.#n)return this.#n;const k=this.#t.viewport&&this.#t.viewport.overlays,y=k&&k.ownerDocument;if(!k||!y||!M(y.createElement))return null;const c=`${B}-title`,o=_(y,"h2",{class:`${B}__title`,attrs:{id:c},text:this.#c("paste.preview.title")}),n=_(y,"div",{class:`${B}__body`}),t=_(y,"button",{class:`${B}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),i=_(y,"button",{class:`${B}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),a=_(y,"div",{class:`${B}__foot`,children:[i,t]}),r=_(y,"div",{class:B,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":c},children:[_(y,"div",{class:`${B}__head`,children:[o]}),n,a]});return k.appendChild(r),this.#n=r,this.#r=n,this.#o=t,this.#i=i,this.#v(r,t,i),r}#v(k,y,c){const o=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.cancel();return}if(i.key!=="Tab")return;const a=[...k.querySelectorAll(G)].filter(l=>!l.disabled);if(!a.length){i.preventDefault();return}const r=a[0],s=a[a.length-1],u=k.ownerDocument.activeElement;i.shiftKey&&(u===r||u===k)?(i.preventDefault(),s.focus()):!i.shiftKey&&u===s&&(i.preventDefault(),r.focus())},n=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.confirm()},t=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.cancel()};k.addEventListener("keydown",o),y.addEventListener("click",n),c.addEventListener("click",t),this.#u.push(()=>{k.removeEventListener("keydown",o),y.removeEventListener("click",n),c.removeEventListener("click",t)})}#y(k,y){const c=this.#t&&this.#t.announce;M(c)&&c.call(this.#t,k,y)}destroy(){for(const k of this.#u)k();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),je("packages/dom/src/rangeselect.js",function(e,V){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/model/selection.js"),_=W.extendSeries,H=W.resolveSelectionConfig,B=V("packages/dom/src/renderer/textentry.js"),G=B.isTextEntry,D=B.isFindBarControl,k=V("packages/dom/src/pastepreview.js").PastePreview,y=V("packages/dom/src/columnmenu.js"),c=y.chartableRange,o=y.rangeChartConfig,n="lat-cell--range",t="lat-cell--range-edge",i=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),a=3;class r{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document,this.#a=l.preview||null}mount(){const l=this.#t.viewport.root,p=f=>this.#c(f),m=f=>this.#d(f),b=()=>this.#h(),g=f=>this.#f(f);l.addEventListener("pointerdown",p),this.#n.addEventListener("pointermove",m),this.#n.addEventListener("pointerup",b),l.addEventListener("keydown",g),this.#o.push(()=>{l.removeEventListener("pointerdown",p),this.#n.removeEventListener("pointermove",m),this.#n.removeEventListener("pointerup",b),l.removeEventListener("keydown",g)});for(const f of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(f,()=>this.paint()));this.paint()}#c(l){if(l.button!==0)return;const p=l.target;if(!p||!M(p.closest))return;if(this.#r=!1,p.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:l.clientX,fromY:l.clientY,armed:!0};return}if(p.closest('[data-role="row-drag"]'))return;const m=this.#R(p);if(!m)return;if(l.shiftKey&&this.#e.selection.corner()){const g=this.#C(m);this.#e.selection.extendRange(g.rowIndex,g.colId),this.#i={mode:"select",fromX:l.clientX,fromY:l.clientY,armed:!0};return}const b=this.#E(m);this.#u=b,this.#e.selection.startRange(b.rowIndex,b.colId,{additive:l.ctrlKey||l.metaKey}),this.#i={mode:"select",fromX:l.clientX,fromY:l.clientY,armed:!1}}#d(l){const p=this.#i;if(!p)return;if(!p.armed){if(Math.abs(l.clientX-p.fromX)+Math.abs(l.clientY-p.fromY)<a)return;p.armed=!0}const m=this.#_(l.clientX,l.clientY);if(!m)return;if(p.mode==="fill"){this.#l=m,this.paint();return}const b=this.#C(m);this.#e.selection.extendRange(b.rowIndex,b.colId)}#h(){const l=this.#i;if(this.#i=null,!!l){if(l.mode==="fill"&&this.#l){const p=this.#l;this.#l=null,this.fillTo(p.rowIndex)}this.#l=null,this.paint()}}#f(l){if(this.#D()||D(l.target)||G(l.target))return;const p=l.ctrlKey||l.metaKey,m=l.key;if(p&&(m==="c"||m==="C")){this.copy(),l.preventDefault();return}if(p&&(m==="v"||m==="V")){this.paste(),l.preventDefault();return}if(p&&(m==="d"||m==="D")){this.fillDown(),l.preventDefault();return}if(m==="Delete"||m==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),l.preventDefault();return}this.clear(),l.preventDefault();return}if(l.altKey&&m==="F1"){this.chartSelection()&&l.preventDefault();return}if(!l.shiftKey)return;const b={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[m];if(!b)return;if(p){const O=this.#W();if(!O)return;if(!this.#r){const $=this.#E(O);this.#u=$,this.#e.selection.startRange($.rowIndex,$.colId,{additive:!0}),this.#r=!0}const T=this.#e.columns.visible().map($=>$.id),A=T.indexOf(O.colId),P=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},L=this.#C({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+b[0])),colId:T[Math.min(T.length-1,Math.max(0,(A<0?0:A)+b[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),l.preventDefault();return}this.#r=!1;const g=this.#e.selection.corner(),f=this.#W(),w=g||f;if(!w)return;if(!g&&f){const O=this.#E(f);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const S=this.#e.columns.visible().map(O=>O.id),h=S.indexOf(w.colId??w.colId),d=S[Math.min(S.length-1,Math.max(0,h+b[1]))],j=Math.min(this.#e.rows.count()-1,Math.max(0,(g?g.row:f.rowIndex)+b[0])),E=this.#C({rowIndex:j,colId:d});this.#e.selection.extendRange(E.rowIndex,E.colId),l.preventDefault()}async copy(){const l=this.#e.export.rangeText();if(!l)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const p=globalThis.navigator&&globalThis.navigator.clipboard;if(!p||!M(p.writeText))return!1;try{return await p.writeText(l),this.#e.emit("clipboard:copy",{text:l,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:l,ok:!1,rows:"range"},"user"),!1}}async paste(){const l=globalThis.navigator&&globalThis.navigator.clipboard;if(!l||!M(l.readText))return 0;let p="";try{p=await l.readText()}catch{return 0}return this.pasteText(p)}pasteText(l){if(!l)return 0;const p=this.#e.selection.cells(),m=p.length?p[0]:this.#v();if(!m)return 0;const b=p.length>1?{rows:new Set(p.map(g=>g.key)).size,columns:new Set(p.map(g=>g.colId)).size}:void 0;if(this.#m()){const g=this.#e.edit.previewPaste(m,l,b);if(g.changes.length+g.rejected.length>1)return this.#p().show(g,{onConfirm:()=>this.#g(m,l,b)}),0}return this.#g(m,l,b)}#m(){const l=this.#e.edit;return!!(l&&l.pastePreview&&M(l.previewPaste))}#p(){return this.#a||(this.#a=new k({grid:this.#e,renderer:this.#t})),this.#a}#g(l,p,m){const b=this.#e.edit.pasteInto(l,p,m);return this.#b(b?this.#w("a11y.range.written",{count:b}):this.#w("a11y.range.refused"),{repeat:!0}),b}#w(l,p){const m=this.#e;return(m&&m.messages?m.messages:N).t(l,p)}#b(l,p){const m=this.#t&&this.#t.announce;M(m)&&m.call(this.#t,l,p)}#v(){const l=this.#W();if(!l)return null;const p=this.#e.rows.get(l.rowIndex);return p?{key:p.key,colId:l.colId}:null}clear(){const l=this.#e.selection.cells();return l.length?this.#e.edit.setCells(l.map(p=>({...p,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const l=this.#e.selection.cells();if(l.length<2)return 0;const p=[...new Set(l.map(g=>g.key))];if(p.length<2)return 0;const m=p[0],b=[];for(const{key:g,colId:f}of l)g!==m&&b.push({key:g,colId:f,value:this.#e.rows.value(m,f)});return this.#e.edit.setCells(b)}chartSelection(){const l=o(this.#e);if(!l.handler)return!1;const p=c(this.#e);return p?(l.handler(this.#e,p),!0):!1}fillTo(l){if(this.#e.selection.ranges().length>1)return 0;const p=this.#e.selection.cells();if(!p.length)return 0;const m=[...new Set(p.map(d=>d.key))],b=[...new Set(p.map(d=>d.colId))],g=this.#x(m[m.length-1]);if(g<0||l<=g)return 0;const f=[];for(let d=g+1;d<=l;d++){const j=this.#e.rows.get(d);if(!j)break;f.push(j)}if(!f.length)return 0;const w=[];for(const d of b){const j=m.map(O=>this.#e.rows.value(O,d)),E=this.#y(j,f,d);for(let O=0;O<f.length;O++)w.push({key:f[O].key,colId:d,value:E[O]})}const S=this.#e.edit.setCells(w),h=this.#e.selection.corner();return h&&this.#e.selection.extendRange(l,h.colId),S}#y(l,p,m){const b=this.#e.get("selection"),g=b&&typeof b=="object"?b.fill:void 0;if(M(g)){const f=this.#e.columns.get(m),w=p.map(h=>({row:h,column:f})),S=g({source:l,target:w,direction:"down"});if(Array.isArray(S)&&S.length===p.length)return S}return _(l,p.length)}paint(){const l=this.#t.viewport.root;if(!l||!l.querySelectorAll)return;const p=this.#e.selection,m=p.ranges().length>0,b=this.#l;for(const g of l.querySelectorAll("[data-col]")){const f=g.getAttribute("data-col"),w=g.parentNode,S=g.getAttribute?g.getAttribute("data-index"):null,h=S!==null&&S!==""?S:w&&w.getAttribute?w.getAttribute("data-index"):null;if(h===null||h==="")continue;const d=Number(h);if(!Number.isFinite(d)||d<0)continue;const j=m&&p.inRange(d,f),E=!!b&&this.#S(d,f,b);g.classList.toggle(n,j||E);const O=j||E?this.#A(d,f,p):null;g.classList.toggle(t,!!O&&O.any);for(const[T,A]of Object.entries(i))g.classList.toggle(A,!!O&&O[T])}this.#j()}#S(l,p,m){const b=this.#e.selection.cells();if(!b.length||!new Set(b.map(w=>w.colId)).has(p))return!1;const f=this.#x([...new Set(b.map(w=>w.key))].pop());return l>f&&l<=m.rowIndex}#A(l,p,m){const b=this.#e.columns.visible().map(h=>h.id),g=b.indexOf(p),f=g>0?b[g-1]:null,w=g>=0&&g<b.length-1?b[g+1]:null,S={top:!m.inRange(l-1,p),bottom:!m.inRange(l+1,p),left:!f||!m.inRange(l,f),right:!w||!m.inRange(l,w)};return S.any=S.top||S.bottom||S.left||S.right,S}#j(){const l=this.#e.selection.corner(),p=this.#t.viewport.overlays;if(!p)return;if(!l||this.#N()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#s&&(this.#s.style.display="none");return}const m=this.#B(l.row,l.colId);if(!m||!M(m.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#w("a11y.fillHandle")),p.appendChild(this.#s));const b=m.getBoundingClientRect(),g=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?b.left:b.right;this.#s.style.left=`${Math.round(w-g.left)-4}px`,this.#s.style.top=`${Math.round(b.bottom-g.top)-4}px`}#O(l){const p=this.#t;return!l||typeof p.spanAt!="function"?null:p.spanAt(l.rowIndex,l.colId)}#E(l){const p=this.#O(l);return p?{rowIndex:p.row,colId:p.columnId}:l}#C(l){const p=this.#O(l);if(!p)return l;const m=this.#u,b=!!m&&m.rowIndex>=p.row+p.rows,g=this.#I(),f=m?g.indexOf(m.colId):-1,w=f>=0&&f>=p.col+p.cols;return{rowIndex:b?p.row:p.row+p.rows-1,colId:w?p.columnId:p.endColumnId}}#T(){const l=this.#e.selection.corner();if(!l)return!1;const p=this.#O({rowIndex:l.row,colId:l.colId});return!!p&&(p.rows>1||p.cols>1)}#I(){const l=this.#e.columns;return l&&M(l.visible)?l.visible().map(p=>p.id):[]}#N(){return H(this.#e.get("selection")).fillHandle}#D(){const l=this.#t.viewport.root;return!!(l&&l.querySelector&&l.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const l=this.#e.selection.cells();return l.length?l[0]:null}#x(l){for(let p=0;p<this.#e.rows.count();p++){const m=this.#e.rows.get(p);if(m&&m.key===l)return p}return-1}#W(){const l=this.#t.viewport.root,p=l&&l.querySelector?l.querySelector('[data-col][tabindex="0"]'):null;return p?this.#R(p):null}#R(l){if(!l||!M(l.closest))return null;const p=l.closest("[data-col]");if(!p||!p.classList.contains("lat-cell"))return null;const m=p.closest("[data-index]");if(!m)return null;const b=Number(m.getAttribute("data-index"));return!Number.isFinite(b)||b<0?null:{rowIndex:b,colId:p.getAttribute("data-col")}}#_(l,p){const m=this.#n.elementFromPoint?this.#n.elementFromPoint(l,p):null;return m?this.#R(m):null}#B(l,p){const m=this.#t.viewport.root;if(!m||!m.querySelectorAll)return null;for(const b of m.querySelectorAll(`[data-col="${p}"]`)){const g=b.closest?b.closest("[data-index]"):null;if(g&&Number(g.getAttribute("data-index"))===l)return b}return null}destroy(){for(const l of this.#o)l();this.#o=[],this.#s&&M(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&M(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const s=r}),je("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 r}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/import/index.js"),_=W.parseDelimited,H=W.inferColumns,B=W.mapRecords,G=W.readXlsx,D=W.looksLikeXlsx,v=V("packages/dom/src/editors/common.js"),k=v.el,y=v.clear,c=v.on,n=V("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",i='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',a=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class r{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.document;const l=u.settings&&typeof u.settings=="object"?u.settings:{};this.#r={file:l.file!==!1,drop:l.drop!==!1,paste:l.paste!==!1,mode:l.mode==="replace"?"replace":"append"},this.#u()}#u(){const u=this.#t&&this.#t.viewport?this.#t.viewport.root:null;u&&(this.#r.drop&&(this.#o.push(c(u,"dragover",l=>{l.dataTransfer&&[...l.dataTransfer.types||[]].includes("Files")&&(l.preventDefault(),u.classList.add("lat-import--dropzone"))})),this.#o.push(c(u,"dragleave",()=>u.classList.remove("lat-import--dropzone"))),this.#o.push(c(u,"drop",l=>{u.classList.remove("lat-import--dropzone");const p=l.dataTransfer&&l.dataTransfer.files&&l.dataTransfer.files[0];p&&(l.preventDefault(),this.#c(p))}))),this.#r.paste&&this.#o.push(c(u,"paste",l=>{if(n(l.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const p=l.clipboardData&&l.clipboardData.getData("text/plain");!p||!p.includes(`
|
|
56
|
-
`)||(l.preventDefault(),this.fromText(p))})))}openFile(){const u=k(this.#n,"input",{attrs:{type:"file",accept:a}});u.style.display="none",this.#o.push(c(u,"change",()=>{const l=u.files&&u.files[0];l&&this.#c(l),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(M(u.arrayBuffer)){u.arrayBuffer().then(p=>{const m=new Uint8Array(p);if(D(m)){this.fromXlsx(m,u.name);return}this.fromText(new TextDecoder().decode(m),u.name)});return}if(M(u.text)){u.text().then(p=>this.fromText(p,u.name));return}const l=new this.#n.defaultView.FileReader;l.onload=()=>this.fromText(String(l.result||""),u.name),l.readAsText(u)}async fromXlsx(u,l){const{header:p,rows:m}=await G(u);if(!p.length)return;const b=H(p,m,{columns:this.#e.columns.all()}),g=m.filter(f=>f.length!==p.length).length;this.#l={rows:m,columns:b,delimiter:null,name:l,warnings:g?[`${g} row(s) do not have ${p.length} columns`]:[]},this.#d()}fromText(u,l){const{header:p,rows:m,delimiter:b}=_(u);if(!p.length)return;const g=H(p,m,{columns:this.#e.columns.all()}),f=m.filter(w=>w.length!==p.length).length;this.#l={rows:m,columns:g,delimiter:b,name:l,warnings:f?[`${f} row(s) do not have ${p.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(i);u&&M(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(u,l){const p=this.#t&&this.#t.announce;M(p)&&p.call(this.#t,u,l)}#f(u,l){return(this.#e&&this.#e.messages?this.#e.messages:N).t(u,l)}#m(){const u=this.#n,l=k(u,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),p=k(u,"div",{class:`${t}__panel`});p.appendChild(k(u,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#s=k(u,"div",{class:`${t}__body`}),p.appendChild(this.#s);const m=k(u,"div",{class:`${t}__footer`}),b=k(u,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),g=k(u,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(c(b,"click",()=>this.close())),this.#o.push(c(g,"click",()=>this.#g())),m.appendChild(b),m.appendChild(g),p.appendChild(m),l.appendChild(p),this.#o.push(c(l,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const S=[...l.querySelectorAll(i)].filter(j=>!j.hidden);if(!S.length)return;const h=S[0],d=S[S.length-1];w.shiftKey&&this.#n.activeElement===h?(w.preventDefault(),d.focus()):!w.shiftKey&&this.#n.activeElement===d&&(w.preventDefault(),h.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(l),this.#i=l}#p(){const u=this.#n,l=y(this.#s),{rows:p,columns:m,name:b,warnings:g}=this.#l;l.appendChild(k(u,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:p.length,name:b||this.#f("import.clipboard")})}));for(const j of g)l.appendChild(k(u,"p",{class:`${t}__warning`,text:j}));const f=this.#e.columns.all().map(j=>j.field||j.id).filter(Boolean),w=k(u,"table",{class:`${t}__map`}),S=k(u,"tr",{});for(const j of["import.colSource","import.colField","import.colType"])S.appendChild(k(u,"th",{text:this.#f(j)}));w.appendChild(S),m.forEach((j,E)=>{const O=k(u,"tr",{});O.appendChild(k(u,"td",{text:j.source}));const T=k(u,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:j.source})}});T.appendChild(k(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of f)T.appendChild(k(u,"option",{text:P,attrs:{value:P,selected:P===j.field?!0:null}}));j.field&&!f.includes(j.field)&&T.appendChild(k(u,"option",{text:j.field,attrs:{value:j.field,selected:!0}}));const A=k(u,"td",{});A.appendChild(T),O.appendChild(A),O.appendChild(k(u,"td",{class:`${t}__type`,text:j.type})),w.appendChild(O)}),l.appendChild(w);const h=k(u,"div",{class:`${t}__mode`}),d=k(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});d.appendChild(k(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),d.appendChild(k(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),h.appendChild(k(u,"label",{text:this.#f("import.modeLabel")})),h.appendChild(d),l.appendChild(h)}#g(){const{rows:u,columns:l}=this.#l;for(const f of this.#i.querySelectorAll("select[data-col]")){const w=Number(f.getAttribute("data-col"));l[w]&&f.value!==void 0&&f.value!==null&&(l[w].field=f.value)}const p=this.#i.querySelector("select[data-mode]"),m=p?p.value:void 0,b=m==="replace"||m==="append"?m:this.#r.mode,g=B(u,l);this.#e.import.apply(g,{mode:b}),this.close(),this.#h(this.#f("import.done",{count:g.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&M(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),je("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,H=W.on,B=W.clear,G=W.documentFor,D="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(c,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:N).t(c,o)}init(c){this.messages=c&&c.messages||c&&c.grid&&c.grid.messages||N;const o=c||{};if(this.doc=G(o),this.host=o.host||{},this.props=o.props||{},this.root=_(this.doc,"div",{class:["lattice-tokens",D],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 n=_(this.doc,"button",{class:`${D}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(H(n,"click",()=>this.toggle())),this.root.appendChild(n),this.toggleButton=n,this.menu=_(this.doc,"div",{class:`${D}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(c,o,n){const t=_(this.doc,"button",{class:`${D}__${c}`,attrs:{type:"button"},children:[_(this.doc,"span",{class:`${D}__glyph`,text:n,attrs:{"aria-hidden":"true"}}),_(this.doc,"span",{class:`${D}__label`,text:o})]});return this.off.push(H(t,"click",()=>{const i=this.host[c];M(i)&&i(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const c=this.host,o=M(c.canUndo)?c.canUndo():!1,n=M(c.canRedo)?c.canRedo():!1,t=M(c.peek)?c.peek("undo"):null,i=M(c.peek)?c.peek("redo"):null;this.#t(this.undoButton,"undo",o,t),this.#t(this.redoButton,"redo",n,i),this.open&&this.#n()}#t(c,o,n,t){if(!c)return;c.disabled=!n;const i=o==="undo",a=this.t(i?"history.undo":"history.redo"),r=c.querySelector(`.${D}__label`);r&&(r.textContent=a);const s=t&&t.label?this.t("history.described",{action:a,label:t.label}):a;c.setAttribute("title",n?s:this.t(i?"history.nothingToUndo":"history.nothingToRedo")),c.setAttribute("aria-label",n?s:this.t(i?"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 c=this.menu;if(!c)return;B(c);const o=M(this.host.list)?this.host.list():[];if(!o.length){c.appendChild(_(this.doc,"p",{class:`${D}__empty`,text:this.t("history.empty")}));return}o.forEach((n,t)=>{const i=_(this.doc,"button",{class:`${D}__item`,attrs:{type:"button",role:"menuitem","data-type":n.type,"data-undone":n.undone?"true":null},children:[_(this.doc,"span",{class:`${D}__kind`,text:n.type}),_(this.doc,"span",{class:`${D}__text`,text:n.label||n.type})]});this.off.push(H(i,"click",()=>{const a=t+1;for(let r=0;r<a;r++)M(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),c.appendChild(i)})}destroy(){for(const c of this.off)c();this.off=[],this.root&&M(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const k=v}),je("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,_={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",B="lat-cell--added-column";class G{#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 c=this.#e.diff,o=c&&c.enabled;for(const n of y.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key"),i=o?c.statusOf(t):"unchanged";for(const r of Object.values(_))n.classList.remove(r);o&&_[i]&&n.classList.add(_[i]),n.setAttribute("data-diff",o?i:"");const a=o&&i==="changed";for(const r of n.querySelectorAll("[data-col]")){const s=r.getAttribute("data-col");if(r.classList.remove(H,B),r.removeAttribute("data-before"),!a)continue;const u=c.cellStatus(t,s);if(u==="changed"){r.classList.add(H);const l=this.#r(c,t,s);l===null?r.removeAttribute("title"):(r.setAttribute("data-before",l),r.setAttribute("title",this.#o("diff.before",{value:l})))}else u==="added-column"&&r.classList.add(B)}}}#r(y,c,o){const n=this.#e,t=n&&n.columns,i=t&&M(t.get)?t.get(o):null,a=n&&n.permissions;if(i&&a&&M(a.isSecret)&&a.isSecret(i))return null;const r=y.before(c,o);if(r==null)return this.#o("diff.empty");if(!i||!M(i.formatValue))return String(r);const s=M(y.beforeRow)?y.beforeRow(c):void 0,l={...(n.rows&&M(n.rows.byKey)?n.rows.byKey(c):null)||{},data:s===void 0?{}:s};try{const p=i.formatValue(r,l,l.data);return p==null?"":String(p)}catch(p){return I(`diff-before-format:${o}`,`the formatter for column "${o}" threw while formatting a previous value, so the diff hover shows the raw one.`,p),String(r)}}#o(y,c){const o=this.#e;return(o&&o.messages?o.messages:W).t(y,c)}destroy(){for(const c of this.#n)c();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const c of y.querySelectorAll("[data-key]")){for(const o of Object.values(_))c.classList.remove(o);c.removeAttribute("data-diff")}for(const c of y.querySelectorAll("[data-col]"))c.classList.remove(H,B),c.removeAttribute("data-before")}}}function D(k){return!!(k&&k.diff&&(M(k.diff)||typeof k.diff=="object"))}const v=G}),je("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 M=V("packages/core/src/internal/util.js").isFunction,I="lat-cell--highlight",N="--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()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):M(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const G=this.#l();if(G){G.sweep();for(const D of B.querySelectorAll("[data-key]")){const v=D.getAttribute("data-key");for(const k of D.querySelectorAll("[data-col]")){const y=G.active?G.colourFor(v,k.getAttribute("data-col")):null;y?(k.classList.add(I),k.style.setProperty(N,y)):k.classList.contains(I)&&(k.classList.remove(I),k.style.removeProperty(N))}}this.#s(G)}}#s(B){this.#r!==null&&M(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const G=B.nextExpiry;if(!Number.isFinite(G)||!M(this.#i.setTimeout))return;const D=Math.max(0,G-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},D)}#l(){const B=this.#e.highlight;return B&&M(B.model)?B.model():null}destroy(){this.#r!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const G of this.#n)G();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll))for(const G of B.querySelectorAll(`.${I}`))G.classList.remove(I),G.style.removeProperty(N)}}const _=W}),je("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isFunction,I="lat-cell--find",N="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()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):M(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const G=this.#e.find;if(!G||!M(G.stateFor))return;const D=M(G.model)?G.model():null,v=!!D&&D.active;if(!v&&!this.#o)return;let k=!1;for(const y of B.querySelectorAll("[data-key]")){const c=y.getAttribute("data-key");for(const o of y.querySelectorAll("[data-col]")){const n=v?G.stateFor(c,o.getAttribute("data-col")):null;n?(k=!0,o.classList.add(I),o.classList.toggle(N,n==="current")):o.classList.contains(I)&&o.classList.remove(I,N)}}this.#o=k}destroy(){for(const G of this.#n)G();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll)){for(const G of B.querySelectorAll(`.${I}`))G.classList.remove(I,N);this.#o=!1}}}const _=W}),je("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/dom/src/editors/common.js"),M=Z.el,I=Z.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction,D="lat-find",v=12,k=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#w=null;#b=null;#v=!1;constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document||n.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=n.settings&&typeof n.settings=="object"?n.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(n,t){const i=this.#e;return(i&&i.messages&&G(i.messages.t)?i.messages:H).t(n,t)}mount(){const n=this.#S();if(!n)return;n.attachUi({open:i=>this.show(i),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),n.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&G(t.addEventListener)&&this.#o.shortcut!==!1){const i=a=>{if(!(a.ctrlKey||a.metaKey)||a.altKey||a.shiftKey||a.key!=="f"&&a.key!=="F")return;const r=a.target;if(this.#s&&r===this.#s){a.preventDefault(),a.stopPropagation(),G(this.#s.select)&&this.#s.select();return}W(r)||(a.preventDefault(),a.stopPropagation(),this.show())};t.addEventListener("keydown",i,!0),this.#g.push(()=>t.removeEventListener("keydown",i,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(n){const t=this.#A();if(!t)return;const i=t.style.display!=="none";t.style.display="",i||this.#y(),this.#S().setOpen(!0),n!=null&&(this.#s.value=String(n),this.#E()),this.#s.focus(),G(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#x();const n=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),n&&(n.clear(),n.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&G(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const r=(G(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;G(r.focus)&&r.focus()}search(){this.#E()}destroy(){this.#v=!0,this.#x();for(const t of this.#g)t();this.#g=[];const n=this.#S();n&&(n.attachUi(null),n.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const n=this.#t;n&&G(n.invalidate)&&n.invalidate("size")}#S(){const n=this.#e&&this.#e.find;return n&&G(n.model)?n.model():null}#A(){if(this.#i)return this.#i;const n=this.#t.viewport,t=n?.root,i=this.#n;if(!t||!i||!G(t.insertBefore))return null;const a=M(i,"div",{class:D,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=M(i,"input",{class:`${D}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=M(i,"span",{class:`${D}__count`,attrs:{"aria-hidden":"true"}}),this.#a=M(i,"span",{class:`${D}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=M(i,"span",{class:`${D}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const r=M(i,"button",{class:`${D}__nav ${D}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),s=M(i,"button",{class:`${D}__nav ${D}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=M(i,"button",{class:`${D}__toggle ${D}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=M(i,"button",{class:`${D}__toggle ${D}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=M(i,"select",{class:`${D}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=M(i,"button",{class:`${D}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),l=M(i,"div",{class:`${D}__options`,children:[this.#c,this.#d,this.#h]});for(const m of[this.#s,this.#l,this.#a,this.#u,r,s,u,l])a.appendChild(m);this.#g.push(I(this.#s,"input",()=>this.#O())),this.#g.push(I(r,"click",()=>this.#e.find.prev())),this.#g.push(I(s,"click",()=>this.#e.find.next())),this.#g.push(I(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push(I(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#E()})),this.#g.push(I(this.#h,"change",()=>{const m=this.#h.value;this.#p=m?String(m):null,this.#E()})),this.#g.push(I(u,"click",()=>this.hide()));const p=m=>{if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),this.hide();return}m.key==="Enter"&&m.target===this.#s&&(m.preventDefault(),m.stopPropagation(),this.#w!==null&&(this.#D(),this.#E()),m.shiftKey?this.#e.find.prev():this.#e.find.next())};return a.addEventListener("keydown",p),this.#g.push(()=>a.removeEventListener("keydown",p)),a.style.display="none",t.insertBefore(a,n.header||t.firstChild),this.#i=a,this.#j(),a}#j(){const n=this.#h;if(!n)return;const t=this.#n;for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(M(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const i=this.#e.columns,a=i&&G(i.visible)?i.visible():[];let r=!1;for(const s of a){if(!s||s.id===void 0)continue;const u=String(s.id);n.appendChild(M(t,"option",{text:s.title||u,attrs:{value:u}})),u===this.#p&&(r=!0)}r||(this.#p=null),n.value=this.#p||""}#O(){const n=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):k;if(this.#D(),n===0||!G(this.#r.setTimeout)){this.#E();return}this.#w=this.#r.setTimeout(()=>{this.#w=null,this.#E()},n)}#E(){const n=this.#S();if(!n||this.#v)return;const t=this.#s?this.#s.value:"";if(!t){this.#M(),n.clear();return}n.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#C()}),this.#T()}#C(){const n=this.#t&&this.#t.window,t=n&&Number.isFinite(n.first)?n.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#v)return;const n=()=>{this.#b=null,this.#I()};G(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(n):G(this.#r.setTimeout)?this.#b=this.#r.setTimeout(n,0):n()}#I(){const n=this.#S();!n||this.#v||!n.active||(n.stale&&n.rescan({from:this.#C()}),!n.complete&&(n.step(v)||this.#T()))}#N(){if(!this.#i||this.#v)return;const n=this.#e.find.count(),t=this.#S().active;let i="",a="idle";t&&(n.total===0?(i=n.complete?this.t("find.none"):this.t("find.searching"),a=n.complete?"none":"searching"):(i=this.t(n.complete?"find.count":"find.countPartial",{current:n.current,total:n.total}),a=n.complete?"matches":"searching")),this.#l.textContent=i,this.#i.setAttribute("data-state",a);const r=t&&n.windowed;this.#a.textContent=r?this.t("find.loadedRows"):"",this.#a.style.display=r?"":"none",t?n.complete&&(this.#u.textContent=n.total===0?this.t(r?"a11y.find.noneLoaded":"a11y.find.none"):this.t(r?"a11y.find.countLoaded":"a11y.find.count",{current:n.current,count:n.total})):this.#u.textContent=""}#D(){this.#w!==null&&G(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null}#M(){this.#b!==null&&(G(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):G(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#x(){this.#D(),this.#M()}}const c=y}),je("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Z="lat-cell--redacted",M="lat-cell";class I{#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 H=this.#e.redaction;if(!H)return;const B=H.active;for(const G of _.querySelectorAll(`.${M}[data-col]`))B&&H.has(G.getAttribute("data-col"))?G.classList.add(Z):G.classList.contains(Z)&&G.classList.remove(Z)}destroy(){for(const _ of this.#n)_();this.#n=[]}}const N=I}),je("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 M=V("packages/dom/src/editors/common.js").markInvalid,I="lat-cell";function N(H,B){let G=H;for(;G;){if(B(G))return G;G=G.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 G=N(B,D=>D.getAttribute&&D.getAttribute("data-key")!==null);return G?G.getAttribute("data-key"):null}paint(){const B=this.#e.validation;if(!B||!B.active)return;const G=this.#t.viewport?.root;if(!(!G||!G.querySelectorAll))for(const D of G.querySelectorAll(`.${I}[data-col]`)){const v=D.getAttribute("data-col"),k=this.#r(D),y=k?B.errorFor(k,v):null;M(D,y?y.message:null)}}destroy(){for(const B of this.#n)B();this.#n=[]}}const _=W}),je("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/dom/src/renderer/textentry.js").isTextEntry,_=V("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",B="lat-presenting--changing",G="lat-presenting__progress",D="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class k{#e;#t;#n;#r=[];#o=null;#i=null;#s=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",n=>this.#a(n))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&M(this.#n.watch)&&this.#r.push(this.#n.watch(n=>{n||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const o=this.#t.viewport?.root;if(o&&M(o.addEventListener)){const n=t=>this.#l(t);o.addEventListener("keydown",n),this.#r.push(()=>o.removeEventListener("keydown",n))}}#l(o){const n=this.#e.presentation;if(!n?.active)return;const t=o.ctrlKey||o.metaKey,i=o.key;if(i==="Escape"&&!this.#n){o.defaultPrevented||(n.stop(),o.preventDefault?.());return}if(t){i==="="||i==="+"?(n.nudge(1),o.preventDefault?.()):i==="-"||i==="_"?(n.nudge(-1),o.preventDefault?.()):i==="0"&&(n.setScale(1.5),o.preventDefault?.());return}if(!n.views.length||N(o.target))return;i==="ArrowRight"||i==="ArrowDown"||i==="PageDown"||i===" "?(n.step(1),o.preventDefault?.()):i==="ArrowLeft"||i==="ArrowUp"||i==="PageUp"?(n.step(-1),o.preventDefault?.()):i==="Home"?(n.goTo(0),o.preventDefault?.()):i==="End"?(n.goTo(n.views.length-1),o.preventDefault?.()):(i==="r"||i==="R")&&(n.reset(),o.preventDefault?.())}#a(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 n=this.#t.viewport?.overlays;if(!n||!this.#e.presentation.views.length)return;const t=n.ownerDocument;if(!t?.createElement)return;if(!this.#i){const r=t.createElement("div");r.className=G,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),n.appendChild(r),this.#i=r}const i=this.#e.views?.get?.(o.viewId),a=i&&i.name?i.name:"";this.#i.textContent=a?`${a} · ${(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 n=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const a of v){if(n.has(a)||a==="toolPanel"&&this.#v())continue;const r=this.#y(a);r&&r.style&&r.style.display!=="none"&&(r.style.display="none",t.push(r))}const i=this.#w();i&&i.style&&i.style.display!=="none"&&this.#b(i)&&(i.style.display="none",t.push(i)),this.#o={maximised:o,hidden:t},this.#t.viewport?.root?.classList?.add(H),this.#f(),this.#p()}#h(){const o=this.#o;this.#o=null;const n=this.#t.viewport?.root;if(n?.classList?.remove(H),n?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),n?.classList?.remove(B),this.#m(),o){const t=this.#e.toolPanel;t&&M(t.presentRestore)&&t.presentRestore();for(const i of o.hidden)i.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 n=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=n&&n.keys.length?new Set(n.keys):null,i=n&&n.colIds.length?new Set(n.colIds):null;for(const a of o.querySelectorAll("[data-key]")){const r=!t||t.has(a.getAttribute("data-key"));for(const s of a.querySelectorAll("[data-col]"))!n||r&&(!i||i.has(s.getAttribute("data-col")))?s.classList.remove(D):s.classList.add(D)}}#p(){this.#g();const o=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(o)||o<=0||!this.#e.presentation.views.length)return;const n=this.#t.viewport?.root?.ownerDocument?.defaultView;n?.setInterval&&(this.#s=n.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.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#w(){const o=this.#e.element;return!o||!M(o.querySelector)?null:o.querySelector(`.${_.statusBar}`)}#b(o){const n=o.children||[];for(const t of n)if(!t.style||t.style.display!=="none")return!1;return!0}#v(){const o=this.#e.toolPanel;return!!(o&&M(o.presentOnly)&&o.presentOnly())}#y(o){const n=this.#e.element;if(!n||!M(n.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?n.querySelector(t):null}destroy(){this.#o&&this.#h();for(const o of this.#r)o();this.#r=[]}}const y=k}),je("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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const M=V("packages/core/src/internal/util.js").isFunction,I=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function N(G,D,v){const k=v.getComputedStyle(G),y=D.style;if(y)for(let c=0;c<k.length;c++){const o=k[c];I.has(o)||y.setProperty(o,k.getPropertyValue(o),k.getPropertyPriority(o))}}function W(G,D,v){if(N(G,D,v),G.tagName==="CANVAS"&&M(G.toDataURL))try{const c=G.toDataURL("image/png"),o=D.style;o&&(o.setProperty("background-image",`url(${c})`),o.setProperty("background-size","100% 100%"),o.setProperty("background-repeat","no-repeat"))}catch{}const k=G.children||[],y=D.children||[];for(let c=0;c<k.length&&c<y.length;c++)W(k[c],y[c],v)}function _(G,D){if(!G||G.startsWith("data:")||G.startsWith("blob:"))return!0;try{return new URL(G,D).origin===D}catch{return!0}}async function H(G,D={}){const v=G.ownerDocument,k=v?.defaultView;if(!k||typeof k.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=G.getBoundingClientRect(),c=Math.max(1,Math.ceil(y.width)),o=Math.max(1,Math.ceil(y.height)),n=Math.max(.1,Number(D.scale)||2),t=k.location?.origin||"";for(const p of G.querySelectorAll("img")){const m=p.getAttribute("src")||"";if(!_(m,t))throw new Error(`capture refused: the image at ${m} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const i=G.cloneNode(!0);W(G,i,k),i.style.width=`${c}px`,i.style.height=`${o}px`,i.style.margin="0";const a=new k.XMLSerializer().serializeToString(i),r=`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${o}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${a}</div></foreignObject></svg>`,s=new k.Image;await new Promise((p,m)=>{s.onload=()=>p(void 0),s.onerror=()=>m(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),s.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`});const u=v.createElement("canvas");u.width=Math.round(c*n),u.height=Math.round(o*n);const l=u.getContext("2d");if(!l)throw new Error("capture could not get a 2d context");return l.fillStyle=D.background||k.getComputedStyle(G).backgroundColor||"#ffffff",l.fillRect(0,0,u.width,u.height),l.drawImage(s,0,0,u.width,u.height),new Promise((p,m)=>{u.toBlob(b=>b?p({blob:b,width:u.width,height:u.height}):m(new Error("capture produced no image")),D.type||"image/png",D.quality)})}const B=H}),je("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 H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,_=Object.freeze(["pen","arrow","rect","highlight"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),B=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),G=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=14,v="system-ui, -apple-system, sans-serif";function k(r,s){if(!r||typeof r!="object")return null;const u=B[r.type];if(!u)return null;const l=Array.isArray(r.points)?r.points:[],p=[];for(const b of l){const g=Number(b&&b.x),f=Number(b&&b.y);Number.isFinite(g)&&Number.isFinite(f)&&p.push({x:g,y:f})}const m=typeof r.colour=="string"&&r.colour?r.colour:s;if(u==="text"){const b=typeof r.text=="string"?r.text:"";if(!p.length||!b)return null;const g={tool:u,colour:m,points:[p[0]],text:b,region:y(r.region)},f=Number(r.fontSize);return Number.isFinite(f)&&f>0&&(g.fontSize=f),typeof r.background=="string"&&r.background&&(g.background=r.background),g}return p.length<2?null:{tool:u,colour:m,points:p,region:y(r.region)}}function y(r){return r==="start"||r==="end"?r:"centre"}function c(r){const s={type:G[r.tool]||r.tool,colour:r.colour,points:r.points.map(u=>({x:u.x,y:u.y}))};return(r.region==="start"||r.region==="end")&&(s.region=r.region),r.tool==="text"&&(s.text=r.text,r.fontSize!==void 0&&(s.fontSize=r.fontSize),r.background!==void 0&&(s.background=r.background)),s}const o="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(r){return r==="arrow"||r==="rect"}class i{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const u=k(s,this.#i);return u?(u.durable=!0,this.#s.push(u),this.#y(),this.redraw(),this.#j(),this.#s.length):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#s.length)}list(){return this.#s.map(c)}replaceAll(s){const u=Array.isArray(s)?s:[];this.#s=u.map(l=>k(l,this.#i)).filter(Boolean);for(const l of this.#s)l.durable=!0;this.#s.length&&this.#y(),this.redraw(),this.#j()}#c(){const s=this.#t.viewport?.root;if(!s||!M(s.addEventListener))return;const u=l=>{!this.#o||!l||l.key!=="Escape"||(this.use(null),l.preventDefault?.())};s.addEventListener("keydown",u,!0),this.#a.push(()=>s.removeEventListener("keydown",u,!0))}#d(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!M(s.matchMedia))return;let u=null;const l=()=>{const p=s.devicePixelRatio||1;let m;try{m=s.matchMedia(`(resolution: ${p}dppx)`)}catch{return}u=m;const b=()=>{this.redraw(),l()};M(m.addEventListener)?m.addEventListener("change",b,{once:!0}):M(m.addListener)&&m.addListener(b)};l(),this.#a.push(()=>{u=null})}use(s,u={}){const l=!!u.colour&&s===this.#o;u.colour&&(this.#i=String(u.colour));const p=s&&_.includes(s)?s:null;this.#o=p&&p===this.#o&&!l?null:p;const m=this.#o?this.#y():this.#n;return m&&(m.style.pointerEvents=this.#o?"auto":"none",m.style.cursor=this.#o?"crosshair":""),this.#j(),this.#o}undo(){return this.#s.pop(),this.redraw(),this.#j(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.redraw(),this.#j())}#h(){const s=this.#s.filter(u=>u.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#j())}redraw(){!this.#n&&this.#s.length&&this.#y();const s=this.#n,u=this.#r;if(!s||!u)return;this.#S();const{left:l,top:p}=this.#v();u.clearRect(0,0,s.width,s.height);const m=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const g=m.filter(f=>y(f.region)===b);if(g.length){u.save(),this.#f(u,b),u.translate((b==="centre"?-l:0)||0,-p||0);for(const f of g)this.#w(u,f);u.restore()}}}#f(s,u="centre"){const l=this.#n,p=this.#t.viewport?.bodyViewport;if(!M(l?.getBoundingClientRect)||!M(p?.getBoundingClientRect))return;const m=l.getBoundingClientRect(),b=p.getBoundingClientRect();if(!b.width||!b.height)return;const g=this.#m(u,b);g&&(s.beginPath(),s.rect(g.left-m.left,b.top-m.top,g.width,b.height),s.clip())}#m(s,u){const l=w=>{if(!M(w?.getBoundingClientRect))return null;const S=w.getBoundingClientRect();return S&&S.width>0?{left:S.left,width:S.width}:null},p=l(this.#t.viewport?.bodyStart),m=l(this.#t.viewport?.bodyEnd);if(s==="start")return p;if(s==="end")return m;let b=u.left,g=u.left+u.width;const f=u.left+u.width/2;for(const w of[p,m]){if(!w)continue;const S=w.left+w.width;w.left+w.width/2<f?b=Math.max(b,S):g=Math.min(g,w.left)}return g>b?{left:b,width:g-b}:null}#p(s){for(const[u,l]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!M(l?.getBoundingClientRect))continue;const p=l.getBoundingClientRect();if(p&&p.width>0&&s>=p.left&&s<p.left+p.width)return u}return"centre"}#g(s){const u=this.#t.viewport?.bodyViewport;if(!M(u?.getBoundingClientRect))return!0;const l=u.getBoundingClientRect();return!l.width||!l.height?!0:s.clientX>=l.left&&s.clientX<=l.right&&s.clientY>=l.top&&s.clientY<=l.bottom}#w(s,u){const l=u.points;if(!l.length)return;const p=this.#e.presentation?.scale||1;s.lineWidth=(n[u.tool]||3)*p,s.strokeStyle=u.colour,s.fillStyle=u.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=u.tool==="highlight"?.32:1;const m=l[0],b=l[l.length-1];if(u.tool==="text"){const g=(u.fontSize||D)*p;s.font=`${g}px ${v}`,s.textBaseline="top";const f=u.text||"";if(u.background){let w=f.length*g*.6;if(typeof s.measureText=="function"){const S=s.measureText(f);S&&Number.isFinite(S.width)&&(w=S.width)}s.fillStyle=u.background,s.fillRect(m.x-g*.15,m.y-g*.1,w+g*.3,g*1.2)}s.fillStyle=u.colour,s.fillText(f,m.x,m.y),s.globalAlpha=1;return}if(u.tool==="rect")s.strokeRect(m.x,m.y,b.x-m.x,b.y-m.y);else if(u.tool==="arrow")s.beginPath(),s.moveTo(m.x,m.y),s.lineTo(b.x,b.y),s.stroke(),this.#b(s,m,b,s.lineWidth);else{s.beginPath(),s.moveTo(m.x,m.y);for(let g=1;g<l.length;g++)s.lineTo(l[g].x,l[g].y);s.stroke()}s.globalAlpha=1}#b(s,u,l,p){const m=Math.atan2(l.y-u.y,l.x-u.x),b=Math.max(8,p*3);s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(l.x-b*Math.cos(m-Math.PI/7),l.y-b*Math.sin(m-Math.PI/7)),s.lineTo(l.x-b*Math.cos(m+Math.PI/7),l.y-b*Math.sin(m+Math.PI/7)),s.closePath(),s.fill()}#v(){const s=M(this.#t.scrollPosition)?this.#t.scrollPosition():null,u=this.#t.viewport?.rtl===!0;return{left:W(s?.left||0,u),top:s?.top||0}}#y(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,u=s?.ownerDocument;if(!s||!u?.createElement)return null;const l=u.createElement("canvas");return l.className=o,l.style.position="absolute",l.style.inset="0",l.style.pointerEvents="none",s.appendChild(l),this.#n=l,this.#r=l.getContext?l.getContext("2d"):null,this.#S(),this.#A(l),l}#S(){const s=this.#n,u=this.#t.viewport?.root;if(!s||!u?.getBoundingClientRect)return;const l=u.getBoundingClientRect(),m=s.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(l.width*m)),g=Math.max(1,Math.round(l.height*m));s.width===b&&s.height===g||(s.width=b,s.height=g,s.style&&(s.style.width=`${Math.max(1,l.width)}px`,s.style.height=`${Math.max(1,l.height)}px`),this.#r?.setTransform(m,0,0,m,0,0))}#A(s){const u=(g,f="centre")=>{const w=s.getBoundingClientRect(),{left:S,top:h}=this.#v();return{x:g.clientX-w.left+(f==="centre"?S:0),y:g.clientY-w.top+h}},l=g=>{if(!this.#o||!this.#g(g))return;const f=this.#p(g.clientX);this.#l={tool:this.#o,colour:this.#i,points:[u(g,f)],region:f},s.setPointerCapture?.(g.pointerId),g.preventDefault?.()},p=g=>{if(!this.#l)return;const f=u(g,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(f),this.redraw()},m=g=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(g.pointerId),this.redraw(),this.#j())},b=g=>{if(!this.#o)return;const f=this.#t.viewport?.bodyViewport;if(!f)return;let w=!1;g.deltaY&&typeof f.scrollTop=="number"&&(f.scrollTop+=g.deltaY,w=!0),g.deltaX&&typeof f.scrollLeft=="number"&&(f.scrollLeft+=g.deltaX,w=!0),w&&g.preventDefault?.()};s.addEventListener("pointerdown",l),s.addEventListener("pointermove",p),s.addEventListener("pointerup",m),s.addEventListener("pointercancel",m),s.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",l),s.removeEventListener("pointermove",p),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m),s.removeEventListener("wheel",b)})}#j(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const a=i}),je("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 H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function _(D){if(!Number.isFinite(D)||D<1e3)return"now";const v=Math.round(D/1e3);if(v<60)return`${v}s ago`;const k=Math.round(v/60);return k<60?`${k}m ago`:`${Math.round(k/60)}h ago`}function H(D,v){return Number.isFinite(D)?new Date(D).toLocaleTimeString(v||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class B{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(v){this.#e=v.grid,this.#t=v.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const v=this.#e.timeline,k=v.depth,y=v.position;this.#r.max=String(Math.max(1,k)),this.#r.value=String(Math.max(0,k-y)),this.#r.disabled=k===0;const c=v.at(),o=v.live;this.#o&&(this.#o.textContent=o?this.#l("timeline.live"):_(Date.now()-(c||Date.now())),this.#o.setAttribute("data-live",o?"true":"false")),this.#i&&(this.#i.textContent=k===0?this.#l("timeline.recording"):H(c,this.#e.get("locale"))),this.#n.setAttribute("data-live",o?"true":"false")}#l(v,k){const y=this.#e;return(y&&y.messages?y.messages:N).t(v,k)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,k=v?.ownerDocument;if(!v||!k?.createElement)return;const y=k.createElement("div");y.className=W;const c=k.createElement("span");c.className=`${W}__ago`,c.setAttribute("role","status"),c.setAttribute("aria-live","polite");const o=k.createElement("input");o.className=`${W}__range`,o.type="range",o.min="0",o.step="1",o.setAttribute("aria-label",this.#l("timeline.scrub"));const n=k.createElement("span");n.className=`${W}__clock`;const t=k.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#l("timeline.goLive"),t.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(c),y.appendChild(o),y.appendChild(n),y.appendChild(t),v.appendChild(y),this.#n=y,this.#r=o,this.#o=c,this.#i=n;const i=()=>{const s=this.#e.timeline.depth;this.#e.timeline.seek(s-Number(o.value))};o.addEventListener("input",i);const a=()=>this.#e.timeline.toLive();t.addEventListener("click",a);const r=s=>s.stopPropagation();o.addEventListener("keydown",r),this.#s.push(()=>{o.removeEventListener("input",i),t.removeEventListener("click",a),o.removeEventListener("keydown",r)})}#u(){this.#n&&(M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const v of this.#s)v();this.#s=[],this.#u()}}const G=B}),je("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",B="lat-cell--commented",G="lat-cell--commented-open";class D{#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.#s(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const c=this.#t.viewport?.root;if(!c||!c.querySelectorAll)return;const o=[];for(const n of c.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key");if(t){o.push(t);for(const i of n.querySelectorAll("[data-col]")){const a=i.getAttribute("data-col"),r=y.at(t,a),s=!!(r&&r.count);i.classList.toggle(B,s),i.classList.toggle(G,s&&r.unresolved>0),this.#i(i,r,a)}}}(o.length!==this.#r.length||o.some((n,t)=>n!==this.#r[t]))&&(this.#r=o,y.request(o))}#o(y,c){const o=this.#e;return(o&&o.messages?o.messages:N).t(y,c)}#i(y,c,o){if(!c||!c.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const n=c.count,t=c.unresolved,i=this.#o("count.comments",{count:n});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:i,unresolved:t}):this.#o("comments.allResolved",{comments:i}))}#s(){const y=this.#t.viewport?.root;if(!y||!M(y.addEventListener))return;const c=n=>{const t=this.#e.comments;if(!t||!t.enabled)return;const i=n.target&&M(n.target.closest)?n.target.closest("[data-col]"):null;if(!i||!i.classList.contains(B)||!this.#l(i,n))return;const a=i.closest("[data-key]"),r=a&&a.getAttribute("data-key");r&&(n.stopPropagation(),n.preventDefault(),t.open(r,i.getAttribute("data-col")))},o=n=>{const t=this.#e.comments;if(!t||!t.enabled||!n.altKey||n.key!=="m"&&n.key!=="M")return;const i=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&M(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!i)return;const a=i.closest("[data-key]"),r=a&&a.getAttribute("data-key");r&&(n.preventDefault(),n.stopPropagation(),t.open(r,i.getAttribute("data-col")))};y.addEventListener("click",c,!0),y.addEventListener("keydown",o,!0),this.#n.push(()=>{y.removeEventListener("click",c,!0),y.removeEventListener("keydown",o,!0)})}#l(y,c){if(!M(y.getBoundingClientRect))return!1;const o=y.getBoundingClientRect(),n=Math.max(14,Math.min(24,o.height*.6));return(_(y)?c.clientX<=o.left+n:c.clientX>=o.right-n)&&c.clientY<=o.top+n}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=D}),je("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=V("packages/core/src/internal/util.js").isFunction,N=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,G="lat-presence";class D{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=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 c of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(c,o=>this.#l(c,o)));this.#a(),this.paint()}}#l(y,c){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const n=c&&c.peer;n&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:n.name}))}#a(){const y=this.#t.viewport?.overlays,c=y?.ownerDocument;if(!y||!c?.createElement)return;const o=this.#e.get("presence")||{},n=c.createElement("span");if(n.className=`${G}__live`,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),y.appendChild(n),this.#r=n,o.roster===!1)return;const t=c.createElement("div");t.className=G,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,c=this.#t.viewport?.root;if(!y||!y.enabled||!c?.querySelectorAll)return;this.#d(c);const o=y.peers(),n=[...o].sort((t,i)=>t.at-i.at);for(const t of n)for(const i of t.ranges||[])for(const a of i.rowIds||[])for(const r of i.columns||[])this.#c(c,a,r,t,"range");for(const t of n)t.cursor&&this.#c(c,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of n)t.editing&&this.#c(c,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(o)}#u(y){if(this.#s!==null)return;const c=y.filter(t=>t.cursorFresh);if(!c.length)return;const n=Math.max(...c.map(t=>t.cursorAt||0))+B-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,n))}#c(y,c,o,n,t){const i=y.querySelector(`[data-key="${_(c)}"]`),a=i&&i.querySelector(`[data-col="${_(o)}"]`);a&&(a.setAttribute("data-presence",t),a.style.setProperty("--lat-peer",n.colour),a.setAttribute("data-peer-name",n.name),a.setAttribute("data-peer-initial",n.initials||(n.name||"?").slice(0,1).toUpperCase()),n.idle?a.setAttribute("data-peer-idle","true"):a.removeAttribute("data-peer-idle"),t==="cursor"&&n.cursorFresh&&a.setAttribute("data-peer-fresh","true"),this.#o.add(`${c}${o}`))}#d(y){if(this.#o.size){for(const c of y.querySelectorAll("[data-presence]"))c.removeAttribute("data-presence"),c.removeAttribute("data-peer-name"),c.removeAttribute("data-peer-initial"),c.removeAttribute("data-peer-fresh"),c.removeAttribute("data-peer-idle"),c.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,c=this.#e.presence.peers();if(this.#n.textContent="",!c.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const n of c){const t=y.createElement("button");t.className=`${G}__peer`,t.type="button",t.style.setProperty("--lat-peer",n.colour),t.toggleAttribute("data-idle",!!n.idle),t.toggleAttribute("data-hidden",!!n.hidden);let i="presence.peer";n.hidden?i="presence.peerHidden":n.idle&&(i="presence.peerIdle"),t.setAttribute("aria-label",this.#f(i,{name:n.name}));const a=y.createElement("span");a.className=`${G}__dot`,a.setAttribute("aria-hidden","true"),a.textContent=n.initials||(n.name||"?").slice(0,1).toUpperCase(),t.appendChild(a);const r=y.createElement("span");r.className=`${G}__name`,r.textContent=n.name,t.appendChild(r),t.addEventListener("click",()=>this.#e.presence.jumpTo(n.id)),this.#n.appendChild(t)}const o=c.filter(n=>n.hidden).length;if(o){const n=y.createElement("span");n.className=`${G}__hidden`,n.textContent=this.#f("presence.hidden",{count:o}),this.#n.appendChild(n)}}announceRefusal(y){if(!this.#r)return;const c=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:c})}#f(y,c){const o=this.#e;return(o&&o.messages?o.messages:N).t(y,c)}destroy(){for(const c of this.#i)c();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=D}),je("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=V("packages/core/src/internal/util.js").isFunction,N=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,G="lat-comments",D=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function k(n,t){if(!Number.isFinite(n))return"";const i=Math.max(0,Math.round((t-n)/1e3));if(i<60)return"just now";const a=Math.round(i/60);if(a<60)return`${a}m ago`;const r=Math.round(a/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function y(n,t,i,a){t.textContent="";const r=String(i??"");if(!a){t.textContent=r;return}const s=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,l=s.exec(r);for(;l;){l.index>u&&t.appendChild(n.createTextNode(r.slice(u,l.index)));const p=l[0];if(p.startsWith("*")){const m=n.createElement("em");m.textContent=p.slice(1,-1),t.appendChild(m)}else if(p.startsWith("`")){const m=n.createElement("code");m.textContent=p.slice(1,-1),t.appendChild(m)}else{const m=p.indexOf("]("),b=p.slice(1,m),g=p.slice(m+2,-1);if(D.test(g)){const f=n.createElement("a");f.href=g,f.textContent=b,f.rel="noopener noreferrer",f.target="_blank",t.appendChild(f)}else t.appendChild(n.createTextNode(b))}u=l.index+p.length,l=s.exec(r)}u<r.length&&t.appendChild(n.createTextNode(r.slice(u)))}class c{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",t=>this.#a(t))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(t){const i=this.#t.viewport?.root?.ownerDocument;i&&(this.#s=i.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(i),this.#n.setAttribute("data-open","true"),this.#b(),this.#y(),this.#o&&M(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#s;this.#s=null,t&&M(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:i}=B(t);this.#e.rows.byKey(i)||(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 a=this.#r.ownerDocument.createElement("p");a.className=`${G}__note`,a.setAttribute("role","status"),a.textContent=t,this.#r.appendChild(a)}#h(t,i){const a=this.#t.viewport?.root;if(!a||!a.querySelector)return null;const r=a.querySelector(`[data-key="${_(t)}"]`);return r?r.querySelector(`[data-col="${i}"]`):null}#f(t,i){const a=this.#e;return(a&&a.messages?a.messages:N).t(t,i)}#m(t){const i=t.createElement("div");i.className=G,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",this.#f("comments.panel"));const a=t.createElement("header");a.className=`${G}__head`;const r=t.createElement("div");r.className=`${G}__title`,a.appendChild(r);const s=t.createElement("button");s.className=`${G}__resolve`,s.type="button",a.appendChild(s);const u=t.createElement("button");u.className=`${G}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",a.appendChild(u);const l=t.createElement("div");l.className=`${G}__list`,l.setAttribute("role","log"),l.setAttribute("aria-live","polite");const p=t.createElement("form");p.className=`${G}__composer`;const m=t.createElement("textarea");m.className=`${G}__input`,m.rows=2,m.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${G}__send`,b.type="submit",b.textContent=this.#f("comments.post"),p.appendChild(m),p.appendChild(b),i.appendChild(a),i.appendChild(l),i.appendChild(p),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(i),this.#n=i,this.#r=l,this.#o=m,this.#p=r,this.#g=s;const g=h=>{h.preventDefault();const d=String(m.value||"").trim();d&&(m.value="",this.#e.comments.add(d))},f=()=>this.#e.comments.close(),w=()=>{this.#w()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},S=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.#e.comments.close();return}if(h.key!=="Tab")return;const d=[...i.querySelectorAll(v)].filter(T=>T.offsetParent!==null||T===m);if(!d.length)return;const j=d[0],E=d[d.length-1],O=i.ownerDocument.activeElement;h.shiftKey&&O===j?(h.preventDefault(),E.focus()):!h.shiftKey&&O===E&&(h.preventDefault(),j.focus())};p.addEventListener("submit",g),u.addEventListener("click",f),s.addEventListener("click",w),i.addEventListener("keydown",S),this.#l.push(()=>{p.removeEventListener("submit",g),u.removeEventListener("click",f),s.removeEventListener("click",w),i.removeEventListener("keydown",S)})}#p=null;#g=null;#w(){return(this.#e.comments.thread||[]).filter(i=>!i.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const i=this.#n.ownerDocument,a=this.#e.get("comments")||{},r=Date.now(),s=t.openKey,{rowId:u,field:l}=B(s),p=this.#e.columns.get(l),m=this.#e.rows.byKey(u),b=M(a.rowLabel)&&m?a.rowLabel(m):u;if(this.#p.textContent=this.#f("comments.cellTitle",{column:p&&(p.title??p.id)||l,row:b}),this.#g.textContent=this.#w()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const g=t.thread||[];if(!g.length){this.#d(this.#f("comments.empty"));return}const f=m&&p?p.getValue(m.data,m):void 0;for(const w of g)this.#r.appendChild(this.#v(i,w,r,f,a))}#v(t,i,a,r,s){const u=t.createElement("article");u.className=`${G}__item`,i.pending&&u.setAttribute("data-pending","true"),i.resolved&&u.setAttribute("data-resolved","true");const l=t.createElement("div");l.className=`${G}__meta`;const p=t.createElement("span");p.className=`${G}__author`,p.textContent=i.author&&(i.author.name||i.author.initials)||this.#f("comments.unknownAuthor"),l.appendChild(p);const m=t.createElement("time");m.className=`${G}__time`;const b=k(i.at,a);m.textContent=i.edited?this.#f("comments.edited",{time:b}):b,l.appendChild(m),u.appendChild(l);const g=t.createElement("div");if(g.className=`${G}__body`,y(t,g,i.body,!!s.markdown),u.appendChild(g),i.value!==void 0&&!Object.is(i.value,r)){const S=t.createElement("p");S.className=`${G}__moved`,S.textContent=this.#f("comments.valueMoved",{was:String(i.value),now:String(r)}),u.appendChild(S)}const f=i.can||{},w=S=>f[S]!==!1;if(w("edit")||w("delete")){const S=t.createElement("div");if(S.className=`${G}__actions`,w("delete")){const h=t.createElement("button");h.type="button",h.className=`${G}__action`,h.textContent=this.#f("comments.delete"),h.addEventListener("click",()=>this.#e.comments.remove(i.id)),S.appendChild(h)}u.appendChild(S)}return u}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const i=this.#e.comments.openKey,{rowId:a,field:r}=B(i),s=this.#h(a,r)||this.#i,u=this.#t.viewport?.root;if(!s||!u||!M(s.getBoundingClientRect))return;const l=s.getBoundingClientRect(),p=u.getBoundingClientRect(),m=this.#n.getBoundingClientRect();let b=l.bottom-p.top+4;b+m.height>p.height&&l.top-p.top>m.height&&(b=l.top-p.top-m.height-4);let g=l.left-p.left;g+m.width>p.width&&(g=Math.max(0,p.width-m.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,g)}px`;const f=l.bottom<p.top||l.top>p.bottom;this.#n.toggleAttribute("data-offscreen",f)}destroy(){for(const t of this.#l)t();this.#l=[],this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const o=c}),je("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 k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,H=W.on,B="lat-watermark",G="https://www.latticegrid.dev",D=["br","bl","tl","tr"],v=4e3;class k{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=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(),M(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const o=this.#e.licence&&this.#e.licence.ready;o&&M(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())}#a(){const o=this.#i;if(!o||!M(o.matchMedia))return!1;try{return!!o.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),M(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%D.length,this.#f(),this.#h(),this.#u()},v)))}#c(){this.#l!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const o=this.#e.licence;return!!(o&&M(o.watermark)&&o.watermark())}#h(){const o=_(this.#t,"a",{class:`${B}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:N).t("licence.watermark"),attrs:{href:G,target:"_blank",rel:"noopener noreferrer"}});this.#r=_(this.#t,"div",{class:`${B} ${B}--${D[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o]}),this.#o.push(H(this.#r,"pointerdown",n=>{M(n.stopPropagation)&&n.stopPropagation()})),this.#n&&M(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&M(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=k}),je("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isFunction,N=V("packages/dom/src/editors/common.js"),W=N.el,_=N.on,B=V("packages/dom/src/themeof.js").themeOf,G="lat-maximised",D={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"},v="lat-maximised-host",k="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(n){this.#e=n.element,this.#t=n.document,this.#n=I(n.onChange)?n.onChange:null,this.#r=I(n.captureScroll)?n.captureScroll:null,this.#o=I(n.restoreScroll)?n.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const n=this.#e.parentNode;if(!n||!this.#t.body)return M("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:k}),this.#i.style.visibility="hidden";const t=this.#e.offsetWidth,i=this.#e.offsetHeight;t&&(this.#i.style.width=`${t}px`),i&&(this.#i.style.height=`${i}px`);const a=this.#r?this.#r():null,r=I(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?B(n):null;r&&(this.#e.setAttribute("data-theme",r),this.#u=!0),n.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[s,u]of Object.entries(D))this.#a[s]=this.#e.style[s]||"",this.#e.style[s]=u;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(G),this.#t.body.classList&&this.#t.body.classList.add(v),a&&this.#o&&this.#o(a),this.#s=_(this.#t,"keydown",s=>this.#h(s)),this.#f(),!0}exit(){if(!this.active())return!1;const n=this.#r?this.#r():null,t=this.#i,i=t.parentNode;if(i&&I(i.insertBefore)&&this.#d(()=>i.insertBefore(this.#e,t)),I(t.remove)&&t.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[a,r]of Object.entries(this.#a))this.#e.style[a]=r;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(G),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),n&&this.#o&&this.#o(n),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(n){const t=this.#t.activeElement,i=t&&t!==this.#t.body&&I(this.#e.contains)&&this.#e.contains(t)?t:null;n(),i&&I(i.focus)&&i.focus()}#h(n){!n||n.key!=="Escape"||n.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const n of this.#l)n(this.active())}watch(n){return I(n)?(this.#l.add(n),()=>this.#l.delete(n)):()=>{}}destroy(){this.exit()}}const c=y}),je("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 i}});const Z=V("packages/dom/src/editors/common.js"),M=Z.documentFor,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction,D=V("packages/core/src/ai/schema.js"),v=D.describeGrid,k=D.promptText,y=V("packages/core/src/ai/intent.js"),c=y.applyPlan,o=y.buildPrompt,n=y.planIntent,t="lat-prompt";class i{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#w="idle";#b=0;#v=!1;#y=[];t(u,l){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(u,l)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||H,this.#e=M(u),this.#t=u.grid||null,this.#n=G(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:G(u.onPlan)?u.onPlan:null,onApply:G(u.onApply)?u.onApply:null,onError:G(u.onError)?u.onError:null},this.#s=I(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(u)}element(){return this.#s}refresh(){this.#v||!this.#s||this.#w!=="busy"&&this.#E()}destroy(){this.#v=!0,this.#b++;for(const u of this.#y)u();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(u){if(this.#v||this.#w==="busy")return null;const l=String(u??(this.#l&&this.#l.value)??"").trim();if(!l)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const p=++this.#b;this.#A("busy"),this.#C("Thinking…");let m;try{const b=v(this.#t,this.#r),g=k(b);if(m=await this.#n({prompt:l,schema:b,schemaText:g,message:o(l,g),context:this.#o}),this.#v||p!==this.#b)return null;const f=n(m,b);return this.#j(f),f}catch(b){return this.#v||p!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const u=this.#g;if(this.#v||!u||!u.ok)return null;const l=this.#t?.ai,p=G(l?.apply)?l.apply(u):c(u,this.#t);return this.#i.onApply&&this.#i.onApply(p,u),this.#E(),this.#l&&(this.#l.value=""),p.failed.length?this.#T(`Applied ${p.applied.length}; ${p.failed.map(m=>`${m.type} failed: ${m.reason}`).join("; ")}`):this.#C(`Applied: ${u.describe()}`),p}discard(){this.#v||(this.#E(),this.#C("Discarded."))}#S(u){const l=this.#e,p=I(l,"div",{class:`${t}__row`});this.#l=I(l,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(N(this.#l,"keydown",b=>{const g=b&&b.key;g==="Enter"?(G(b.preventDefault)&&b.preventDefault(),this.ask()):g==="Escape"&&this.#g&&(G(b.preventDefault)&&b.preventDefault(),this.discard())})),p.appendChild(this.#l),this.#a=I(l,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(N(this.#a,"click",()=>{this.ask()})),p.appendChild(this.#a),this.#s.appendChild(p),this.#u=I(l,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=I(l,"p",{class:`${t}__summary`}),this.#d=I(l,"ul",{class:`${t}__notes`});const m=I(l,"div",{class:`${t}__buttons`});this.#h=I(l,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=I(l,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(N(this.#h,"click",()=>{this.apply()})),this.#y.push(N(this.#f,"click",()=>{this.discard()})),m.appendChild(this.#h),m.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(m),this.#s.appendChild(this.#u),this.#m=I(l,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=I(l,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#m),this.#s.appendChild(this.#p)}#A(u){if(this.#w=u,!this.#s)return;this.#s.setAttribute("data-state",u);const l=u==="busy";a(this.#l,l),a(this.#a,l),this.#a&&(this.#a.textContent=this.t(l?"prompt.asking":"prompt.ask")),r(this.#u,u!=="preview"),r(this.#p,u!=="error")}#j(u){const l=u;if(this.#i.onPlan&&this.#i.onPlan(u),!l.ok){this.#g=null;const p=l.rejected.length?l.rejected.map(m=>m.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${p}`);return}this.#g=u,this.#C(""),this.#c&&(this.#c.textContent=l.describe()),this.#O(l.rejected),this.#A("preview")}#O(u){const l=this.#d;if(l){W(l),r(l,!u.length);for(const p of u.slice(0,6))l.appendChild(I(this.#e,"li",{class:`${t}__note`,text:p.reason}));u.length>6&&l.appendChild(I(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#A("idle")}#C(u){this.#m&&(this.#m.textContent=u)}#T(u){this.#g=null,this.#C(""),this.#p&&(this.#p.textContent=u),this.#A("error")}}function a(s,u){s&&(s.disabled=u,u?s.setAttribute("disabled",""):s.removeAttribute("disabled"))}function r(s,u){s&&(s.hidden=u,u?s.setAttribute("hidden",""):s.removeAttribute("hidden"))}}),je("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 i}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.isObject,N=Z.warnOnce,_=V("packages/core/src/source/derive.js").reduceValues,B=V("packages/core/src/source/memory.js").isPipelineSettle,D=V("packages/core/src/i18n/index.js").defaultMessages,k=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"},c="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"]),n=Object.freeze({direction:"flat",change:null,percent:null});function t(g,f){if(!Number.isFinite(g)||!Number.isFinite(f))return n;const w=g-f,S=w>0?"up":w<0?"down":"flat",h=f===0?null:w/Math.abs(f)*100;return{direction:S,change:w,percent:h}}function i(g,f){return g==="flat"||f==="neither"?"flat":g===f?"good":"bad"}function a(g,f,w=null){if(M(f)){const O=f(g,w);return O==="good"||O==="warn"||O==="bad"?O:null}if(!I(f))return null;const S=typeof g=="number"&&Number.isFinite(g)?g:null;if(S===null)return null;const h=Number.isFinite(Number(f.good))?Number(f.good):null,d=Number.isFinite(Number(f.warn))?Number(f.warn):null,j=String(f.direction||"up")==="down",E=O=>j?S<=O:S>=O;return h!==null&&E(h)?"good":d!==null&&E(d)?"warn":h===null&&d===null?null:"bad"}function r(g){return!(M(g.value)||g.value!==void 0&&!I(g.value))}function s(g){return!g||!g.rows||!M(g.rows.totalCount)?!0:g.rows.totalCount()>0}function u(g){const f=I(g)?g:{},w=f.grid||null,S=m(f.container,w);if(!S)return N("stat.container","createStat needs a `container`: an element or a selector."),b();const h=S.ownerDocument||(typeof document>"u"?null:document);if(!h)return N("stat.document","createStat needs a document; it draws DOM."),b();const d=h.createElement("div");d.className=["lattice",y.root,f.class].filter(Boolean).join(" "),d.setAttribute("role","group");const j=h.createElement("div");j.className=y.title;const E=h.createElement("div");E.className=y.value;const O=h.createElement("div");O.className=y.interval;const T=h.createElement("div");T.className=y.delta;const A=h.createElement("div");A.className=y.footer;const P=h.createElement("div");if(P.className=y.note,P.hidden=!0,f.icon!=null&&f.icon!==""){const te=h.createElement("span");te.className=y.icon,te.setAttribute("aria-hidden","true"),k(te,f.icon,`stat:${f.title||"stat"}`),d.appendChild(te);const ee=h.createElement("div");ee.className=y.body,ee.appendChild(j),ee.appendChild(E),ee.appendChild(P),ee.appendChild(O),ee.appendChild(T),ee.appendChild(A),d.appendChild(ee)}else d.appendChild(j),d.appendChild(E),d.appendChild(P),d.appendChild(O),d.appendChild(T),d.appendChild(A);S.appendChild(d);let $=null;const U=[];let x=!1;function F(){if(M(f.value))return f.value(w);if(f.value!==void 0&&!I(f.value))return f.value;const te=I(f.value)?f.value:f,ee=te.of,re=te.fn||"sum",se=te.show;return w?re==="count"?z().length:ee?se?q(String(ee),String(re),String(se)):C()==="filtered"&&w.statistics&&M(w.statistics.reduce)?w.statistics.reduce(String(ee),String(re)):_(z().map(de=>p(de,String(ee))),String(re)):null:null}function C(){return String(f.scope||"filtered")}function z(){if(!w||!w.rows)return[];const te=C();if(te==="all"){const re=[];return M(w.rows.forEachAll)&&w.rows.forEachAll(se=>{se.group||re.push(l(se))}),re}if(te==="selected")return(w.selection&&M(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(l);const ee=[];return M(w.rows.forEach)&&w.rows.forEach(re=>{re.group||ee.push(l(re))}),ee}function q(te,ee,re){if(ee!=="min"&&ee!=="max")return N(`stat.show.${ee}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ee}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,de=null;for(const ie of z()){const oe=Number(p(ie,te));Number.isFinite(oe)&&(se===null||(ee==="max"?oe>se:oe<se))&&(se=oe,de=ie)}return de===null?null:p(de,re)}function Q(te){if(M(f.format))return String(f.format(te,w));if(te==null)return f.empty??"—";const ee=I(f.value)?f.value:f,re=ee.show||ee.of;if((ee.show?!0:o.has(String(ee.fn||"sum")))&&w&&re&&M(w.columns?.get)){const de=w.columns.get(String(re));if(de&&M(de.formatValue))return de.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(f.decimals??2):String(te)}function Y(te){return te?(w&&w.messages||D).t(`stat.tone.${te}`):""}function J(){if(x)return;const te=F(),ee=r(f)&&!!w&&!s(w),re=ee?null:te,se=M(f.baseline)?f.baseline(w):f.baseline;$=re,j.textContent=f.title??"",j.hidden=!f.title,E.textContent=Q(re),P.hidden=!ee,ee&&(P.textContent=w.messages.t("stat.noData"));const de=ee||se===void 0||se===null?n:t(typeof re=="number"?re:null,Number(se)),ie=i(de.direction,f.goodWhen||"up");if(T.hidden=de.change===null,de.change!==null){const pe=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Me=de.percent===null?Q(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;T.textContent=`${pe} ${Me}`,T.setAttribute("data-tone",ie),T.setAttribute("data-direction",de.direction)}const oe=M(f.interval)?f.interval(re,w):null,ue=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);O.hidden=!ue,ue&&(O.textContent=`${Q(oe.lower)} – ${Q(oe.upper)}`,Number.isFinite(oe.confidence)&&O.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const ce=ee?c:f.bands?a(re,f.bands,w):null;ce?d.setAttribute("data-tone",ce):d.removeAttribute("data-tone"),A.textContent=M(f.footer)?String(f.footer(re,w)):f.footer??"",A.hidden=!A.textContent,d.setAttribute("aria-label",[f.title,E.textContent,ee?P.textContent:"",ue?O.textContent:"",de.change===null?"":T.textContent,de.change===null?"":Y(ie),A.textContent].filter(Boolean).join(", "))}if(w&&M(w.on)&&f.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ee=re=>{te==="model:changed"&&!B(re)||J()};w.on(te,ee),U.push(()=>M(w.off)&&w.off(te,ee))}return J(),{element:()=>d,value:()=>$,refresh:J,destroy(){x=!0;for(const te of U)try{te()}catch{}U.length=0,d.remove()}}}function l(g){return I(g)&&"data"in g?g.data:g}function p(g,f){if(!I(g))return;if(!f.includes("."))return g[f];let w=g;for(const S of f.split(".")){if(!I(w))return;w=w[S]}return w}function m(g,f){if(g&&typeof g=="object")return g;if(typeof g!="string")return null;const w=f&&f.element&&f.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(g):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),je("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isObject,N=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class _{#e;#t;#n;#r=null;#o=[];constructor({grid:B,document:G,kpis:D}){this.#e=B,this.#t=G,this.#n=Array.isArray(D)?D.filter(M):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const G=this.#t.createElement("div");G.className=`lattice ${W.band}`,G.setAttribute("role","group"),G.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=G;for(const D of this.#n){const v=N({...D,grid:this.#e,container:G});this.#o.push(v)}}destroy(){for(const B of this.#o)try{B.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),je("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const M=V("packages/core/src/index.js").createHeadlessGrid,N=V("packages/core/src/defaults.js").applyDefaults,_=V("packages/core/src/export/download.js").downloadBlob,H=V("packages/core/src/internal/util.js"),B=H.fail,G=H.isFunction,D=H.warnOnce,k=V("packages/dom/src/localviews.js").createLocalViewStorage,c=V("packages/dom/src/renderer/index.js").DomRenderer,n=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),i=t.icon,a=t.iconNames,s=V("packages/dom/src/editors/index.js").editors,l=V("packages/dom/src/filters/index.js").filters,p=V("packages/dom/src/ui/index.js"),m=p.StatusBar,b=p.TooltipManager,g=p.Pagination,f=p.GroupByZone,S=V("packages/dom/src/ui/celltooltip.js").CellTooltips,d=V("packages/dom/src/filtermenu.js").FilterMenu,E=V("packages/dom/src/columnmenu.js").ColumnMenu,T=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,$=V("packages/dom/src/alignedgrids.js").AlignedGrids,x=V("packages/dom/src/columntagbar.js").ColumnTagBar,C=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,Q=V("packages/dom/src/toolpanelmount.js"),Y=Q.ToolPanelDock,J=Q.panelHost,ee=V("packages/dom/src/celledit.js").CellEditController,se=V("packages/dom/src/editbar.js").EditBar,ie=V("packages/dom/src/rangeselect.js").RangeController,ue=V("packages/core/src/model/selection.js").resolveSelectionConfig,pe=V("packages/dom/src/importer.js").ImportController,$e=V("packages/dom/src/historybar.js").HistoryBar,ke=V("packages/dom/src/diffpaint.js").DiffPainter,Ee=V("packages/dom/src/detailhost.js").DetailHost,ze=V("packages/dom/src/highlightpaint.js").HighlightPainter,Xe=V("packages/dom/src/findpaint.js").FindPainter,Pe=V("packages/dom/src/findbar.js").FindBar,He=V("packages/dom/src/redactpaint.js").RedactionPainter,st=V("packages/dom/src/validationpaint.js").ValidationPainter,bt=V("packages/dom/src/presentation.js").PresentationController,Tt=V("packages/dom/src/capture.js").captureElement,It=V("packages/dom/src/annotate.js").AnnotationLayer,Yt=V("packages/dom/src/timelinebar.js").TimelineBar,fe=V("packages/dom/src/commentpaint.js").CommentPainter,xe=V("packages/dom/src/presencepaint.js").PresencePainter,_e=V("packages/dom/src/commentpanel.js").CommentPanel,gt=V("packages/dom/src/watermark.js").Watermark,Oe=V("packages/dom/src/maximise.js").Maximiser,Ne=V("packages/dom/src/promptbar.js").PromptBar,ve=V("packages/dom/src/kpistrip.js").KpiStrip;function Te(Le,rt,et){const it=rt==="redo"?"toolbar.redo":"toolbar.undo";return!et||!et.label?Le(it):Le(rt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:et.label})}const Ce=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Re=2e3;function Be(Le,rt,et){const it=rt.annotate===!0?We(Le):[];if(rt.actions===!1)return[];if(rt.actions===void 0&&rt.side!=="left")return it;const Et=Array.isArray(rt.actions)?rt.actions:Ce,Nt=(Ot,Vt)=>Le.messages.t(Ot,Vt),dt={undo:{name:"undo",title:()=>Te(Nt,"undo",Le.history.peek("undo")),icon:"undo",run:()=>Le.history.undo(),enabled:()=>Le.history.canUndo()},redo:{name:"redo",title:()=>Te(Nt,"redo",Le.history.peek("redo")),icon:"redo",run:()=>Le.history.redo(),enabled:()=>Le.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Le.export.csv({download:!0,fileName:rt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Le.export.excel({download:!0,fileName:rt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Le.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Le.export.print()},pause:{name:"pause",title:()=>{if(!Le.updates.paused)return Nt("toolbar.pause");const Ot=Le.updates.stats().pending;return Ot?Nt("toolbar.applyHeld",{count:Ot}):Nt("toolbar.resume")},icon:()=>Le.updates.paused?"play":"pause",run:()=>Le.updates.paused?Le.updates.resume():Le.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Le.state.reset(),enabled:()=>Le.state.modified()},maximise:{name:"maximise",title:()=>Nt(et&&et.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>et&&et.active()?"minimise":"maximise",run:()=>et.toggle()}};return et||delete dt.maximise,Et.map(Ot=>Ot==="-"?{name:"-",separator:!0}:typeof Ot=="string"?dt[Ot]:!Ot||typeof Ot!="object"||!Ot.name?null:{...Ot,run:G(Ot.run)?()=>Ot.run({grid:Le,keys:Le.selection&&G(Le.selection.keys)?Le.selection.keys():[],cells:Le.selection&&G(Le.selection.cells)?Le.selection.cells():[]}):void 0}).filter(Boolean).concat(it)}function We(Le){const rt=it=>Le.messages.t(it),et={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(it=>({name:it,title:()=>rt(`toolbar.annotate.${it}`),icon:et[it],run:()=>Le.annotate?.use(it),active:()=>Le.annotate?.tool===it,annotation:!0}))}const ft=["pen","arrow","rect","highlight"];function at(Le){return{rowCount:()=>{if(G(Le.rows.matchCount))return Le.rows.matchCount();const rt=Le.pagination&&G(Le.pagination.get)?Le.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:Le.rows.count()},totalRowCount:()=>G(Le.rows.totalCount)?Le.rows.totalCount():Le.rows.count(),selectedCount:()=>{const rt=Le.selection&&Le.selection.keys?Le.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=Le.selection;return!rt||!G(rt.cells)?[]:rt.cells().map(({key:et,colId:it})=>Le.rows.value(et,it))},hiddenUnresolved:()=>G(Le.comments&&Le.comments.hiddenUnresolved)?Le.comments.hiddenUnresolved():0,progress:()=>G(Le.source&&Le.source.progress)?Le.source.progress():null,updateStats:()=>Le.updates?Le.updates.stats():null}}function mt(Le,rt){for(const[et,it]of Object.entries(s||{}))Le.register("editor",et,it);for(const[et,it]of Object.entries(l||{}))Le.register("filter",et,it);for(const[et,it]of Object.entries(rt.components||{}))Le.register("component",et,it);for(const[et,it]of Object.entries(rt.pipes||{}))Le.register("pipe",et,it);for(const[et,it]of Object.entries(rt.totalFns||{}))Le.register("totalFn",et,it)}function ct(Le,rt,et,it,Et,Nt){const dt=[],Ot=rt.viewport;let Vt=null;if(et.maximise!==!1&&(Vt=new Oe({element:Nt,document:it,onChange:()=>rt.invalidate("all"),captureScroll:()=>rt.scrollState(),restoreScroll:tt=>rt.restoreScroll(tt)}),Le.maximise=Vt,dt.push(()=>Vt.destroy())),et.statusBar){const tt=typeof et.statusBar=="object"?et.statusBar:{},pt=new m;pt.init({document:it,host:at(Le),panels:tt.panels,registry:tt.registry,locale:Le.get("locale"),messages:Le.messages}),Ot.statusBar.appendChild(pt.element());const Pt=()=>{const nn=Ot.statusBar.offsetHeight||Ot.statusBar.getBoundingClientRect?.().height||0;Ot.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},$t=()=>{pt.refresh(),Pt()},Ht=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Le.on(nn,$t));$t(),Pt(),dt.push(()=>{for(const nn of Ht)nn();Ot.root.style.removeProperty("--lattice-status-height"),pt.destroy?.()})}const Wt=ue(et.selection);if(Wt.ranges){const tt=new ie({grid:Le,renderer:rt,document:it});tt.mount(),Le.ranges=tt,dt.push(()=>tt.destroy())}if(et.import){const tt=new pe({grid:Le,renderer:rt,document:it,settings:typeof et.import=="object"?et.import:{}});Le.importer=tt,dt.push(()=>tt.destroy())}if(et.historyBar){const tt=typeof et.historyBar=="object"?et.historyBar.element:null,pt=new $e;pt.init({document:it,host:{undo:()=>Le.history.undo(),redo:()=>Le.history.redo(),canUndo:()=>Le.history.canUndo(),canRedo:()=>Le.history.canRedo(),peek:$t=>Le.history.peek($t),list:()=>Le.history.list()},props:typeof et.historyBar=="object"?et.historyBar:{}}),(tt||Ot.root).appendChild(pt.element());const Pt=[Le.on("history:changed",()=>pt.refresh())];Le.historyBar=pt,dt.push(()=>{for(const $t of Pt)$t();pt.destroy()})}if(et.diff){const tt=new ke({grid:Le,renderer:rt});tt.mount(),Le.diffPainter=tt,dt.push(()=>tt.destroy())}if(et.ai&&G(et.ai.ask)){const tt=new Ne;tt.init({document:it,grid:Le,ask:et.ai.ask,schemaOptions:et.ai.schemaOptions,context:et.ai.context,placeholder:et.ai.placeholder});const pt=et.ai.element||Ot.root;pt===Ot.root?pt.insertBefore(tt.element(),pt.firstChild):pt.appendChild(tt.element()),Le.promptBar=tt,dt.push(()=>tt.destroy())}if(et.groupPanel){const tt=typeof et.groupPanel=="object"?et.groupPanel:{},pt=new f;pt.init({document:it,grid:Le,host:J(Le,it,(Pt,$t)=>rt.announce?.(Pt,$t)),props:{header:Ot.header,hint:tt.hint}}),Ot.root.insertBefore(pt.element(),Ot.header),Le.groupPanel=pt;for(const Pt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])G(Le.on)&&dt.push(Le.on(Pt,()=>pt.refresh()));dt.push(()=>pt.destroy())}if(et.kpis){const tt=new ve({grid:Le,document:it,kpis:et.kpis});tt.active&&(tt.mount(),Ot.root.insertBefore(tt.element(),Ot.header),Le.kpiStrip=tt,dt.push(()=>tt.destroy()))}if(et.toolPanel){const tt=typeof et.toolPanel=="object"?et.toolPanel:{},pt=new Y({grid:Le,document:it,root:Ot.root,panels:tt.panels,openPanel:tt.openPanel,side:tt.side,icons:tt.icons,actions:Be(Le,tt,Vt),announce:(Pt,$t)=>rt.announce?.(Pt,$t)});pt.mount(),Le.toolPanel=pt,dt.push(()=>pt.destroy()),tt.annotate===void 0&&(dt.push(Le.on("presentation:started",()=>{for(const Pt of We(Le))pt.addAction(Pt)})),dt.push(Le.on("presentation:ended",()=>{for(const Pt of ft)pt.removeAction(Pt)})))}if(et.pagination){const tt=typeof et.pagination=="object"?et.pagination:{},pt=new g;pt.init({document:it,pageSize:tt.pageSize,pageSizes:tt.pageSizes,page:tt.page,total:tt.total,locale:Le.get("locale"),messages:Le.messages,onChange:({page:Ht,pageSize:nn})=>Le.pagination.set({page:Ht,pageSize:nn})});const Pt=()=>{const Ht=Le.pagination.get();pt.total=Ht.total,pt.counting=Ht.counting===!0,pt.page=Ht.page,pt.paint()};Le.pagination.set({pageSize:pt.pageSize}),Pt();const $t=["rows:changed","filter:changed","model:changed"].map(Ht=>Le.on(Ht,Pt));Ot.statusBar.appendChild(pt.element()),dt.push(()=>{for(const Ht of $t)Ht();pt.destroy?.()})}if(et.edit!==!1)if(et.editBar){const tt=new se({grid:Le,document:it,root:Ot.root});tt.mount(),Le.editBar=tt,dt.push(()=>tt.destroy())}else{const tt=new ee({grid:Le,document:it,renderer:rt,registry:Et,cellLayer:rt.cellLayer});tt.mount(),dt.push(()=>tt.destroy())}const an=new d({grid:Le,document:it,layer:Ot.overlays,registry:Et});an.mount(),dt.push(()=>an.destroy());const ln=new E({grid:Le,document:it,host:Ot.root,cellMenu:et.contextMenu!==!1,headerMenu:et.columnMenu!==!1,items:G(et.contextMenu)?et.contextMenu:void 0,headerItems:G(et.columnMenu)?et.columnMenu:void 0});if(ln.mount(),dt.push(()=>ln.destroy()),Array.isArray(et.alignedGrids)&&et.alignedGrids.length){const tt=new $;tt.add(Le);for(const pt of et.alignedGrids)pt&&pt!==Le&&tt.add(pt);dt.push(()=>tt.destroy())}const zt=new q({grid:Le,renderer:rt,document:it,registry:Et});zt.active&&(zt.mount(),dt.push(()=>zt.destroy())),Object.defineProperty(Le,"form",{configurable:!0,value:Object.freeze({open(tt){return zt.active?zt.openRow(tt):!1},close(){zt.active&&zt.close()},save(){return zt.active?zt.save():!1},isOpen(){return zt.active?zt.open:!1}})}),dt.push(()=>{delete Le.form}),Object.defineProperty(Le,"icons",{configurable:!0,value:Object.freeze({get(tt){const pt=i(tt);return pt?{viewBox:pt.viewBox,paths:pt.paths.slice(),paint:pt.paint==="stroke"?"stroke":"fill"}:null},names(){return a()}})}),dt.push(()=>{delete Le.icons});const un=new x({grid:Le,renderer:rt,document:it});un.active&&(un.mount(),dt.push(()=>un.destroy()));const cn=new C({grid:Le,renderer:rt,document:it});cn.active&&(cn.mount(),dt.push(()=>cn.destroy()));const rn=new P({grid:Le,renderer:rt,document:it});if(rn.active){rn.mount(),rn.paint();const tt=Le.on("render:done",()=>rn.paint());dt.push(()=>{tt(),rn.destroy()})}if(et.shortcuts!==!1){const tt=new T({grid:Le,renderer:rt});tt.mount(),dt.push(()=>tt.destroy())}const jt=new ze({grid:Le,renderer:rt,window:it.defaultView||void 0});jt.mount(),dt.push(()=>jt.destroy());const Rt=new Xe({grid:Le,renderer:rt,window:it.defaultView||void 0});if(Rt.mount(),dt.push(()=>Rt.destroy()),et.find!==!1){const tt=new Pe({grid:Le,renderer:rt,document:it,settings:et.find});tt.mount(),dt.push(()=>tt.destroy())}const Ft=new He({grid:Le,renderer:rt});Ft.mount(),dt.push(()=>Ft.destroy());const Ut=new st({grid:Le,renderer:rt});Ut.mount(),dt.push(()=>Ut.destroy());const Qt=new bt({grid:Le,renderer:rt,maximiser:Vt});Qt.mount(),dt.push(()=>Qt.destroy());const qt=new Yt({grid:Le,renderer:rt});qt.mount(),dt.push(()=>qt.destroy()),et.environment||Le.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 Zt=null;for(const[tt,pt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])dt.push(Le.on(tt,()=>{Zt=pt}));dt.push(Le.on("render:done",tt=>{Le.diagnostics.render(Zt||tt.cause,tt.phases),Zt=null}));const en=new xe({grid:Le,renderer:rt});if(en.mount(),dt.push(()=>en.destroy()),dt.push(Le.on("presence:lockRefused",tt=>en.announceRefusal(tt.peer))),Le.presence&&Le.presence.enabled){for(const Pt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])dt.push(Le.on(Pt,()=>Le.presence.publish()));let tt="";dt.push(Le.on("render:done",()=>{const Pt=rt.focusState&&rt.focusState(),$t=Pt?`${Pt.rowKey}${Pt.colId}`:"";$t!==tt&&(tt=$t,Le.presence.publish())}));const pt=Nt.ownerDocument;if(pt&&G(pt.addEventListener)){const Pt=()=>Le.presence.setPaused(pt.visibilityState==="hidden");pt.addEventListener("visibilitychange",Pt),Pt(),dt.push(()=>pt.removeEventListener("visibilitychange",Pt))}}const Xt=new fe({grid:Le,renderer:rt});Xt.mount(),dt.push(()=>Xt.destroy());const dn=new _e({grid:Le,renderer:rt});dn.mount(),dt.push(()=>dn.destroy()),dt.push(Le.on("facet:computed",()=>rt.refreshHeader?.())),Wt&&Wt.headerCheckbox===!0&&dt.push(Le.on("selection:changed",()=>rt.refreshHeader?.())),dt.push(Le.on("facet:expanded",()=>rt.invalidate("columns"))),dt.push(Le.on("model:changed",()=>rt.invalidate("rows")));const Kt=(tt,pt)=>rt.announce?.(tt,pt),fn=Le.messages,Bt=(tt,pt)=>fn.t(tt,pt),pn=tt=>Bt("count.rows",{count:tt});dt.push(Le.on("sort:changed",()=>{const tt=Le.sort.get();if(!tt.length){Kt(Bt("a11y.sort.cleared"));return}const pt=tt.map(Pt=>{const $t=Le.columns.get(Pt.col);return Bt("a11y.sort.column",{column:$t&&$t.title||Pt.col,direction:Bt(Pt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Kt(Bt("a11y.sort.by",{columns:fn.list(pt)}))})),dt.push(Le.on("filter:changed",()=>{const tt=Le.rows.matchCount?Le.rows.matchCount():Le.rows.count(),pt=Le.rows.totalCount?Le.rows.totalCount():tt;Kt(tt===pt?Bt("a11y.filter.cleared",{rows:pn(pt)}):Bt("a11y.filter.applied",{shown:pn(tt),total:pn(pt)}))})),dt.push(Le.on("selection:changed",()=>{const tt=Le.selection.keys().length;Kt(tt===0?Bt("a11y.selection.cleared"):Bt("a11y.selection.count",{count:tt}))})),dt.push(Le.on("group:toggled",tt=>{const pt=Le.rows.byKey?Le.rows.byKey(tt.key):null,Pt=(pt&&(pt.groupLabel??pt.groupValue))??tt.key;Kt(Bt(tt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Pt,rows:pn(Le.rows.count())}))})),dt.push(Le.on("column:grouped",tt=>{const pt=Array.isArray(tt.columns)?tt.columns:[];if(!pt.length){Kt(Bt("a11y.group.cleared"));return}const Pt=pt.map($t=>{const Ht=Le.columns.get($t);return Ht&&Ht.title||$t});Kt(Bt("a11y.group.by",{columns:fn.list(Pt)}))})),dt.push(Le.on("page:changed",tt=>{const pt=Number(tt.size)||0,Pt=Number(tt.total)||0,$t=pt>0?Math.max(1,Math.ceil(Pt/pt)):1;Kt(Bt("a11y.page.position",{page:(Number(tt.page)||0)+1,pages:$t}))}));let tn={added:0,removed:0},_t=null;const En=()=>{_t=null;const tt=[];tn.added&&tt.push(Bt("count.rowsAdded",{count:tn.added})),tn.removed&&tt.push(Bt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},tt.length&&Kt(fn.list(tt))};dt.push(Le.on("rows:changed",tt=>{if(!tt||typeof tt.added!="number")return;const pt=Number(tt.added)||0,Pt=Number(tt.removed)||0;!pt&&!Pt||(tn.added+=pt,tn.removed+=Pt,_t||(_t=setTimeout(En,Re)))})),dt.push(()=>{_t&&clearTimeout(_t)}),dt.push(Le.on("rows:paused",()=>{_t&&(clearTimeout(_t),_t=null),tn={added:0,removed:0},Kt(Bt("a11y.updates.paused"),{repeat:!0})})),dt.push(Le.on("rows:resumed",()=>Kt(Bt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:tt,first:pt}=hn;if(hn={count:0,first:null},!tt||!pt)return;const Pt=Le.columns.get(pt.colId),$t=Pt&&Pt.title||pt.colId,Ht=pt.reason?Bt("a11y.edit.reason",{reason:pt.reason}):"";if(tt===1){const nn=pt.restored===void 0||pt.restored===null||pt.restored===""?Bt("value.empty"):String(pt.restored);Kt(Bt("a11y.edit.refusedOne",{column:$t,value:nn,reason:Ht}),{repeat:!0});return}Kt(Bt("a11y.edit.refusedMany",{count:tt,reason:Ht}),{repeat:!0})};dt.push(Le.on("cell:reverted",tt=>{!tt||!tt.applied||(hn.count+=1,hn.first||(hn.first=tt),mn||(mn=setTimeout(Sn,150)))})),dt.push(()=>{mn&&clearTimeout(mn)}),dt.push(Le.on("history:applied",tt=>{const pt=!!(tt&&tt.direction==="redo"),Pt=tt&&tt.step&&tt.step.label;Kt(Pt?Bt(pt?"a11y.history.redo":"a11y.history.undo",{label:Pt}):Bt(pt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new It({grid:Le,renderer:rt,seed:et.state&&Array.isArray(et.state.annotations)?et.state.annotations:null});gn.mount(),dt.push(()=>gn.destroy()),Le.annotate=gn,Le.capture=async(tt={})=>{const{blob:pt,width:Pt,height:$t}=await Tt(rt.viewport.root,tt);return(tt.download===!0||tt.download!==!1&&tt.fileName)&&_(pt,tt.fileName||`${Le.get("exportName")||"grid"}.png`),Le.emit("presentation:captured",{width:Pt,height:$t,bytes:pt.size,mimeType:pt.type,fileName:tt.fileName||null},"api"),pt};const On=new gt({grid:Le,document:it,element:Ot.overlays,window:it.defaultView||void 0});On.mount(),dt.push(()=>On.destroy());const Tn=new b({grid:Le,document:it,element:Ot.overlays});Tn.mount?.(),dt.push(()=>Tn.destroy?.());const jn=new S({grid:Le,host:Le.rendererHost(),viewport:Ot,document:it});return jn.mount(),dt.push(()=>jn.destroy()),dt}function vt(Le){const rt=[],et=it=>{if(it&&(it.__lattice&&rt.push(it),it.children))for(const Et of it.children)et(Et)};return et(Le),rt}function St(Le,rt={}){(!Le||typeof Le!="object"||!("appendChild"in Le))&&B("createGrid needs a host element as its first argument."),rt=N(rt);const et=Le.ownerDocument||(typeof document<"u"?document:null);et||B("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const it=et.documentElement&&et.documentElement.lang,Et=!rt.licence&&G(et.querySelector)?et.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...rt};if(!rt.locale&&it&&(Nt.locale=it),Et&&(Nt.licence=Et),rt.views&&rt.views.local)if(rt.views.storage)D("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const zt=rt.views.local===!0?{}:rt.views.local;Nt.views={...rt.views,storage:k(zt)}}const dt=M(Nt),Ot=dt.rendererHost();Ot.document=et,mt(Ot.registry,rt),Ot.cellLayer=n(Ot),Ot.detailHost=new Ee({grid:dt,document:Le.ownerDocument||globalThis.document,createGrid:(zt,un)=>St(zt,un)});const Vt=new c(Le,Ot),Wt=dt.on("detail:toggled",()=>{Ot.detailHost.syncTarget(),Ot.detailHost.prune()}),sn=dt.on("config:changed",zt=>{zt&&zt.key==="detail"&&Ot.detailHost.reconfigure()});dt.on("destroy",()=>{Wt(),sn(),Ot.detailHost.destroy()}),Ot.detailHost.syncTarget(),dt.attachRenderer(Vt),Vt.mount();const an=ct(dt,Vt,rt,et,Ot.registry,Le),ln=dt.destroy.bind(dt);return dt.destroy=()=>{for(const zt of an)try{zt()}catch{}Le.__lattice===dt&&(Le.__lattice=null),ln()},Le.__lattice=dt,dt}}),je("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return n}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,H=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,G=V("packages/dom/src/createGrid.js").createGrid,D=new Set([...Object.keys(W),...Object.keys(H)]);function v(t,i){for(const a of t.children)if(a.tagName===i.toUpperCase())return a;return null}function k(t,i){const a=[];for(const r of t.children)r.tagName===i.toUpperCase()&&a.push(r);return a}function y(t,i){const a=M(t.getAttribute)?t.getAttribute("data-field"):null;return a||String(t.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${i}`}function c(t){const i=t.trim();if(i==="")return null;if(i==="true"||i==="false")return i==="true";const a=Number(i);return Number.isFinite(a)&&i!==""?a:i}function o(t){const i=v(t,"thead"),a=v(i||t,"tr"),s=(a?k(a,"th").length?k(a,"th"):k(a,"td"):[]).map((m,b)=>{const g=y(m,b),f={id:g,field:g,title:String(m.textContent||"").trim()||g},w=M(m.getAttribute)?m.getAttribute("data-type"):null;w&&(D.has(w)?f.type=w:I(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${g}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const S=M(m.getAttribute)?m.getAttribute("data-format"):null;return S&&(f.format=S),f}),u=v(t,"tbody"),p=(u?k(u,"tr"):k(t,"tr").filter(m=>m!==a)).map((m,b)=>{const g=k(m,"td"),w={__row:(M(m.getAttribute)?m.getAttribute("data-id"):null)||`row${b}`};return s.forEach((S,h)=>{w[S.field]=g[h]?c(String(g[h].textContent||"")):null}),w});return{columns:s,rows:p}}function n(t,i={}){const{columns:a,rows:r}=o(t),s=t.ownerDocument.createElement("div");return t.parentNode.insertBefore(s,t),t.parentNode.removeChild(t),G(s,{rowKey:"__row",columns:a,rows:r,...i,columns:i.columns!==void 0?i.columns:a,rows:i.rows!==void 0?i.rows:r})}}),je("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return D}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/dom/src/createGrid.js").createGrid,_=V("packages/dom/src/hydrate.js").hydrateTable;function H(v,k){const y=[];return M(v.hasAttribute)&&v.hasAttribute(k)&&y.push(v),M(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${k}]`)),y}function B(v){const k=v.parentNode;if(!k||!k.children)return null;const y=[...k.children],c=y.indexOf(v),o=[y[c+1],y[c-1]];for(const n of o)if(n&&n.tagName==="SCRIPT"&&M(n.getAttribute)&&n.hasAttribute("data-lattice-config"))return n;return null}function G(v){const k=B(v);if(!k)return{};try{return JSON.parse(k.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function D(v){const k=v||(typeof document<"u"?document:null);if(!k)return[];const y=[];for(const c of H(k,"data-lattice-grid")){if(c.__lattice)continue;const o=G(c);y.push(c.tagName==="TABLE"?_(c,o):N(c,o))}return y}}),je("packages/modules/htmx/controller.js",function(e,V){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return N}});const M=V("packages/core/src/internal/util.js").isFunction;function I(W,_){if(!W||!M(_))return 0;let H=0;for(const B of _(W))B.__lattice&&M(B.__lattice.destroy)&&(B.__lattice.destroy(),H+=1);return H}function N(W,_){return!W||!M(_)?[]:_(W)}}),je("packages/modules/htmx/history.js",function(e,V){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return B}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/core/src/model/state.js"),N=I.serialiseState,W=I.restoreState;function _(G,D){const v=[];return G&&(M(G.hasAttribute)&&G.hasAttribute(D)&&v.push(G),M(G.querySelectorAll)&&v.push(...G.querySelectorAll(`[${D}]`))),v}function H(G,D){if(!G||!M(D))return 0;let v=0;for(const k of D(G))!k.__lattice||!M(k.setAttribute)||(k.setAttribute("data-lattice-state",N(k.__lattice)),v+=1);return v}function B(G,D){if(!G)return 0;const v=_(G,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of v)for(;y.firstChild;)y.removeChild(y.firstChild);v.length&&M(D)&&D(G);let k=0;for(const y of _(G,"data-lattice-state")){const c=M(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!c||!y.__lattice||(W(y.__lattice,c),k+=1)}return k}}),je("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 H}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return D}});const Z=V("packages/dom/src/hydrate.js"),M=Z.coerceCell,I=Z.childTags,N=Z.firstChildTag,W=5e3;function _(v,k={}){const y=v.pagination.get(),c=k.limit??(y.pageSize||100);return{offset:k.offset??(y.page??0)*c,limit:c,sort:JSON.stringify(v.sort.get()),filters:JSON.stringify(v.filters.get())}}function H(v,k){let y;if(v.tagName==="TR")y=[v];else{const c=N(v,"tbody")||v;y=I(c,"tr").length?I(c,"tr"):I(v,"tr")}return y.map((c,o)=>{const n=I(c,"td"),i={__row:(typeof c.getAttribute=="function"?c.getAttribute("data-id"):null)||`row${o}`};return k.forEach((a,r)=>{i[a.field]=n[r]?M(String(n[r].textContent||"")):null}),i})}function B(v){const k=JSON.parse(v);return Array.isArray(k)?{rows:k,total:void 0}:{rows:k.rows||[],total:k.total}}function G(v){v<=W||console.warn(`lattice-grid/htmx: parsed ${v} rows from an HTML fragment, past the documented ${W}-row boundary for that path. Consider a JSON response for this size.`)}function D(v,k){if(/json/i.test(v.contentType||""))return B(v.text);const c=H(v.fragment,k);return G(c.length),{rows:c,total:void 0}}}),je("packages/modules/htmx/oob.js",function(e,V){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(_,H={}){const B=H.doc||(typeof document<"u"?document:null);if(!B||!M(B.addEventListener))return()=>{};const G=D=>{const v=D.detail,k=v&&v.target,y=k&&M(k.getAttribute)?k.getAttribute("data-lattice-row"):null;if(!y||!v.fragment)return;const c=H.columns||_.columns.visible().map(n=>({field:n.field||n.id})),[o]=N(v.fragment,c);o&&(delete o.__row,_.rows.apply({update:[{...o,[_.get("rowKey")]:y}]})),v.shouldSwap=!1};return B.addEventListener("htmx:oobBeforeSwap",G),()=>B.removeEventListener("htmx:oobBeforeSwap",G)}}),je("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 G}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return D}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/modules/htmx/rowmodel.js"),N=I.queryParams,W=I.ingestResponse,_="lattice:query-changed";function H(v,k){const y=v.createElement("tbody");if(M(v.createRange)){const c=v.createRange();c.selectNodeContents(y),y.appendChild(c.createContextualFragment(k))}return y}function B(v,k,y={}){const c=k.ownerDocument;let o=!1;const n=l=>{l.target!==k||!l.detail||!l.detail.parameters||Object.assign(l.detail.parameters,N(v,y))},t=l=>{l.target===k&&(o=!0)},i=l=>{if(o=!1,l.target!==k)return;const p=l.detail&&l.detail.xhr&&l.detail.xhr.status,m=p?`Could not load rows (server responded ${p}).`:"Could not load rows, the request failed to reach the server.";v.overlay.show("empty",m)},a=l=>{if(l.target!==k||(o=!1,l.detail&&(l.detail.shouldSwap=!1),!l.detail||!l.detail.xhr||l.detail.isError))return;const{xhr:p}=l.detail,m=M(p.getResponseHeader)&&p.getResponseHeader("Content-Type")||"",b=l.detail.serverResponse??p.responseText??"",g=y.columns||v.columns.visible().map(S=>({field:S.field||S.id})),f=/json/i.test(m)?null:H(c,b),{rows:w}=W({contentType:m,text:b,fragment:f},g);v.rows.load(w)},r=()=>{if(o&&M(k.dispatchEvent)){const p=c.defaultView&&c.defaultView.CustomEvent;k.dispatchEvent(p?new p("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const l=globalThis.htmx;l&&M(l.trigger)&&l.trigger(k,_)};c.addEventListener("htmx:configRequest",n),c.addEventListener("htmx:beforeRequest",t),c.addEventListener("htmx:beforeSwap",a),c.addEventListener("htmx:responseError",i),c.addEventListener("htmx:sendError",i);const s=v.on("sort:changed",r),u=v.on("filter:changed",r);return()=>{c.removeEventListener("htmx:configRequest",n),c.removeEventListener("htmx:beforeRequest",t),c.removeEventListener("htmx:beforeSwap",a),c.removeEventListener("htmx:responseError",i),c.removeEventListener("htmx:sendError",i),s(),u()}}const G="lattice:scroll-near-end";function D(v,k,y={}){const c=k.ownerDocument,o=y.threshold??20;let n=!1,t=!1;const i=h=>{h.target!==k||!h.detail||!h.detail.parameters||Object.assign(h.detail.parameters,N(v,{...y,offset:v.rows.count()}))},a=h=>{h.target===k&&(n=!0)},r=h=>{h.target===k&&(n=!1)},s=h=>{if(h.target!==k||(n=!1,h.detail&&(h.detail.shouldSwap=!1),!h.detail||!h.detail.xhr||h.detail.isError))return;const{xhr:d}=h.detail,j=M(d.getResponseHeader)&&d.getResponseHeader("Content-Type")||"",E=h.detail.serverResponse??d.responseText??"",O=y.columns||v.columns.visible().map(P=>({field:P.field||P.id})),T=/json/i.test(j)?null:H(c,E),{rows:A}=W({contentType:j,text:E,fragment:T},O);if(!A.length){t=!0;return}v.rows.apply({add:A})},u=()=>{t=!1},l=()=>{if(n||t)return;const h=globalThis.htmx;h&&M(h.trigger)&&h.trigger(k,G)};let p=!1;const m=()=>{p=!0},b=({last:h})=>{p&&(p=!1,(v.rows.count()===0||h>=v.rows.count()-1-o)&&l())};c.addEventListener("htmx:configRequest",i),c.addEventListener("htmx:beforeRequest",a),c.addEventListener("htmx:beforeSwap",s),c.addEventListener("htmx:responseError",r),c.addEventListener("htmx:sendError",r);const g=v.on("render:done",b),f=v.on("scroll",m),w=v.on("sort:changed",u),S=v.on("filter:changed",u);return()=>{c.removeEventListener("htmx:configRequest",i),c.removeEventListener("htmx:beforeRequest",a),c.removeEventListener("htmx:beforeSwap",s),c.removeEventListener("htmx:responseError",r),c.removeEventListener("htmx:sendError",r),g(),f(),w(),S()}}}),je("packages/modules/htmx/index.js",function(e,V){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/dom/src/createGrid.js"),N=I.gridElementsWithin,W=V("packages/dom/src/autoinit.js"),_=W.autoInit,H=V("packages/modules/htmx/controller.js"),B=H.destroyWithin,G=H.initWithin,D=V("packages/modules/htmx/history.js"),v=D.saveStateWithin,k=D.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return I.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return I.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 c=V("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return c.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return c.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 n=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return n.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n.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 H.destroyWithin}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return H.initWithin}}),Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return D.saveStateWithin}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return D.restoreStateWithin}});const i=V("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return i.driveOobUpdates}});const a=V("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return a.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return a.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return a.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return a.SCROLL_NEAR_END_EVENT}});const r=V("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return r.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return r.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return r.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return r.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return r.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return r.HTML_ROW_WARNING_THRESHOLD}});function s(l){const p=l||(typeof document<"u"?document:null);if(!p||!M(p.addEventListener))return()=>{};const m=w=>B(w.target,N),b=w=>G(w.detail&&w.detail.elt||w.target,_),g=w=>{v(w.detail&&w.detail.historyElt||p,N)},f=w=>{w.detail&&w.detail.cacheMiss||k(p,_)};return p.addEventListener("htmx:beforeCleanupElement",m),p.addEventListener("htmx:load",b),p.addEventListener("htmx:beforeHistorySave",g),p.addEventListener("htmx:historyRestore",f),()=>{p.removeEventListener("htmx:beforeCleanupElement",m),p.removeEventListener("htmx:load",b),p.removeEventListener("htmx:beforeHistorySave",g),p.removeEventListener("htmx:historyRestore",f)}}s();const u=s});try{Un("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),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 m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),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 g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.74.0";async function he(){return fe}const X="1.74.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).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(/^./,q=>q.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=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"}),x=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(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?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class ue{#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 oe{#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 m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,m=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 d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=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:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=Y(s[f]);return u}function Q(){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 _(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=c=>{if(!_(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,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),this.#e=new Uint32Array(z+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(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(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:(z(`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 T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.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 T.set(s,f),f}function re(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(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 J(i){return!i||!i.presence?null:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(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 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,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(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 Q(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 _(i){const s=he(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 Q(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),m=f instanceof Date?f.getTime():Number(f);return Q(a,m)}return X(u,f)}}function C(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=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"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 m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),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 fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,X=fe.isFunction,z=fe.pathGetter,x=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return M(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function c(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let l=d;l<h;l++)n[l-d]=r[m.values[l]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=X(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new oe(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,g]of r)e[l]!==Y&&n.set(e[l],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==Y&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new x(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new x(d)),this.#p=d}#A(e,d){const h=M(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),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]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new x(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Q:0,this.#w=d.compactRatio??_;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let l=0;l<r;l++)this.#r[h+l]=d[l];this.#i=h+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 g=n.get(l.id);g?l.appendPacked(g,h,r):l.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(Math.max(this.#s,r)),h}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 h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(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 m=0;m<M.length;m++){const e=M[m];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 oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);return{readers:u,reset(){h=new WeakMap}}}class L{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 Q{#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={...J,...u};const f=s.columns??[];this.#r=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(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=he(),{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&&he()-i<s);return this.#o+=he()-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 m=this.#r.readers.get(a.id)??(x(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);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 d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`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(d))}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 _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),!g&&l&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),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&&d(n),r[n]=l}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,X=fe.warnOnce,z=["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=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`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: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(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=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(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 J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.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,m=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 d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>h.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,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(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=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(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,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(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,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${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 C(M,i){const s=he(M)||M===""?null:String(M),u=he(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,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const H=x(p);return H===null?u(p):H}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;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<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),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 d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="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 P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(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 g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,l){const g=new Date(n);switch(l){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===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;C<f?(c=Math.sqrt(-2*Math.log(C)),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)):C<=1-f?(c=C-.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-C)),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*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const M=Math.abs(C),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 m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});class fe{#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(L){if(!Number.isFinite(L))return;this.#t++;const Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}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 L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}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(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.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"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"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 m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),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 P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),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 ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),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 Ge}}),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 lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("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:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=c(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).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 G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+N*(b-y[0]))))}if(b>=y[2]){const N=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+N*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,Oe=be)}return Oe}function Re(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of N)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,N)=>k+N,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const N=Qe(y),I=T(1-(1-N)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:N}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"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 m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(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:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=Object.freeze({...J,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 m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(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 L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(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=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,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 F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${m.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,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(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 Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,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=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(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,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(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=oe(i,c,f[t],u);return c}function oe(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",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(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=>L(i,a,u,f));const t=c.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m: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 C(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,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"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 x}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),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 he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}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 m=t.method||"modifiedZScore";if(!(re.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=x.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function M(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.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(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const te=me("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 x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),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 fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(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!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Je=Un("packages/modules/htmx/index.js"),_i=Je.createGrid,Zi=Je.gridElementsWithin,Yi=Je.readTable,Xi=Je.hydrateTable,Qi=Je.autoInit,Ji=Je.serialiseState,eo=Je.restoreState,to=Je.createHeadlessGrid,no=Je.version,ro=Je.getVersion,io=Je.Grid,oo=Je.EventBus,so=Je.Registry,ao=Je.sharedRegistry,lo=Je.registerModules,uo=Je.parseLicence,co=Je.verifyLicence,fo=Je.licenceInfo,ho=Je.watermark,mo=Je.setLicence,po=Je.licenceState,go=Je.isLocalHost,yo=Je.matchesDomain,bo=Je.LicenceHolder,wo=Je.ColumnModel,vo=Je.buildGraph,ko=Je.Lookup,So=Je.ValuePipeline,Oo=Je.compileFormat,jo=Je.compileMask,Ao=Je.specToOoxml,Po=Je.EXTENDED_TYPES,Co=Je.createRadixType,Eo=Je.RADIX_PRESETS,To=Je.parseRadix,Mo=Je.formatRadix,No=Je.createUnitType,Ro=Je.registerUnitSystem,Lo=Je.defineUnit,Fo=Je.UNIT_SYSTEMS,xo=Je.parseUnit,Do=Je.formatUnit,Io=Je.createCurrencyType,$o=Je.parseMoney,zo=Je.formatMoney,Bo=Je.convertMoney,Uo=Je.rateFunction,Ho=Je.MISSING_RATE,Vo=Je.Messages,Go=Je.createMessages,Ko=Je.auditCatalogue,Wo=Je.EN_GB,qo=Je.MESSAGE_KEYS,_o=Je.DEFAULT_LOCALE,Zo=Je.formatList,Yo=Je.resolveLocale,Xo=Je.LOCALES,Qo=Je.resolveCatalogue,Jo=Je.EN_US,es=Je.FR_FR,ts=Je.FR_CA,ns=Je.IT_IT,rs=Je.ES_ES,is=Je.PT_BR,os=Je.DE_DE,ss=Je.NL_NL,as=Je.SV_SE,ls=Je.DA_DK,us=Je.NB_NO,cs=Je.FI_FI,ds=Je.PL_PL,fs=Je.CS_CZ,hs=Je.HU_HU,ms=Je.RO_RO,ps=Je.UK_UA,gs=Je.EL_GR,ys=Je.JA_JP,bs=Je.AR,ws=Je.AR_SA,vs=Je.ColumnStore,ks=Je.Bitset,Ss=Je.Dictionary,Os=Je.MultiValue,js=Je.MaskPool,As=Je.sortColumn,Ps=Je.sortMulti,Cs=Je.evaluateFilters,Es=Je.compact,Ts=Je.testValue,Ms=Je.groupByColumns,Ns=Je.total,Rs=Je.TOTAL_FNS,Ls=Je.pivot,Fs=Je.Window,xs=Je.openWindow,Ds=Je.WINDOW_KINDS,Is=Je.evaluateFormula,$s=Je.parseFormula,zs=Je.referencesOf,Bs=Je.looksLikeFormula,Us=Je.FormulaError,Hs=Je.FUNCTIONS,Vs=Je.compileRules,Gs=Je.ingest,Ks=Je.ingestSync,Ws=Je.createSource,qs=Je.createMemorySource,_s=Je.createPagedSource,Zs=Je.createRemoteSource,Ys=Je.createStreamSource,Xs=Je.PROTOCOL,Qs=Je.createPushdownSource,Js=Je.planQuery,ea=Je.splitFilters,ta=Je.applyResidual,na=Je.capabilitiesOf,ra=Je.resolveMutate,ia=Je.NO_CAPABILITIES,oa=Je.odataAdapter,sa=Je.filtersToOData,aa=Je.conditionToOData,la=Je.restAdapter,ua=Je.DEFAULT_PARAMS,ca=Je.dfqlAdapter,da=Je.duckdbAdapter,fa=Je.filtersToSql,ha=Je.RowModel,ma=Je.createRowKey,pa=Je.SelectionModel,ga=Je.RangeModel,ya=Je.EditModel,ba=Je.ChangeModel,wa=Je.StateModel,va=Je.STATE_VERSION,ka=Je.VERSION,Sa=Je.createStat,Oa=Je.deltaOf,ja=Je.toneOf,Aa=Je.setLicense,Pa=Je.licenseInfo,Ca=Je.licenseState,Ea=Je.destroyWithin,Ta=Je.initWithin,Ma=Je.saveStateWithin,Na=Je.restoreStateWithin,Ra=Je.driveOobUpdates,La=Je.driveServerMode,Fa=Je.driveInfiniteScroll,xa=Je.QUERY_CHANGED_EVENT,Da=Je.SCROLL_NEAR_END_EVENT,Ia=Je.queryParams,$a=Je.rowsFromFragment,za=Je.rowsFromJson,Ba=Je.ingestResponse,Ua=Je.warnIfLargeHtmlPayload,Ha=Je.HTML_ROW_WARNING_THRESHOLD,Va=Je.attach;var Ga=Je.default;export{bs as AR,ws as AR_SA,ks as Bitset,fs as CS_CZ,ba as ChangeModel,wo as ColumnModel,vs as ColumnStore,ls as DA_DK,_o as DEFAULT_LOCALE,ua as DEFAULT_PARAMS,os as DE_DE,Ss as Dictionary,gs as EL_GR,Wo as EN_GB,Jo as EN_US,rs as ES_ES,Po as EXTENDED_TYPES,ya as EditModel,oo as EventBus,cs as FI_FI,ts as FR_CA,es as FR_FR,Hs as FUNCTIONS,Us as FormulaError,io as Grid,Ha as HTML_ROW_WARNING_THRESHOLD,hs as HU_HU,ns as IT_IT,ys as JA_JP,Xo as LOCALES,bo as LicenceHolder,ko as Lookup,qo as MESSAGE_KEYS,Ho as MISSING_RATE,js as MaskPool,Vo as Messages,Os as MultiValue,us as NB_NO,ss as NL_NL,ia as NO_CAPABILITIES,ds as PL_PL,Xs as PROTOCOL,is as PT_BR,xa as QUERY_CHANGED_EVENT,Eo as RADIX_PRESETS,ms as RO_RO,ga as RangeModel,so as Registry,ha as RowModel,Da as SCROLL_NEAR_END_EVENT,va as STATE_VERSION,as as SV_SE,pa as SelectionModel,wa as StateModel,Rs as TOTAL_FNS,ps as UK_UA,Fo as UNIT_SYSTEMS,ka as VERSION,So as ValuePipeline,Ds as WINDOW_KINDS,Fs as Window,ta as applyResidual,Va as attach,Ko as auditCatalogue,Qi as autoInit,vo as buildGraph,na as capabilitiesOf,Es as compact,Oo as compileFormat,jo as compileMask,Vs as compileRules,aa as conditionToOData,Bo as convertMoney,Io as createCurrencyType,_i as createGrid,to as createHeadlessGrid,qs as createMemorySource,Go as createMessages,_s as createPagedSource,Qs as createPushdownSource,Co as createRadixType,Zs as createRemoteSource,ma as createRowKey,Ws as createSource,Sa as createStat,Ys as createStreamSource,No as createUnitType,Ga as default,Lo as defineUnit,Oa as deltaOf,Ea as destroyWithin,ca as dfqlAdapter,Fa as driveInfiniteScroll,Ra as driveOobUpdates,La as driveServerMode,da as duckdbAdapter,Cs as evaluateFilters,Is as evaluateFormula,sa as filtersToOData,fa as filtersToSql,Zo as formatList,zo as formatMoney,Mo as formatRadix,Do as formatUnit,ro as getVersion,Zi as gridElementsWithin,Ms as groupByColumns,Xi as hydrateTable,Gs as ingest,Ba as ingestResponse,Ks as ingestSync,Ta as initWithin,go as isLocalHost,fo as licenceInfo,po as licenceState,Pa as licenseInfo,Ca as licenseState,Bs as looksLikeFormula,yo as matchesDomain,oa as odataAdapter,xs as openWindow,$s as parseFormula,uo as parseLicence,$o as parseMoney,To as parseRadix,xo as parseUnit,Ls as pivot,Js as planQuery,Ia as queryParams,Uo as rateFunction,Yi as readTable,zs as referencesOf,lo as registerModules,Ro as registerUnitSystem,Qo as resolveCatalogue,Yo as resolveLocale,ra as resolveMutate,la as restAdapter,eo as restoreState,Na as restoreStateWithin,$a as rowsFromFragment,za as rowsFromJson,Ma as saveStateWithin,Ji as serialiseState,mo as setLicence,Aa as setLicense,ao as sharedRegistry,As as sortColumn,Ps as sortMulti,Ao as specToOoxml,ea as splitFilters,Ts as testValue,ja as toneOf,Ns as total,co as verifyLicence,no as version,Ua as warnIfLargeHtmlPayload,ho as watermark};
|
|
56
|
+
`)||(l.preventDefault(),this.fromText(p))})))}openFile(){const u=k(this.#n,"input",{attrs:{type:"file",accept:a}});u.style.display="none",this.#o.push(c(u,"change",()=>{const l=u.files&&u.files[0];l&&this.#c(l),u.parentNode&&u.parentNode.removeChild(u)})),this.#n.body.appendChild(u),u.click()}#c(u){if(M(u.arrayBuffer)){u.arrayBuffer().then(p=>{const m=new Uint8Array(p);if(D(m)){this.fromXlsx(m,u.name);return}this.fromText(new TextDecoder().decode(m),u.name)});return}if(M(u.text)){u.text().then(p=>this.fromText(p,u.name));return}const l=new this.#n.defaultView.FileReader;l.onload=()=>this.fromText(String(l.result||""),u.name),l.readAsText(u)}async fromXlsx(u,l){const{header:p,rows:m}=await G(u);if(!p.length)return;const b=H(p,m,{columns:this.#e.columns.all()}),g=m.filter(f=>f.length!==p.length).length;this.#l={rows:m,columns:b,delimiter:null,name:l,warnings:g?[`${g} row(s) do not have ${p.length} columns`]:[]},this.#d()}fromText(u,l){const{header:p,rows:m,delimiter:b}=_(u);if(!p.length)return;const g=H(p,m,{columns:this.#e.columns.all()}),f=m.filter(w=>w.length!==p.length).length;this.#l={rows:m,columns:g,delimiter:b,name:l,warnings:f?[`${f} row(s) do not have ${p.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const u=this.#i.querySelector(i);u&&M(u.focus)&&u.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(u,l){const p=this.#t&&this.#t.announce;M(p)&&p.call(this.#t,u,l)}#f(u,l){return(this.#e&&this.#e.messages?this.#e.messages:N).t(u,l)}#m(){const u=this.#n,l=k(u,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),p=k(u,"div",{class:`${t}__panel`});p.appendChild(k(u,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#s=k(u,"div",{class:`${t}__body`}),p.appendChild(this.#s);const m=k(u,"div",{class:`${t}__footer`}),b=k(u,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),g=k(u,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(c(b,"click",()=>this.close())),this.#o.push(c(g,"click",()=>this.#g())),m.appendChild(b),m.appendChild(g),p.appendChild(m),l.appendChild(p),this.#o.push(c(l,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const S=[...l.querySelectorAll(i)].filter(j=>!j.hidden);if(!S.length)return;const h=S[0],d=S[S.length-1];w.shiftKey&&this.#n.activeElement===h?(w.preventDefault(),d.focus()):!w.shiftKey&&this.#n.activeElement===d&&(w.preventDefault(),h.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(l),this.#i=l}#p(){const u=this.#n,l=y(this.#s),{rows:p,columns:m,name:b,warnings:g}=this.#l;l.appendChild(k(u,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:p.length,name:b||this.#f("import.clipboard")})}));for(const j of g)l.appendChild(k(u,"p",{class:`${t}__warning`,text:j}));const f=this.#e.columns.all().map(j=>j.field||j.id).filter(Boolean),w=k(u,"table",{class:`${t}__map`}),S=k(u,"tr",{});for(const j of["import.colSource","import.colField","import.colType"])S.appendChild(k(u,"th",{text:this.#f(j)}));w.appendChild(S),m.forEach((j,E)=>{const O=k(u,"tr",{});O.appendChild(k(u,"td",{text:j.source}));const T=k(u,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:j.source})}});T.appendChild(k(u,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of f)T.appendChild(k(u,"option",{text:P,attrs:{value:P,selected:P===j.field?!0:null}}));j.field&&!f.includes(j.field)&&T.appendChild(k(u,"option",{text:j.field,attrs:{value:j.field,selected:!0}}));const A=k(u,"td",{});A.appendChild(T),O.appendChild(A),O.appendChild(k(u,"td",{class:`${t}__type`,text:j.type})),w.appendChild(O)}),l.appendChild(w);const h=k(u,"div",{class:`${t}__mode`}),d=k(u,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});d.appendChild(k(u,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),d.appendChild(k(u,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),h.appendChild(k(u,"label",{text:this.#f("import.modeLabel")})),h.appendChild(d),l.appendChild(h)}#g(){const{rows:u,columns:l}=this.#l;for(const f of this.#i.querySelectorAll("select[data-col]")){const w=Number(f.getAttribute("data-col"));l[w]&&f.value!==void 0&&f.value!==null&&(l[w].field=f.value)}const p=this.#i.querySelector("select[data-mode]"),m=p?p.value:void 0,b=m==="replace"||m==="append"?m:this.#r.mode,g=B(u,l);this.#e.import.apply(g,{mode:b}),this.close(),this.#h(this.#f("import.done",{count:g.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&M(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const u of this.#o)u();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),je("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,H=W.on,B=W.clear,G=W.documentFor,D="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(c,o){return(this.messages&&typeof this.messages.t=="function"?this.messages:N).t(c,o)}init(c){this.messages=c&&c.messages||c&&c.grid&&c.grid.messages||N;const o=c||{};if(this.doc=G(o),this.host=o.host||{},this.props=o.props||{},this.root=_(this.doc,"div",{class:["lattice-tokens",D],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 n=_(this.doc,"button",{class:`${D}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(H(n,"click",()=>this.toggle())),this.root.appendChild(n),this.toggleButton=n,this.menu=_(this.doc,"div",{class:`${D}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(c,o,n){const t=_(this.doc,"button",{class:`${D}__${c}`,attrs:{type:"button"},children:[_(this.doc,"span",{class:`${D}__glyph`,text:n,attrs:{"aria-hidden":"true"}}),_(this.doc,"span",{class:`${D}__label`,text:o})]});return this.off.push(H(t,"click",()=>{const i=this.host[c];M(i)&&i(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const c=this.host,o=M(c.canUndo)?c.canUndo():!1,n=M(c.canRedo)?c.canRedo():!1,t=M(c.peek)?c.peek("undo"):null,i=M(c.peek)?c.peek("redo"):null;this.#t(this.undoButton,"undo",o,t),this.#t(this.redoButton,"redo",n,i),this.open&&this.#n()}#t(c,o,n,t){if(!c)return;c.disabled=!n;const i=o==="undo",a=this.t(i?"history.undo":"history.redo"),r=c.querySelector(`.${D}__label`);r&&(r.textContent=a);const s=t&&t.label?this.t("history.described",{action:a,label:t.label}):a;c.setAttribute("title",n?s:this.t(i?"history.nothingToUndo":"history.nothingToRedo")),c.setAttribute("aria-label",n?s:this.t(i?"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 c=this.menu;if(!c)return;B(c);const o=M(this.host.list)?this.host.list():[];if(!o.length){c.appendChild(_(this.doc,"p",{class:`${D}__empty`,text:this.t("history.empty")}));return}o.forEach((n,t)=>{const i=_(this.doc,"button",{class:`${D}__item`,attrs:{type:"button",role:"menuitem","data-type":n.type,"data-undone":n.undone?"true":null},children:[_(this.doc,"span",{class:`${D}__kind`,text:n.type}),_(this.doc,"span",{class:`${D}__text`,text:n.label||n.type})]});this.off.push(H(i,"click",()=>{const a=t+1;for(let r=0;r<a;r++)M(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),c.appendChild(i)})}destroy(){for(const c of this.off)c();this.off=[],this.root&&M(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const k=v}),je("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,_={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",B="lat-cell--added-column";class G{#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 c=this.#e.diff,o=c&&c.enabled;for(const n of y.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key"),i=o?c.statusOf(t):"unchanged";for(const r of Object.values(_))n.classList.remove(r);o&&_[i]&&n.classList.add(_[i]),n.setAttribute("data-diff",o?i:"");const a=o&&i==="changed";for(const r of n.querySelectorAll("[data-col]")){const s=r.getAttribute("data-col");if(r.classList.remove(H,B),r.removeAttribute("data-before"),!a)continue;const u=c.cellStatus(t,s);if(u==="changed"){r.classList.add(H);const l=this.#r(c,t,s);l===null?r.removeAttribute("title"):(r.setAttribute("data-before",l),r.setAttribute("title",this.#o("diff.before",{value:l})))}else u==="added-column"&&r.classList.add(B)}}}#r(y,c,o){const n=this.#e,t=n&&n.columns,i=t&&M(t.get)?t.get(o):null,a=n&&n.permissions;if(i&&a&&M(a.isSecret)&&a.isSecret(i))return null;const r=y.before(c,o);if(r==null)return this.#o("diff.empty");if(!i||!M(i.formatValue))return String(r);const s=M(y.beforeRow)?y.beforeRow(c):void 0,l={...(n.rows&&M(n.rows.byKey)?n.rows.byKey(c):null)||{},data:s===void 0?{}:s};try{const p=i.formatValue(r,l,l.data);return p==null?"":String(p)}catch(p){return I(`diff-before-format:${o}`,`the formatter for column "${o}" threw while formatting a previous value, so the diff hover shows the raw one.`,p),String(r)}}#o(y,c){const o=this.#e;return(o&&o.messages?o.messages:W).t(y,c)}destroy(){for(const c of this.#n)c();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const c of y.querySelectorAll("[data-key]")){for(const o of Object.values(_))c.classList.remove(o);c.removeAttribute("data-diff")}for(const c of y.querySelectorAll("[data-col]"))c.classList.remove(H,B),c.removeAttribute("data-before")}}}function D(k){return!!(k&&k.diff&&(M(k.diff)||typeof k.diff=="object"))}const v=G}),je("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 M=V("packages/core/src/internal/util.js").isFunction,I="lat-cell--highlight",N="--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()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):M(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const G=this.#l();if(G){G.sweep();for(const D of B.querySelectorAll("[data-key]")){const v=D.getAttribute("data-key");for(const k of D.querySelectorAll("[data-col]")){const y=G.active?G.colourFor(v,k.getAttribute("data-col")):null;y?(k.classList.add(I),k.style.setProperty(N,y)):k.classList.contains(I)&&(k.classList.remove(I),k.style.removeProperty(N))}}this.#s(G)}}#s(B){this.#r!==null&&M(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const G=B.nextExpiry;if(!Number.isFinite(G)||!M(this.#i.setTimeout))return;const D=Math.max(0,G-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},D)}#l(){const B=this.#e.highlight;return B&&M(B.model)?B.model():null}destroy(){this.#r!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const G of this.#n)G();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll))for(const G of B.querySelectorAll(`.${I}`))G.classList.remove(I),G.style.removeProperty(N)}}const _=W}),je("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isFunction,I="lat-cell--find",N="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()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(B):M(this.#i.setTimeout)?this.#i.setTimeout(B,0):B()}paint(){const B=this.#t.viewport?.root;if(!B||!B.querySelectorAll)return;const G=this.#e.find;if(!G||!M(G.stateFor))return;const D=M(G.model)?G.model():null,v=!!D&&D.active;if(!v&&!this.#o)return;let k=!1;for(const y of B.querySelectorAll("[data-key]")){const c=y.getAttribute("data-key");for(const o of y.querySelectorAll("[data-col]")){const n=v?G.stateFor(c,o.getAttribute("data-col")):null;n?(k=!0,o.classList.add(I),o.classList.toggle(N,n==="current")):o.classList.contains(I)&&o.classList.remove(I,N)}}this.#o=k}destroy(){for(const G of this.#n)G();this.#n=[];const B=this.#t.viewport?.root;if(!(!B||!B.querySelectorAll)){for(const G of B.querySelectorAll(`.${I}`))G.classList.remove(I,N);this.#o=!1}}}const _=W}),je("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/dom/src/editors/common.js"),M=Z.el,I=Z.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction,D="lat-find",v=12,k=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#w=null;#b=null;#v=!1;constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document||n.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=n.settings&&typeof n.settings=="object"?n.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(n,t){const i=this.#e;return(i&&i.messages&&G(i.messages.t)?i.messages:H).t(n,t)}mount(){const n=this.#S();if(!n)return;n.attachUi({open:i=>this.show(i),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),n.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&G(t.addEventListener)&&this.#o.shortcut!==!1){const i=a=>{if(!(a.ctrlKey||a.metaKey)||a.altKey||a.shiftKey||a.key!=="f"&&a.key!=="F")return;const r=a.target;if(this.#s&&r===this.#s){a.preventDefault(),a.stopPropagation(),G(this.#s.select)&&this.#s.select();return}W(r)||(a.preventDefault(),a.stopPropagation(),this.show())};t.addEventListener("keydown",i,!0),this.#g.push(()=>t.removeEventListener("keydown",i,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(n){const t=this.#A();if(!t)return;const i=t.style.display!=="none";t.style.display="",i||this.#y(),this.#S().setOpen(!0),n!=null&&(this.#s.value=String(n),this.#E()),this.#s.focus(),G(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#x();const n=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),n&&(n.clear(),n.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&G(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const r=(G(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;G(r.focus)&&r.focus()}search(){this.#E()}destroy(){this.#v=!0,this.#x();for(const t of this.#g)t();this.#g=[];const n=this.#S();n&&(n.attachUi(null),n.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const n=this.#t;n&&G(n.invalidate)&&n.invalidate("size")}#S(){const n=this.#e&&this.#e.find;return n&&G(n.model)?n.model():null}#A(){if(this.#i)return this.#i;const n=this.#t.viewport,t=n?.root,i=this.#n;if(!t||!i||!G(t.insertBefore))return null;const a=M(i,"div",{class:D,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=M(i,"input",{class:`${D}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=M(i,"span",{class:`${D}__count`,attrs:{"aria-hidden":"true"}}),this.#a=M(i,"span",{class:`${D}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=M(i,"span",{class:`${D}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const r=M(i,"button",{class:`${D}__nav ${D}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),s=M(i,"button",{class:`${D}__nav ${D}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=M(i,"button",{class:`${D}__toggle ${D}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=M(i,"button",{class:`${D}__toggle ${D}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=M(i,"select",{class:`${D}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const u=M(i,"button",{class:`${D}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),l=M(i,"div",{class:`${D}__options`,children:[this.#c,this.#d,this.#h]});for(const m of[this.#s,this.#l,this.#a,this.#u,r,s,u,l])a.appendChild(m);this.#g.push(I(this.#s,"input",()=>this.#O())),this.#g.push(I(r,"click",()=>this.#e.find.prev())),this.#g.push(I(s,"click",()=>this.#e.find.next())),this.#g.push(I(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push(I(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#E()})),this.#g.push(I(this.#h,"change",()=>{const m=this.#h.value;this.#p=m?String(m):null,this.#E()})),this.#g.push(I(u,"click",()=>this.hide()));const p=m=>{if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),this.hide();return}m.key==="Enter"&&m.target===this.#s&&(m.preventDefault(),m.stopPropagation(),this.#w!==null&&(this.#D(),this.#E()),m.shiftKey?this.#e.find.prev():this.#e.find.next())};return a.addEventListener("keydown",p),this.#g.push(()=>a.removeEventListener("keydown",p)),a.style.display="none",t.insertBefore(a,n.header||t.firstChild),this.#i=a,this.#j(),a}#j(){const n=this.#h;if(!n)return;const t=this.#n;for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(M(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const i=this.#e.columns,a=i&&G(i.visible)?i.visible():[];let r=!1;for(const s of a){if(!s||s.id===void 0)continue;const u=String(s.id);n.appendChild(M(t,"option",{text:s.title||u,attrs:{value:u}})),u===this.#p&&(r=!0)}r||(this.#p=null),n.value=this.#p||""}#O(){const n=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):k;if(this.#D(),n===0||!G(this.#r.setTimeout)){this.#E();return}this.#w=this.#r.setTimeout(()=>{this.#w=null,this.#E()},n)}#E(){const n=this.#S();if(!n||this.#v)return;const t=this.#s?this.#s.value:"";if(!t){this.#M(),n.clear();return}n.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#C()}),this.#T()}#C(){const n=this.#t&&this.#t.window,t=n&&Number.isFinite(n.first)?n.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#v)return;const n=()=>{this.#b=null,this.#I()};G(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(n):G(this.#r.setTimeout)?this.#b=this.#r.setTimeout(n,0):n()}#I(){const n=this.#S();!n||this.#v||!n.active||(n.stale&&n.rescan({from:this.#C()}),!n.complete&&(n.step(v)||this.#T()))}#N(){if(!this.#i||this.#v)return;const n=this.#e.find.count(),t=this.#S().active;let i="",a="idle";t&&(n.total===0?(i=n.complete?this.t("find.none"):this.t("find.searching"),a=n.complete?"none":"searching"):(i=this.t(n.complete?"find.count":"find.countPartial",{current:n.current,total:n.total}),a=n.complete?"matches":"searching")),this.#l.textContent=i,this.#i.setAttribute("data-state",a);const r=t&&n.windowed;this.#a.textContent=r?this.t("find.loadedRows"):"",this.#a.style.display=r?"":"none",t?n.complete&&(this.#u.textContent=n.total===0?this.t(r?"a11y.find.noneLoaded":"a11y.find.none"):this.t(r?"a11y.find.countLoaded":"a11y.find.count",{current:n.current,count:n.total})):this.#u.textContent=""}#D(){this.#w!==null&&G(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null}#M(){this.#b!==null&&(G(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):G(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#x(){this.#D(),this.#M()}}const c=y}),je("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return N}});const Z="lat-cell--redacted",M="lat-cell";class I{#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 H=this.#e.redaction;if(!H)return;const B=H.active;for(const G of _.querySelectorAll(`.${M}[data-col]`))B&&H.has(G.getAttribute("data-col"))?G.classList.add(Z):G.classList.contains(Z)&&G.classList.remove(Z)}destroy(){for(const _ of this.#n)_();this.#n=[]}}const N=I}),je("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 M=V("packages/dom/src/editors/common.js").markInvalid,I="lat-cell";function N(H,B){let G=H;for(;G;){if(B(G))return G;G=G.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 G=N(B,D=>D.getAttribute&&D.getAttribute("data-key")!==null);return G?G.getAttribute("data-key"):null}paint(){const B=this.#e.validation;if(!B||!B.active)return;const G=this.#t.viewport?.root;if(!(!G||!G.querySelectorAll))for(const D of G.querySelectorAll(`.${I}[data-col]`)){const v=D.getAttribute("data-col"),k=this.#r(D),y=k?B.errorFor(k,v):null;M(D,y?y.message:null)}}destroy(){for(const B of this.#n)B();this.#n=[]}}const _=W}),je("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/dom/src/renderer/textentry.js").isTextEntry,_=V("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",B="lat-presenting--changing",G="lat-presenting__progress",D="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class k{#e;#t;#n;#r=[];#o=null;#i=null;#s=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",n=>this.#a(n))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&M(this.#n.watch)&&this.#r.push(this.#n.watch(n=>{n||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const o=this.#t.viewport?.root;if(o&&M(o.addEventListener)){const n=t=>this.#l(t);o.addEventListener("keydown",n),this.#r.push(()=>o.removeEventListener("keydown",n))}}#l(o){const n=this.#e.presentation;if(!n?.active)return;const t=o.ctrlKey||o.metaKey,i=o.key;if(i==="Escape"&&!this.#n){o.defaultPrevented||(n.stop(),o.preventDefault?.());return}if(t){i==="="||i==="+"?(n.nudge(1),o.preventDefault?.()):i==="-"||i==="_"?(n.nudge(-1),o.preventDefault?.()):i==="0"&&(n.setScale(1.5),o.preventDefault?.());return}if(!n.views.length||N(o.target))return;i==="ArrowRight"||i==="ArrowDown"||i==="PageDown"||i===" "?(n.step(1),o.preventDefault?.()):i==="ArrowLeft"||i==="ArrowUp"||i==="PageUp"?(n.step(-1),o.preventDefault?.()):i==="Home"?(n.goTo(0),o.preventDefault?.()):i==="End"?(n.goTo(n.views.length-1),o.preventDefault?.()):(i==="r"||i==="R")&&(n.reset(),o.preventDefault?.())}#a(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 n=this.#t.viewport?.overlays;if(!n||!this.#e.presentation.views.length)return;const t=n.ownerDocument;if(!t?.createElement)return;if(!this.#i){const r=t.createElement("div");r.className=G,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),n.appendChild(r),this.#i=r}const i=this.#e.views?.get?.(o.viewId),a=i&&i.name?i.name:"";this.#i.textContent=a?`${a} · ${(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 n=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const a of v){if(n.has(a)||a==="toolPanel"&&this.#v())continue;const r=this.#y(a);r&&r.style&&r.style.display!=="none"&&(r.style.display="none",t.push(r))}const i=this.#w();i&&i.style&&i.style.display!=="none"&&this.#b(i)&&(i.style.display="none",t.push(i)),this.#o={maximised:o,hidden:t},this.#t.viewport?.root?.classList?.add(H),this.#f(),this.#p()}#h(){const o=this.#o;this.#o=null;const n=this.#t.viewport?.root;if(n?.classList?.remove(H),n?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),n?.classList?.remove(B),this.#m(),o){const t=this.#e.toolPanel;t&&M(t.presentRestore)&&t.presentRestore();for(const i of o.hidden)i.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 n=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=n&&n.keys.length?new Set(n.keys):null,i=n&&n.colIds.length?new Set(n.colIds):null;for(const a of o.querySelectorAll("[data-key]")){const r=!t||t.has(a.getAttribute("data-key"));for(const s of a.querySelectorAll("[data-col]"))!n||r&&(!i||i.has(s.getAttribute("data-col")))?s.classList.remove(D):s.classList.add(D)}}#p(){this.#g();const o=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(o)||o<=0||!this.#e.presentation.views.length)return;const n=this.#t.viewport?.root?.ownerDocument?.defaultView;n?.setInterval&&(this.#s=n.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.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#w(){const o=this.#e.element;return!o||!M(o.querySelector)?null:o.querySelector(`.${_.statusBar}`)}#b(o){const n=o.children||[];for(const t of n)if(!t.style||t.style.display!=="none")return!1;return!0}#v(){const o=this.#e.toolPanel;return!!(o&&M(o.presentOnly)&&o.presentOnly())}#y(o){const n=this.#e.element;if(!n||!M(n.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?n.querySelector(t):null}destroy(){this.#o&&this.#h();for(const o of this.#r)o();this.#r=[]}}const y=k}),je("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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return B}});const M=V("packages/core/src/internal/util.js").isFunction,I=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function N(G,D,v){const k=v.getComputedStyle(G),y=D.style;if(y)for(let c=0;c<k.length;c++){const o=k[c];I.has(o)||y.setProperty(o,k.getPropertyValue(o),k.getPropertyPriority(o))}}function W(G,D,v){if(N(G,D,v),G.tagName==="CANVAS"&&M(G.toDataURL))try{const c=G.toDataURL("image/png"),o=D.style;o&&(o.setProperty("background-image",`url(${c})`),o.setProperty("background-size","100% 100%"),o.setProperty("background-repeat","no-repeat"))}catch{}const k=G.children||[],y=D.children||[];for(let c=0;c<k.length&&c<y.length;c++)W(k[c],y[c],v)}function _(G,D){if(!G||G.startsWith("data:")||G.startsWith("blob:"))return!0;try{return new URL(G,D).origin===D}catch{return!0}}async function H(G,D={}){const v=G.ownerDocument,k=v?.defaultView;if(!k||typeof k.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=G.getBoundingClientRect(),c=Math.max(1,Math.ceil(y.width)),o=Math.max(1,Math.ceil(y.height)),n=Math.max(.1,Number(D.scale)||2),t=k.location?.origin||"";for(const p of G.querySelectorAll("img")){const m=p.getAttribute("src")||"";if(!_(m,t))throw new Error(`capture refused: the image at ${m} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const i=G.cloneNode(!0);W(G,i,k),i.style.width=`${c}px`,i.style.height=`${o}px`,i.style.margin="0";const a=new k.XMLSerializer().serializeToString(i),r=`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${o}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${a}</div></foreignObject></svg>`,s=new k.Image;await new Promise((p,m)=>{s.onload=()=>p(void 0),s.onerror=()=>m(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),s.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`});const u=v.createElement("canvas");u.width=Math.round(c*n),u.height=Math.round(o*n);const l=u.getContext("2d");if(!l)throw new Error("capture could not get a 2d context");return l.fillStyle=D.background||k.getComputedStyle(G).backgroundColor||"#ffffff",l.fillRect(0,0,u.width,u.height),l.drawImage(s,0,0,u.width,u.height),new Promise((p,m)=>{u.toBlob(b=>b?p({blob:b,width:u.width,height:u.height}):m(new Error("capture produced no image")),D.type||"image/png",D.quality)})}const B=H}),je("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 H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,_=Object.freeze(["pen","arrow","rect","highlight"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),B=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),G=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=14,v="system-ui, -apple-system, sans-serif";function k(r,s){if(!r||typeof r!="object")return null;const u=B[r.type];if(!u)return null;const l=Array.isArray(r.points)?r.points:[],p=[];for(const b of l){const g=Number(b&&b.x),f=Number(b&&b.y);Number.isFinite(g)&&Number.isFinite(f)&&p.push({x:g,y:f})}const m=typeof r.colour=="string"&&r.colour?r.colour:s;if(u==="text"){const b=typeof r.text=="string"?r.text:"";if(!p.length||!b)return null;const g={tool:u,colour:m,points:[p[0]],text:b,region:y(r.region)},f=Number(r.fontSize);return Number.isFinite(f)&&f>0&&(g.fontSize=f),typeof r.background=="string"&&r.background&&(g.background=r.background),g}return p.length<2?null:{tool:u,colour:m,points:p,region:y(r.region)}}function y(r){return r==="start"||r==="end"?r:"centre"}function c(r){const s={type:G[r.tool]||r.tool,colour:r.colour,points:r.points.map(u=>({x:u.x,y:u.y}))};return(r.region==="start"||r.region==="end")&&(s.region=r.region),r.tool==="text"&&(s.text=r.text,r.fontSize!==void 0&&(s.fontSize=r.fontSize),r.background!==void 0&&(s.background=r.background)),s}const o="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(r){return r==="arrow"||r==="rect"}class i{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const u=k(s,this.#i);return u?(u.durable=!0,this.#s.push(u),this.#y(),this.redraw(),this.#j(),this.#s.length):(I("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#s.length)}list(){return this.#s.map(c)}replaceAll(s){const u=Array.isArray(s)?s:[];this.#s=u.map(l=>k(l,this.#i)).filter(Boolean);for(const l of this.#s)l.durable=!0;this.#s.length&&this.#y(),this.redraw(),this.#j()}#c(){const s=this.#t.viewport?.root;if(!s||!M(s.addEventListener))return;const u=l=>{!this.#o||!l||l.key!=="Escape"||(this.use(null),l.preventDefault?.())};s.addEventListener("keydown",u,!0),this.#a.push(()=>s.removeEventListener("keydown",u,!0))}#d(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!M(s.matchMedia))return;let u=null;const l=()=>{const p=s.devicePixelRatio||1;let m;try{m=s.matchMedia(`(resolution: ${p}dppx)`)}catch{return}u=m;const b=()=>{this.redraw(),l()};M(m.addEventListener)?m.addEventListener("change",b,{once:!0}):M(m.addListener)&&m.addListener(b)};l(),this.#a.push(()=>{u=null})}use(s,u={}){const l=!!u.colour&&s===this.#o;u.colour&&(this.#i=String(u.colour));const p=s&&_.includes(s)?s:null;this.#o=p&&p===this.#o&&!l?null:p;const m=this.#o?this.#y():this.#n;return m&&(m.style.pointerEvents=this.#o?"auto":"none",m.style.cursor=this.#o?"crosshair":""),this.#j(),this.#o}undo(){return this.#s.pop(),this.redraw(),this.#j(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.redraw(),this.#j())}#h(){const s=this.#s.filter(u=>u.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#j())}redraw(){!this.#n&&this.#s.length&&this.#y();const s=this.#n,u=this.#r;if(!s||!u)return;this.#S();const{left:l,top:p}=this.#v();u.clearRect(0,0,s.width,s.height);const m=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const g=m.filter(f=>y(f.region)===b);if(g.length){u.save(),this.#f(u,b),u.translate((b==="centre"?-l:0)||0,-p||0);for(const f of g)this.#w(u,f);u.restore()}}}#f(s,u="centre"){const l=this.#n,p=this.#t.viewport?.bodyViewport;if(!M(l?.getBoundingClientRect)||!M(p?.getBoundingClientRect))return;const m=l.getBoundingClientRect(),b=p.getBoundingClientRect();if(!b.width||!b.height)return;const g=this.#m(u,b);g&&(s.beginPath(),s.rect(g.left-m.left,b.top-m.top,g.width,b.height),s.clip())}#m(s,u){const l=w=>{if(!M(w?.getBoundingClientRect))return null;const S=w.getBoundingClientRect();return S&&S.width>0?{left:S.left,width:S.width}:null},p=l(this.#t.viewport?.bodyStart),m=l(this.#t.viewport?.bodyEnd);if(s==="start")return p;if(s==="end")return m;let b=u.left,g=u.left+u.width;const f=u.left+u.width/2;for(const w of[p,m]){if(!w)continue;const S=w.left+w.width;w.left+w.width/2<f?b=Math.max(b,S):g=Math.min(g,w.left)}return g>b?{left:b,width:g-b}:null}#p(s){for(const[u,l]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!M(l?.getBoundingClientRect))continue;const p=l.getBoundingClientRect();if(p&&p.width>0&&s>=p.left&&s<p.left+p.width)return u}return"centre"}#g(s){const u=this.#t.viewport?.bodyViewport;if(!M(u?.getBoundingClientRect))return!0;const l=u.getBoundingClientRect();return!l.width||!l.height?!0:s.clientX>=l.left&&s.clientX<=l.right&&s.clientY>=l.top&&s.clientY<=l.bottom}#w(s,u){const l=u.points;if(!l.length)return;const p=this.#e.presentation?.scale||1;s.lineWidth=(n[u.tool]||3)*p,s.strokeStyle=u.colour,s.fillStyle=u.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=u.tool==="highlight"?.32:1;const m=l[0],b=l[l.length-1];if(u.tool==="text"){const g=(u.fontSize||D)*p;s.font=`${g}px ${v}`,s.textBaseline="top";const f=u.text||"";if(u.background){let w=f.length*g*.6;if(typeof s.measureText=="function"){const S=s.measureText(f);S&&Number.isFinite(S.width)&&(w=S.width)}s.fillStyle=u.background,s.fillRect(m.x-g*.15,m.y-g*.1,w+g*.3,g*1.2)}s.fillStyle=u.colour,s.fillText(f,m.x,m.y),s.globalAlpha=1;return}if(u.tool==="rect")s.strokeRect(m.x,m.y,b.x-m.x,b.y-m.y);else if(u.tool==="arrow")s.beginPath(),s.moveTo(m.x,m.y),s.lineTo(b.x,b.y),s.stroke(),this.#b(s,m,b,s.lineWidth);else{s.beginPath(),s.moveTo(m.x,m.y);for(let g=1;g<l.length;g++)s.lineTo(l[g].x,l[g].y);s.stroke()}s.globalAlpha=1}#b(s,u,l,p){const m=Math.atan2(l.y-u.y,l.x-u.x),b=Math.max(8,p*3);s.beginPath(),s.moveTo(l.x,l.y),s.lineTo(l.x-b*Math.cos(m-Math.PI/7),l.y-b*Math.sin(m-Math.PI/7)),s.lineTo(l.x-b*Math.cos(m+Math.PI/7),l.y-b*Math.sin(m+Math.PI/7)),s.closePath(),s.fill()}#v(){const s=M(this.#t.scrollPosition)?this.#t.scrollPosition():null,u=this.#t.viewport?.rtl===!0;return{left:W(s?.left||0,u),top:s?.top||0}}#y(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,u=s?.ownerDocument;if(!s||!u?.createElement)return null;const l=u.createElement("canvas");return l.className=o,l.style.position="absolute",l.style.inset="0",l.style.pointerEvents="none",s.appendChild(l),this.#n=l,this.#r=l.getContext?l.getContext("2d"):null,this.#S(),this.#A(l),l}#S(){const s=this.#n,u=this.#t.viewport?.root;if(!s||!u?.getBoundingClientRect)return;const l=u.getBoundingClientRect(),m=s.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(l.width*m)),g=Math.max(1,Math.round(l.height*m));s.width===b&&s.height===g||(s.width=b,s.height=g,s.style&&(s.style.width=`${Math.max(1,l.width)}px`,s.style.height=`${Math.max(1,l.height)}px`),this.#r?.setTransform(m,0,0,m,0,0))}#A(s){const u=(g,f="centre")=>{const w=s.getBoundingClientRect(),{left:S,top:h}=this.#v();return{x:g.clientX-w.left+(f==="centre"?S:0),y:g.clientY-w.top+h}},l=g=>{if(!this.#o||!this.#g(g))return;const f=this.#p(g.clientX);this.#l={tool:this.#o,colour:this.#i,points:[u(g,f)],region:f},s.setPointerCapture?.(g.pointerId),g.preventDefault?.()},p=g=>{if(!this.#l)return;const f=u(g,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(f),this.redraw()},m=g=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(g.pointerId),this.redraw(),this.#j())},b=g=>{if(!this.#o)return;const f=this.#t.viewport?.bodyViewport;if(!f)return;let w=!1;g.deltaY&&typeof f.scrollTop=="number"&&(f.scrollTop+=g.deltaY,w=!0),g.deltaX&&typeof f.scrollLeft=="number"&&(f.scrollLeft+=g.deltaX,w=!0),w&&g.preventDefault?.()};s.addEventListener("pointerdown",l),s.addEventListener("pointermove",p),s.addEventListener("pointerup",m),s.addEventListener("pointercancel",m),s.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",l),s.removeEventListener("pointermove",p),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m),s.removeEventListener("wheel",b)})}#j(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const a=i}),je("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 H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return G}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function _(D){if(!Number.isFinite(D)||D<1e3)return"now";const v=Math.round(D/1e3);if(v<60)return`${v}s ago`;const k=Math.round(v/60);return k<60?`${k}m ago`:`${Math.round(k/60)}h ago`}function H(D,v){return Number.isFinite(D)?new Date(D).toLocaleTimeString(v||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class B{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(v){this.#e=v.grid,this.#t=v.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const v=this.#e.timeline,k=v.depth,y=v.position;this.#r.max=String(Math.max(1,k)),this.#r.value=String(Math.max(0,k-y)),this.#r.disabled=k===0;const c=v.at(),o=v.live;this.#o&&(this.#o.textContent=o?this.#l("timeline.live"):_(Date.now()-(c||Date.now())),this.#o.setAttribute("data-live",o?"true":"false")),this.#i&&(this.#i.textContent=k===0?this.#l("timeline.recording"):H(c,this.#e.get("locale"))),this.#n.setAttribute("data-live",o?"true":"false")}#l(v,k){const y=this.#e;return(y&&y.messages?y.messages:N).t(v,k)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,k=v?.ownerDocument;if(!v||!k?.createElement)return;const y=k.createElement("div");y.className=W;const c=k.createElement("span");c.className=`${W}__ago`,c.setAttribute("role","status"),c.setAttribute("aria-live","polite");const o=k.createElement("input");o.className=`${W}__range`,o.type="range",o.min="0",o.step="1",o.setAttribute("aria-label",this.#l("timeline.scrub"));const n=k.createElement("span");n.className=`${W}__clock`;const t=k.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#l("timeline.goLive"),t.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(c),y.appendChild(o),y.appendChild(n),y.appendChild(t),v.appendChild(y),this.#n=y,this.#r=o,this.#o=c,this.#i=n;const i=()=>{const s=this.#e.timeline.depth;this.#e.timeline.seek(s-Number(o.value))};o.addEventListener("input",i);const a=()=>this.#e.timeline.toLive();t.addEventListener("click",a);const r=s=>s.stopPropagation();o.addEventListener("keydown",r),this.#s.push(()=>{o.removeEventListener("input",i),t.removeEventListener("click",a),o.removeEventListener("keydown",r)})}#u(){this.#n&&(M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const v of this.#s)v();this.#s=[],this.#u()}}const G=B}),je("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,_=V("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",B="lat-cell--commented",G="lat-cell--commented-open";class D{#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.#s(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const c=this.#t.viewport?.root;if(!c||!c.querySelectorAll)return;const o=[];for(const n of c.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key");if(t){o.push(t);for(const i of n.querySelectorAll("[data-col]")){const a=i.getAttribute("data-col"),r=y.at(t,a),s=!!(r&&r.count);i.classList.toggle(B,s),i.classList.toggle(G,s&&r.unresolved>0),this.#i(i,r,a)}}}(o.length!==this.#r.length||o.some((n,t)=>n!==this.#r[t]))&&(this.#r=o,y.request(o))}#o(y,c){const o=this.#e;return(o&&o.messages?o.messages:N).t(y,c)}#i(y,c,o){if(!c||!c.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const n=c.count,t=c.unresolved,i=this.#o("count.comments",{count:n});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:i,unresolved:t}):this.#o("comments.allResolved",{comments:i}))}#s(){const y=this.#t.viewport?.root;if(!y||!M(y.addEventListener))return;const c=n=>{const t=this.#e.comments;if(!t||!t.enabled)return;const i=n.target&&M(n.target.closest)?n.target.closest("[data-col]"):null;if(!i||!i.classList.contains(B)||!this.#l(i,n))return;const a=i.closest("[data-key]"),r=a&&a.getAttribute("data-key");r&&(n.stopPropagation(),n.preventDefault(),t.open(r,i.getAttribute("data-col")))},o=n=>{const t=this.#e.comments;if(!t||!t.enabled||!n.altKey||n.key!=="m"&&n.key!=="M")return;const i=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&M(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!i)return;const a=i.closest("[data-key]"),r=a&&a.getAttribute("data-key");r&&(n.preventDefault(),n.stopPropagation(),t.open(r,i.getAttribute("data-col")))};y.addEventListener("click",c,!0),y.addEventListener("keydown",o,!0),this.#n.push(()=>{y.removeEventListener("click",c,!0),y.removeEventListener("keydown",o,!0)})}#l(y,c){if(!M(y.getBoundingClientRect))return!1;const o=y.getBoundingClientRect(),n=Math.max(14,Math.min(24,o.height*.6));return(_(y)?c.clientX<=o.left+n:c.clientX>=o.right-n)&&c.clientY<=o.top+n}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=D}),je("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const M=V("packages/core/src/internal/util.js").isFunction,N=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,G="lat-presence";class D{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=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 c of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(c,o=>this.#l(c,o)));this.#a(),this.paint()}}#l(y,c){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const n=c&&c.peer;n&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:n.name}))}#a(){const y=this.#t.viewport?.overlays,c=y?.ownerDocument;if(!y||!c?.createElement)return;const o=this.#e.get("presence")||{},n=c.createElement("span");if(n.className=`${G}__live`,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),y.appendChild(n),this.#r=n,o.roster===!1)return;const t=c.createElement("div");t.className=G,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,c=this.#t.viewport?.root;if(!y||!y.enabled||!c?.querySelectorAll)return;this.#d(c);const o=y.peers(),n=[...o].sort((t,i)=>t.at-i.at);for(const t of n)for(const i of t.ranges||[])for(const a of i.rowIds||[])for(const r of i.columns||[])this.#c(c,a,r,t,"range");for(const t of n)t.cursor&&this.#c(c,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of n)t.editing&&this.#c(c,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(o)}#u(y){if(this.#s!==null)return;const c=y.filter(t=>t.cursorFresh);if(!c.length)return;const n=Math.max(...c.map(t=>t.cursorAt||0))+B-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,n))}#c(y,c,o,n,t){const i=y.querySelector(`[data-key="${_(c)}"]`),a=i&&i.querySelector(`[data-col="${_(o)}"]`);a&&(a.setAttribute("data-presence",t),a.style.setProperty("--lat-peer",n.colour),a.setAttribute("data-peer-name",n.name),a.setAttribute("data-peer-initial",n.initials||(n.name||"?").slice(0,1).toUpperCase()),n.idle?a.setAttribute("data-peer-idle","true"):a.removeAttribute("data-peer-idle"),t==="cursor"&&n.cursorFresh&&a.setAttribute("data-peer-fresh","true"),this.#o.add(`${c}${o}`))}#d(y){if(this.#o.size){for(const c of y.querySelectorAll("[data-presence]"))c.removeAttribute("data-presence"),c.removeAttribute("data-peer-name"),c.removeAttribute("data-peer-initial"),c.removeAttribute("data-peer-fresh"),c.removeAttribute("data-peer-idle"),c.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const y=this.#n.ownerDocument,c=this.#e.presence.peers();if(this.#n.textContent="",!c.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const n of c){const t=y.createElement("button");t.className=`${G}__peer`,t.type="button",t.style.setProperty("--lat-peer",n.colour),t.toggleAttribute("data-idle",!!n.idle),t.toggleAttribute("data-hidden",!!n.hidden);let i="presence.peer";n.hidden?i="presence.peerHidden":n.idle&&(i="presence.peerIdle"),t.setAttribute("aria-label",this.#f(i,{name:n.name}));const a=y.createElement("span");a.className=`${G}__dot`,a.setAttribute("aria-hidden","true"),a.textContent=n.initials||(n.name||"?").slice(0,1).toUpperCase(),t.appendChild(a);const r=y.createElement("span");r.className=`${G}__name`,r.textContent=n.name,t.appendChild(r),t.addEventListener("click",()=>this.#e.presence.jumpTo(n.id)),this.#n.appendChild(t)}const o=c.filter(n=>n.hidden).length;if(o){const n=y.createElement("span");n.className=`${G}__hidden`,n.textContent=this.#f("presence.hidden",{count:o}),this.#n.appendChild(n)}}announceRefusal(y){if(!this.#r)return;const c=y&&y.name?y.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:c})}#f(y,c){const o=this.#e;return(o&&o.messages?o.messages:N).t(y,c)}destroy(){for(const c of this.#i)c();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=D}),je("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=V("packages/core/src/internal/util.js").isFunction,N=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,G="lat-comments",D=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function k(n,t){if(!Number.isFinite(n))return"";const i=Math.max(0,Math.round((t-n)/1e3));if(i<60)return"just now";const a=Math.round(i/60);if(a<60)return`${a}m ago`;const r=Math.round(a/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function y(n,t,i,a){t.textContent="";const r=String(i??"");if(!a){t.textContent=r;return}const s=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let u=0,l=s.exec(r);for(;l;){l.index>u&&t.appendChild(n.createTextNode(r.slice(u,l.index)));const p=l[0];if(p.startsWith("*")){const m=n.createElement("em");m.textContent=p.slice(1,-1),t.appendChild(m)}else if(p.startsWith("`")){const m=n.createElement("code");m.textContent=p.slice(1,-1),t.appendChild(m)}else{const m=p.indexOf("]("),b=p.slice(1,m),g=p.slice(m+2,-1);if(D.test(g)){const f=n.createElement("a");f.href=g,f.textContent=b,f.rel="noopener noreferrer",f.target="_blank",t.appendChild(f)}else t.appendChild(n.createTextNode(b))}u=l.index+p.length,l=s.exec(r)}u<r.length&&t.appendChild(n.createTextNode(r.slice(u)))}class c{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",t=>this.#a(t))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(t){const i=this.#t.viewport?.root?.ownerDocument;i&&(this.#s=i.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(i),this.#n.setAttribute("data-open","true"),this.#b(),this.#y(),this.#o&&M(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#s;this.#s=null,t&&M(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:i}=B(t);this.#e.rows.byKey(i)||(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 a=this.#r.ownerDocument.createElement("p");a.className=`${G}__note`,a.setAttribute("role","status"),a.textContent=t,this.#r.appendChild(a)}#h(t,i){const a=this.#t.viewport?.root;if(!a||!a.querySelector)return null;const r=a.querySelector(`[data-key="${_(t)}"]`);return r?r.querySelector(`[data-col="${i}"]`):null}#f(t,i){const a=this.#e;return(a&&a.messages?a.messages:N).t(t,i)}#m(t){const i=t.createElement("div");i.className=G,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",this.#f("comments.panel"));const a=t.createElement("header");a.className=`${G}__head`;const r=t.createElement("div");r.className=`${G}__title`,a.appendChild(r);const s=t.createElement("button");s.className=`${G}__resolve`,s.type="button",a.appendChild(s);const u=t.createElement("button");u.className=`${G}__close`,u.type="button",u.setAttribute("aria-label",this.#f("comments.close")),u.textContent="×",a.appendChild(u);const l=t.createElement("div");l.className=`${G}__list`,l.setAttribute("role","log"),l.setAttribute("aria-live","polite");const p=t.createElement("form");p.className=`${G}__composer`;const m=t.createElement("textarea");m.className=`${G}__input`,m.rows=2,m.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${G}__send`,b.type="submit",b.textContent=this.#f("comments.post"),p.appendChild(m),p.appendChild(b),i.appendChild(a),i.appendChild(l),i.appendChild(p),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(i),this.#n=i,this.#r=l,this.#o=m,this.#p=r,this.#g=s;const g=h=>{h.preventDefault();const d=String(m.value||"").trim();d&&(m.value="",this.#e.comments.add(d))},f=()=>this.#e.comments.close(),w=()=>{this.#w()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},S=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.#e.comments.close();return}if(h.key!=="Tab")return;const d=[...i.querySelectorAll(v)].filter(T=>T.offsetParent!==null||T===m);if(!d.length)return;const j=d[0],E=d[d.length-1],O=i.ownerDocument.activeElement;h.shiftKey&&O===j?(h.preventDefault(),E.focus()):!h.shiftKey&&O===E&&(h.preventDefault(),j.focus())};p.addEventListener("submit",g),u.addEventListener("click",f),s.addEventListener("click",w),i.addEventListener("keydown",S),this.#l.push(()=>{p.removeEventListener("submit",g),u.removeEventListener("click",f),s.removeEventListener("click",w),i.removeEventListener("keydown",S)})}#p=null;#g=null;#w(){return(this.#e.comments.thread||[]).filter(i=>!i.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const i=this.#n.ownerDocument,a=this.#e.get("comments")||{},r=Date.now(),s=t.openKey,{rowId:u,field:l}=B(s),p=this.#e.columns.get(l),m=this.#e.rows.byKey(u),b=M(a.rowLabel)&&m?a.rowLabel(m):u;if(this.#p.textContent=this.#f("comments.cellTitle",{column:p&&(p.title??p.id)||l,row:b}),this.#g.textContent=this.#w()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const g=t.thread||[];if(!g.length){this.#d(this.#f("comments.empty"));return}const f=m&&p?p.getValue(m.data,m):void 0;for(const w of g)this.#r.appendChild(this.#v(i,w,r,f,a))}#v(t,i,a,r,s){const u=t.createElement("article");u.className=`${G}__item`,i.pending&&u.setAttribute("data-pending","true"),i.resolved&&u.setAttribute("data-resolved","true");const l=t.createElement("div");l.className=`${G}__meta`;const p=t.createElement("span");p.className=`${G}__author`,p.textContent=i.author&&(i.author.name||i.author.initials)||this.#f("comments.unknownAuthor"),l.appendChild(p);const m=t.createElement("time");m.className=`${G}__time`;const b=k(i.at,a);m.textContent=i.edited?this.#f("comments.edited",{time:b}):b,l.appendChild(m),u.appendChild(l);const g=t.createElement("div");if(g.className=`${G}__body`,y(t,g,i.body,!!s.markdown),u.appendChild(g),i.value!==void 0&&!Object.is(i.value,r)){const S=t.createElement("p");S.className=`${G}__moved`,S.textContent=this.#f("comments.valueMoved",{was:String(i.value),now:String(r)}),u.appendChild(S)}const f=i.can||{},w=S=>f[S]!==!1;if(w("edit")||w("delete")){const S=t.createElement("div");if(S.className=`${G}__actions`,w("delete")){const h=t.createElement("button");h.type="button",h.className=`${G}__action`,h.textContent=this.#f("comments.delete"),h.addEventListener("click",()=>this.#e.comments.remove(i.id)),S.appendChild(h)}u.appendChild(S)}return u}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const i=this.#e.comments.openKey,{rowId:a,field:r}=B(i),s=this.#h(a,r)||this.#i,u=this.#t.viewport?.root;if(!s||!u||!M(s.getBoundingClientRect))return;const l=s.getBoundingClientRect(),p=u.getBoundingClientRect(),m=this.#n.getBoundingClientRect();let b=l.bottom-p.top+4;b+m.height>p.height&&l.top-p.top>m.height&&(b=l.top-p.top-m.height-4);let g=l.left-p.left;g+m.width>p.width&&(g=Math.max(0,p.width-m.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,g)}px`;const f=l.bottom<p.top||l.top>p.bottom;this.#n.toggleAttribute("data-offscreen",f)}destroy(){for(const t of this.#l)t();this.#l=[],this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const o=c}),je("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 k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),_=W.el,H=W.on,B="lat-watermark",G="https://www.latticegrid.dev",D=["br","bl","tl","tr"],v=4e3;class k{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=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(),M(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const o=this.#e.licence&&this.#e.licence.ready;o&&M(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())}#a(){const o=this.#i;if(!o||!M(o.matchMedia))return!1;try{return!!o.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),M(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%D.length,this.#f(),this.#h(),this.#u()},v)))}#c(){this.#l!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const o=this.#e.licence;return!!(o&&M(o.watermark)&&o.watermark())}#h(){const o=_(this.#t,"a",{class:`${B}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:N).t("licence.watermark"),attrs:{href:G,target:"_blank",rel:"noopener noreferrer"}});this.#r=_(this.#t,"div",{class:`${B} ${B}--${D[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[o]}),this.#o.push(H(this.#r,"pointerdown",n=>{M(n.stopPropagation)&&n.stopPropagation()})),this.#n&&M(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&M(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=k}),je("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Z=V("packages/core/src/internal/util.js"),M=Z.warnOnce,I=Z.isFunction,N=V("packages/dom/src/editors/common.js"),W=N.el,_=N.on,B=V("packages/dom/src/themeof.js").themeOf,G="lat-maximised",D={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"},v="lat-maximised-host",k="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(n){this.#e=n.element,this.#t=n.document,this.#n=I(n.onChange)?n.onChange:null,this.#r=I(n.captureScroll)?n.captureScroll:null,this.#o=I(n.restoreScroll)?n.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const n=this.#e.parentNode;if(!n||!this.#t.body)return M("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:k}),this.#i.style.visibility="hidden";const t=this.#e.offsetWidth,i=this.#e.offsetHeight;t&&(this.#i.style.width=`${t}px`),i&&(this.#i.style.height=`${i}px`);const a=this.#r?this.#r():null,r=I(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?B(n):null;r&&(this.#e.setAttribute("data-theme",r),this.#u=!0),n.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[s,u]of Object.entries(D))this.#a[s]=this.#e.style[s]||"",this.#e.style[s]=u;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(G),this.#t.body.classList&&this.#t.body.classList.add(v),a&&this.#o&&this.#o(a),this.#s=_(this.#t,"keydown",s=>this.#h(s)),this.#f(),!0}exit(){if(!this.active())return!1;const n=this.#r?this.#r():null,t=this.#i,i=t.parentNode;if(i&&I(i.insertBefore)&&this.#d(()=>i.insertBefore(this.#e,t)),I(t.remove)&&t.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[a,r]of Object.entries(this.#a))this.#e.style[a]=r;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(G),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),n&&this.#o&&this.#o(n),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(n){const t=this.#t.activeElement,i=t&&t!==this.#t.body&&I(this.#e.contains)&&this.#e.contains(t)?t:null;n(),i&&I(i.focus)&&i.focus()}#h(n){!n||n.key!=="Escape"||n.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const n of this.#l)n(this.active())}watch(n){return I(n)?(this.#l.add(n),()=>this.#l.delete(n)):()=>{}}destroy(){this.exit()}}const c=y}),je("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 i}});const Z=V("packages/dom/src/editors/common.js"),M=Z.documentFor,I=Z.el,N=Z.on,W=Z.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,G=V("packages/core/src/internal/util.js").isFunction,D=V("packages/core/src/ai/schema.js"),v=D.describeGrid,k=D.promptText,y=V("packages/core/src/ai/intent.js"),c=y.applyPlan,o=y.buildPrompt,n=y.planIntent,t="lat-prompt";class i{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#w="idle";#b=0;#v=!1;#y=[];t(u,l){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(u,l)}init(u={}){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||H,this.#e=M(u),this.#t=u.grid||null,this.#n=G(u.ask)?u.ask:null,this.#r=u.schemaOptions||{},this.#o=u.context,this.#i={onPlan:G(u.onPlan)?u.onPlan:null,onApply:G(u.onApply)?u.onApply:null,onError:G(u.onError)?u.onError:null},this.#s=I(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(u)}element(){return this.#s}refresh(){this.#v||!this.#s||this.#w!=="busy"&&this.#E()}destroy(){this.#v=!0,this.#b++;for(const u of this.#y)u();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(u){if(this.#v||this.#w==="busy")return null;const l=String(u??(this.#l&&this.#l.value)??"").trim();if(!l)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const p=++this.#b;this.#A("busy"),this.#C("Thinking…");let m;try{const b=v(this.#t,this.#r),g=k(b);if(m=await this.#n({prompt:l,schema:b,schemaText:g,message:o(l,g),context:this.#o}),this.#v||p!==this.#b)return null;const f=n(m,b);return this.#j(f),f}catch(b){return this.#v||p!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const u=this.#g;if(this.#v||!u||!u.ok)return null;const l=this.#t?.ai,p=G(l?.apply)?l.apply(u):c(u,this.#t);return this.#i.onApply&&this.#i.onApply(p,u),this.#E(),this.#l&&(this.#l.value=""),p.failed.length?this.#T(`Applied ${p.applied.length}; ${p.failed.map(m=>`${m.type} failed: ${m.reason}`).join("; ")}`):this.#C(`Applied: ${u.describe()}`),p}discard(){this.#v||(this.#E(),this.#C("Discarded."))}#S(u){const l=this.#e,p=I(l,"div",{class:`${t}__row`});this.#l=I(l,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:u.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":u.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(N(this.#l,"keydown",b=>{const g=b&&b.key;g==="Enter"?(G(b.preventDefault)&&b.preventDefault(),this.ask()):g==="Escape"&&this.#g&&(G(b.preventDefault)&&b.preventDefault(),this.discard())})),p.appendChild(this.#l),this.#a=I(l,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(N(this.#a,"click",()=>{this.ask()})),p.appendChild(this.#a),this.#s.appendChild(p),this.#u=I(l,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=I(l,"p",{class:`${t}__summary`}),this.#d=I(l,"ul",{class:`${t}__notes`});const m=I(l,"div",{class:`${t}__buttons`});this.#h=I(l,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=I(l,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(N(this.#h,"click",()=>{this.apply()})),this.#y.push(N(this.#f,"click",()=>{this.discard()})),m.appendChild(this.#h),m.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(m),this.#s.appendChild(this.#u),this.#m=I(l,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=I(l,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#m),this.#s.appendChild(this.#p)}#A(u){if(this.#w=u,!this.#s)return;this.#s.setAttribute("data-state",u);const l=u==="busy";a(this.#l,l),a(this.#a,l),this.#a&&(this.#a.textContent=this.t(l?"prompt.asking":"prompt.ask")),r(this.#u,u!=="preview"),r(this.#p,u!=="error")}#j(u){const l=u;if(this.#i.onPlan&&this.#i.onPlan(u),!l.ok){this.#g=null;const p=l.rejected.length?l.rejected.map(m=>m.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${p}`);return}this.#g=u,this.#C(""),this.#c&&(this.#c.textContent=l.describe()),this.#O(l.rejected),this.#A("preview")}#O(u){const l=this.#d;if(l){W(l),r(l,!u.length);for(const p of u.slice(0,6))l.appendChild(I(this.#e,"li",{class:`${t}__note`,text:p.reason}));u.length>6&&l.appendChild(I(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:u.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#A("idle")}#C(u){this.#m&&(this.#m.textContent=u)}#T(u){this.#g=null,this.#C(""),this.#p&&(this.#p.textContent=u),this.#A("error")}}function a(s,u){s&&(s.disabled=u,u?s.setAttribute("disabled",""):s.removeAttribute("disabled"))}function r(s,u){s&&(s.hidden=u,u?s.setAttribute("hidden",""):s.removeAttribute("hidden"))}}),je("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 i}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return u}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.isObject,N=Z.warnOnce,_=V("packages/core/src/source/derive.js").reduceValues,B=V("packages/core/src/source/memory.js").isPipelineSettle,D=V("packages/core/src/i18n/index.js").defaultMessages,k=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"},c="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"]),n=Object.freeze({direction:"flat",change:null,percent:null});function t(g,f){if(!Number.isFinite(g)||!Number.isFinite(f))return n;const w=g-f,S=w>0?"up":w<0?"down":"flat",h=f===0?null:w/Math.abs(f)*100;return{direction:S,change:w,percent:h}}function i(g,f){return g==="flat"||f==="neither"?"flat":g===f?"good":"bad"}function a(g,f,w=null){if(M(f)){const O=f(g,w);return O==="good"||O==="warn"||O==="bad"?O:null}if(!I(f))return null;const S=typeof g=="number"&&Number.isFinite(g)?g:null;if(S===null)return null;const h=Number.isFinite(Number(f.good))?Number(f.good):null,d=Number.isFinite(Number(f.warn))?Number(f.warn):null,j=String(f.direction||"up")==="down",E=O=>j?S<=O:S>=O;return h!==null&&E(h)?"good":d!==null&&E(d)?"warn":h===null&&d===null?null:"bad"}function r(g){return!(M(g.value)||g.value!==void 0&&!I(g.value))}function s(g){return!g||!g.rows||!M(g.rows.totalCount)?!0:g.rows.totalCount()>0}function u(g){const f=I(g)?g:{},w=f.grid||null,S=m(f.container,w);if(!S)return N("stat.container","createStat needs a `container`: an element or a selector."),b();const h=S.ownerDocument||(typeof document>"u"?null:document);if(!h)return N("stat.document","createStat needs a document; it draws DOM."),b();const d=h.createElement("div");d.className=["lattice",y.root,f.class].filter(Boolean).join(" "),d.setAttribute("role","group");const j=h.createElement("div");j.className=y.title;const E=h.createElement("div");E.className=y.value;const O=h.createElement("div");O.className=y.interval;const T=h.createElement("div");T.className=y.delta;const A=h.createElement("div");A.className=y.footer;const P=h.createElement("div");if(P.className=y.note,P.hidden=!0,f.icon!=null&&f.icon!==""){const te=h.createElement("span");te.className=y.icon,te.setAttribute("aria-hidden","true"),k(te,f.icon,`stat:${f.title||"stat"}`),d.appendChild(te);const ee=h.createElement("div");ee.className=y.body,ee.appendChild(j),ee.appendChild(E),ee.appendChild(P),ee.appendChild(O),ee.appendChild(T),ee.appendChild(A),d.appendChild(ee)}else d.appendChild(j),d.appendChild(E),d.appendChild(P),d.appendChild(O),d.appendChild(T),d.appendChild(A);S.appendChild(d);let $=null;const U=[];let x=!1;function F(){if(M(f.value))return f.value(w);if(f.value!==void 0&&!I(f.value))return f.value;const te=I(f.value)?f.value:f,ee=te.of,re=te.fn||"sum",se=te.show;return w?re==="count"?z().length:ee?se?q(String(ee),String(re),String(se)):C()==="filtered"&&w.statistics&&M(w.statistics.reduce)?w.statistics.reduce(String(ee),String(re)):_(z().map(de=>p(de,String(ee))),String(re)):null:null}function C(){return String(f.scope||"filtered")}function z(){if(!w||!w.rows)return[];const te=C();if(te==="all"){const re=[];return M(w.rows.forEachAll)&&w.rows.forEachAll(se=>{se.group||re.push(l(se))}),re}if(te==="selected")return(w.selection&&M(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(l);const ee=[];return M(w.rows.forEach)&&w.rows.forEach(re=>{re.group||ee.push(l(re))}),ee}function q(te,ee,re){if(ee!=="min"&&ee!=="max")return N(`stat.show.${ee}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ee}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,de=null;for(const ie of z()){const oe=Number(p(ie,te));Number.isFinite(oe)&&(se===null||(ee==="max"?oe>se:oe<se))&&(se=oe,de=ie)}return de===null?null:p(de,re)}function Q(te){if(M(f.format))return String(f.format(te,w));if(te==null)return f.empty??"—";const ee=I(f.value)?f.value:f,re=ee.show||ee.of;if((ee.show?!0:o.has(String(ee.fn||"sum")))&&w&&re&&M(w.columns?.get)){const de=w.columns.get(String(re));if(de&&M(de.formatValue))return de.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(f.decimals??2):String(te)}function Y(te){return te?(w&&w.messages||D).t(`stat.tone.${te}`):""}function J(){if(x)return;const te=F(),ee=r(f)&&!!w&&!s(w),re=ee?null:te,se=M(f.baseline)?f.baseline(w):f.baseline;$=re,j.textContent=f.title??"",j.hidden=!f.title,E.textContent=Q(re),P.hidden=!ee,ee&&(P.textContent=w.messages.t("stat.noData"));const de=ee||se===void 0||se===null?n:t(typeof re=="number"?re:null,Number(se)),ie=i(de.direction,f.goodWhen||"up");if(T.hidden=de.change===null,de.change!==null){const pe=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Me=de.percent===null?Q(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;T.textContent=`${pe} ${Me}`,T.setAttribute("data-tone",ie),T.setAttribute("data-direction",de.direction)}const oe=M(f.interval)?f.interval(re,w):null,ue=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);O.hidden=!ue,ue&&(O.textContent=`${Q(oe.lower)} – ${Q(oe.upper)}`,Number.isFinite(oe.confidence)&&O.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const ce=ee?c:f.bands?a(re,f.bands,w):null;ce?d.setAttribute("data-tone",ce):d.removeAttribute("data-tone"),A.textContent=M(f.footer)?String(f.footer(re,w)):f.footer??"",A.hidden=!A.textContent,d.setAttribute("aria-label",[f.title,E.textContent,ee?P.textContent:"",ue?O.textContent:"",de.change===null?"":T.textContent,de.change===null?"":Y(ie),A.textContent].filter(Boolean).join(", "))}if(w&&M(w.on)&&f.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ee=re=>{te==="model:changed"&&!B(re)||J()};w.on(te,ee),U.push(()=>M(w.off)&&w.off(te,ee))}return J(),{element:()=>d,value:()=>$,refresh:J,destroy(){x=!0;for(const te of U)try{te()}catch{}U.length=0,d.remove()}}}function l(g){return I(g)&&"data"in g?g.data:g}function p(g,f){if(!I(g))return;if(!f.includes("."))return g[f];let w=g;for(const S of f.split(".")){if(!I(w))return;w=w[S]}return w}function m(g,f){if(g&&typeof g=="object")return g;if(typeof g!="string")return null;const w=f&&f.element&&f.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(g):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),je("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return _}});const M=V("packages/core/src/internal/util.js").isObject,N=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class _{#e;#t;#n;#r=null;#o=[];constructor({grid:B,document:G,kpis:D}){this.#e=B,this.#t=G,this.#n=Array.isArray(D)?D.filter(M):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const G=this.#t.createElement("div");G.className=`lattice ${W.band}`,G.setAttribute("role","group"),G.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=G;for(const D of this.#n){const v=N({...D,grid:this.#e,container:G});this.#o.push(v)}}destroy(){for(const B of this.#o)try{B.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),je("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const M=V("packages/core/src/index.js").createHeadlessGrid,N=V("packages/core/src/defaults.js").applyDefaults,_=V("packages/core/src/export/download.js").downloadBlob,H=V("packages/core/src/internal/util.js"),B=H.fail,G=H.isFunction,D=H.warnOnce,k=V("packages/dom/src/localviews.js").createLocalViewStorage,c=V("packages/dom/src/renderer/index.js").DomRenderer,n=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),i=t.icon,a=t.iconNames,s=V("packages/dom/src/editors/index.js").editors,l=V("packages/dom/src/filters/index.js").filters,p=V("packages/dom/src/ui/index.js"),m=p.StatusBar,b=p.TooltipManager,g=p.Pagination,f=p.GroupByZone,S=V("packages/dom/src/ui/celltooltip.js").CellTooltips,d=V("packages/dom/src/filtermenu.js").FilterMenu,E=V("packages/dom/src/columnmenu.js").ColumnMenu,T=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,$=V("packages/dom/src/alignedgrids.js").AlignedGrids,x=V("packages/dom/src/columntagbar.js").ColumnTagBar,C=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,Q=V("packages/dom/src/toolpanelmount.js"),Y=Q.ToolPanelDock,J=Q.panelHost,ee=V("packages/dom/src/celledit.js").CellEditController,se=V("packages/dom/src/editbar.js").EditBar,ie=V("packages/dom/src/rangeselect.js").RangeController,ue=V("packages/core/src/model/selection.js").resolveSelectionConfig,pe=V("packages/dom/src/importer.js").ImportController,$e=V("packages/dom/src/historybar.js").HistoryBar,ke=V("packages/dom/src/diffpaint.js").DiffPainter,Ee=V("packages/dom/src/detailhost.js").DetailHost,ze=V("packages/dom/src/highlightpaint.js").HighlightPainter,Xe=V("packages/dom/src/findpaint.js").FindPainter,Pe=V("packages/dom/src/findbar.js").FindBar,He=V("packages/dom/src/redactpaint.js").RedactionPainter,st=V("packages/dom/src/validationpaint.js").ValidationPainter,bt=V("packages/dom/src/presentation.js").PresentationController,Tt=V("packages/dom/src/capture.js").captureElement,It=V("packages/dom/src/annotate.js").AnnotationLayer,Yt=V("packages/dom/src/timelinebar.js").TimelineBar,fe=V("packages/dom/src/commentpaint.js").CommentPainter,xe=V("packages/dom/src/presencepaint.js").PresencePainter,_e=V("packages/dom/src/commentpanel.js").CommentPanel,gt=V("packages/dom/src/watermark.js").Watermark,Oe=V("packages/dom/src/maximise.js").Maximiser,Ne=V("packages/dom/src/promptbar.js").PromptBar,ve=V("packages/dom/src/kpistrip.js").KpiStrip;function Te(Le,rt,et){const it=rt==="redo"?"toolbar.redo":"toolbar.undo";return!et||!et.label?Le(it):Le(rt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:et.label})}const Ce=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Re=2e3;function Be(Le,rt,et){const it=rt.annotate===!0?We(Le):[];if(rt.actions===!1)return[];if(rt.actions===void 0&&rt.side!=="left")return it;const Et=Array.isArray(rt.actions)?rt.actions:Ce,Nt=(Ot,Vt)=>Le.messages.t(Ot,Vt),dt={undo:{name:"undo",title:()=>Te(Nt,"undo",Le.history.peek("undo")),icon:"undo",run:()=>Le.history.undo(),enabled:()=>Le.history.canUndo()},redo:{name:"redo",title:()=>Te(Nt,"redo",Le.history.peek("redo")),icon:"redo",run:()=>Le.history.redo(),enabled:()=>Le.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Le.export.csv({download:!0,fileName:rt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Le.export.excel({download:!0,fileName:rt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Le.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Le.export.print()},pause:{name:"pause",title:()=>{if(!Le.updates.paused)return Nt("toolbar.pause");const Ot=Le.updates.stats().pending;return Ot?Nt("toolbar.applyHeld",{count:Ot}):Nt("toolbar.resume")},icon:()=>Le.updates.paused?"play":"pause",run:()=>Le.updates.paused?Le.updates.resume():Le.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Le.state.reset(),enabled:()=>Le.state.modified()},maximise:{name:"maximise",title:()=>Nt(et&&et.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>et&&et.active()?"minimise":"maximise",run:()=>et.toggle()}};return et||delete dt.maximise,Et.map(Ot=>Ot==="-"?{name:"-",separator:!0}:typeof Ot=="string"?dt[Ot]:!Ot||typeof Ot!="object"||!Ot.name?null:{...Ot,run:G(Ot.run)?()=>Ot.run({grid:Le,keys:Le.selection&&G(Le.selection.keys)?Le.selection.keys():[],cells:Le.selection&&G(Le.selection.cells)?Le.selection.cells():[]}):void 0}).filter(Boolean).concat(it)}function We(Le){const rt=it=>Le.messages.t(it),et={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(it=>({name:it,title:()=>rt(`toolbar.annotate.${it}`),icon:et[it],run:()=>Le.annotate?.use(it),active:()=>Le.annotate?.tool===it,annotation:!0}))}const ft=["pen","arrow","rect","highlight"];function at(Le){return{rowCount:()=>{if(G(Le.rows.matchCount))return Le.rows.matchCount();const rt=Le.pagination&&G(Le.pagination.get)?Le.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:Le.rows.count()},totalRowCount:()=>G(Le.rows.totalCount)?Le.rows.totalCount():Le.rows.count(),selectedCount:()=>{const rt=Le.selection&&Le.selection.keys?Le.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=Le.selection;return!rt||!G(rt.cells)?[]:rt.cells().map(({key:et,colId:it})=>Le.rows.value(et,it))},hiddenUnresolved:()=>G(Le.comments&&Le.comments.hiddenUnresolved)?Le.comments.hiddenUnresolved():0,progress:()=>G(Le.source&&Le.source.progress)?Le.source.progress():null,updateStats:()=>Le.updates?Le.updates.stats():null}}function mt(Le,rt){for(const[et,it]of Object.entries(s||{}))Le.register("editor",et,it);for(const[et,it]of Object.entries(l||{}))Le.register("filter",et,it);for(const[et,it]of Object.entries(rt.components||{}))Le.register("component",et,it);for(const[et,it]of Object.entries(rt.pipes||{}))Le.register("pipe",et,it);for(const[et,it]of Object.entries(rt.totalFns||{}))Le.register("totalFn",et,it)}function ct(Le,rt,et,it,Et,Nt){const dt=[],Ot=rt.viewport;let Vt=null;if(et.maximise!==!1&&(Vt=new Oe({element:Nt,document:it,onChange:()=>rt.invalidate("all"),captureScroll:()=>rt.scrollState(),restoreScroll:tt=>rt.restoreScroll(tt)}),Le.maximise=Vt,dt.push(()=>Vt.destroy())),et.statusBar){const tt=typeof et.statusBar=="object"?et.statusBar:{},pt=new m;pt.init({document:it,host:at(Le),panels:tt.panels,registry:tt.registry,locale:Le.get("locale"),messages:Le.messages}),Ot.statusBar.appendChild(pt.element());const Pt=()=>{const nn=Ot.statusBar.offsetHeight||Ot.statusBar.getBoundingClientRect?.().height||0;Ot.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},$t=()=>{pt.refresh(),Pt()},Ht=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Le.on(nn,$t));$t(),Pt(),dt.push(()=>{for(const nn of Ht)nn();Ot.root.style.removeProperty("--lattice-status-height"),pt.destroy?.()})}const Wt=ue(et.selection);if(Wt.ranges){const tt=new ie({grid:Le,renderer:rt,document:it});tt.mount(),Le.ranges=tt,dt.push(()=>tt.destroy())}if(et.import){const tt=new pe({grid:Le,renderer:rt,document:it,settings:typeof et.import=="object"?et.import:{}});Le.importer=tt,dt.push(()=>tt.destroy())}if(et.historyBar){const tt=typeof et.historyBar=="object"?et.historyBar.element:null,pt=new $e;pt.init({document:it,host:{undo:()=>Le.history.undo(),redo:()=>Le.history.redo(),canUndo:()=>Le.history.canUndo(),canRedo:()=>Le.history.canRedo(),peek:$t=>Le.history.peek($t),list:()=>Le.history.list()},props:typeof et.historyBar=="object"?et.historyBar:{}}),(tt||Ot.root).appendChild(pt.element());const Pt=[Le.on("history:changed",()=>pt.refresh())];Le.historyBar=pt,dt.push(()=>{for(const $t of Pt)$t();pt.destroy()})}if(et.diff){const tt=new ke({grid:Le,renderer:rt});tt.mount(),Le.diffPainter=tt,dt.push(()=>tt.destroy())}if(et.ai&&G(et.ai.ask)){const tt=new Ne;tt.init({document:it,grid:Le,ask:et.ai.ask,schemaOptions:et.ai.schemaOptions,context:et.ai.context,placeholder:et.ai.placeholder});const pt=et.ai.element||Ot.root;pt===Ot.root?pt.insertBefore(tt.element(),pt.firstChild):pt.appendChild(tt.element()),Le.promptBar=tt,dt.push(()=>tt.destroy())}if(et.groupPanel){const tt=typeof et.groupPanel=="object"?et.groupPanel:{},pt=new f;pt.init({document:it,grid:Le,host:J(Le,it,(Pt,$t)=>rt.announce?.(Pt,$t)),props:{header:Ot.header,hint:tt.hint}}),Ot.root.insertBefore(pt.element(),Ot.header),Le.groupPanel=pt;for(const Pt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])G(Le.on)&&dt.push(Le.on(Pt,()=>pt.refresh()));dt.push(()=>pt.destroy())}if(et.kpis){const tt=new ve({grid:Le,document:it,kpis:et.kpis});tt.active&&(tt.mount(),Ot.root.insertBefore(tt.element(),Ot.header),Le.kpiStrip=tt,dt.push(()=>tt.destroy()))}if(et.toolPanel){const tt=typeof et.toolPanel=="object"?et.toolPanel:{},pt=new Y({grid:Le,document:it,root:Ot.root,panels:tt.panels,openPanel:tt.openPanel,side:tt.side,icons:tt.icons,actions:Be(Le,tt,Vt),announce:(Pt,$t)=>rt.announce?.(Pt,$t)});pt.mount(),Le.toolPanel=pt,dt.push(()=>pt.destroy()),tt.annotate===void 0&&(dt.push(Le.on("presentation:started",()=>{for(const Pt of We(Le))pt.addAction(Pt)})),dt.push(Le.on("presentation:ended",()=>{for(const Pt of ft)pt.removeAction(Pt)})))}if(et.pagination){const tt=typeof et.pagination=="object"?et.pagination:{},pt=new g;pt.init({document:it,pageSize:tt.pageSize,pageSizes:tt.pageSizes,page:tt.page,total:tt.total,locale:Le.get("locale"),messages:Le.messages,onChange:({page:Ht,pageSize:nn})=>Le.pagination.set({page:Ht,pageSize:nn})});const Pt=()=>{const Ht=Le.pagination.get();pt.total=Ht.total,pt.counting=Ht.counting===!0,pt.page=Ht.page,pt.paint()};Le.pagination.set({pageSize:pt.pageSize}),Pt();const $t=["rows:changed","filter:changed","model:changed"].map(Ht=>Le.on(Ht,Pt));Ot.statusBar.appendChild(pt.element()),dt.push(()=>{for(const Ht of $t)Ht();pt.destroy?.()})}if(et.edit!==!1)if(et.editBar){const tt=new se({grid:Le,document:it,root:Ot.root});tt.mount(),Le.editBar=tt,dt.push(()=>tt.destroy())}else{const tt=new ee({grid:Le,document:it,renderer:rt,registry:Et,cellLayer:rt.cellLayer});tt.mount(),dt.push(()=>tt.destroy())}const an=new d({grid:Le,document:it,layer:Ot.overlays,registry:Et});an.mount(),dt.push(()=>an.destroy());const ln=new E({grid:Le,document:it,host:Ot.root,cellMenu:et.contextMenu!==!1,headerMenu:et.columnMenu!==!1,items:G(et.contextMenu)?et.contextMenu:void 0,headerItems:G(et.columnMenu)?et.columnMenu:void 0});if(ln.mount(),dt.push(()=>ln.destroy()),Array.isArray(et.alignedGrids)&&et.alignedGrids.length){const tt=new $;tt.add(Le);for(const pt of et.alignedGrids)pt&&pt!==Le&&tt.add(pt);dt.push(()=>tt.destroy())}const zt=new q({grid:Le,renderer:rt,document:it,registry:Et});zt.active&&(zt.mount(),dt.push(()=>zt.destroy())),Object.defineProperty(Le,"form",{configurable:!0,value:Object.freeze({open(tt){return zt.active?zt.openRow(tt):!1},close(){zt.active&&zt.close()},save(){return zt.active?zt.save():!1},isOpen(){return zt.active?zt.open:!1}})}),dt.push(()=>{delete Le.form}),Object.defineProperty(Le,"icons",{configurable:!0,value:Object.freeze({get(tt){const pt=i(tt);return pt?{viewBox:pt.viewBox,paths:pt.paths.slice(),paint:pt.paint==="stroke"?"stroke":"fill"}:null},names(){return a()}})}),dt.push(()=>{delete Le.icons});const un=new x({grid:Le,renderer:rt,document:it});un.active&&(un.mount(),dt.push(()=>un.destroy()));const cn=new C({grid:Le,renderer:rt,document:it});cn.active&&(cn.mount(),dt.push(()=>cn.destroy()));const rn=new P({grid:Le,renderer:rt,document:it});if(rn.active){rn.mount(),rn.paint();const tt=Le.on("render:done",()=>rn.paint());dt.push(()=>{tt(),rn.destroy()})}if(et.shortcuts!==!1){const tt=new T({grid:Le,renderer:rt});tt.mount(),dt.push(()=>tt.destroy())}const jt=new ze({grid:Le,renderer:rt,window:it.defaultView||void 0});jt.mount(),dt.push(()=>jt.destroy());const Rt=new Xe({grid:Le,renderer:rt,window:it.defaultView||void 0});if(Rt.mount(),dt.push(()=>Rt.destroy()),et.find!==!1){const tt=new Pe({grid:Le,renderer:rt,document:it,settings:et.find});tt.mount(),dt.push(()=>tt.destroy())}const Ft=new He({grid:Le,renderer:rt});Ft.mount(),dt.push(()=>Ft.destroy());const Ut=new st({grid:Le,renderer:rt});Ut.mount(),dt.push(()=>Ut.destroy());const Qt=new bt({grid:Le,renderer:rt,maximiser:Vt});Qt.mount(),dt.push(()=>Qt.destroy());const qt=new Yt({grid:Le,renderer:rt});qt.mount(),dt.push(()=>qt.destroy()),et.environment||Le.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 Zt=null;for(const[tt,pt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])dt.push(Le.on(tt,()=>{Zt=pt}));dt.push(Le.on("render:done",tt=>{Le.diagnostics.render(Zt||tt.cause,tt.phases),Zt=null}));const en=new xe({grid:Le,renderer:rt});if(en.mount(),dt.push(()=>en.destroy()),dt.push(Le.on("presence:lockRefused",tt=>en.announceRefusal(tt.peer))),Le.presence&&Le.presence.enabled){for(const Pt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])dt.push(Le.on(Pt,()=>Le.presence.publish()));let tt="";dt.push(Le.on("render:done",()=>{const Pt=rt.focusState&&rt.focusState(),$t=Pt?`${Pt.rowKey}${Pt.colId}`:"";$t!==tt&&(tt=$t,Le.presence.publish())}));const pt=Nt.ownerDocument;if(pt&&G(pt.addEventListener)){const Pt=()=>Le.presence.setPaused(pt.visibilityState==="hidden");pt.addEventListener("visibilitychange",Pt),Pt(),dt.push(()=>pt.removeEventListener("visibilitychange",Pt))}}const Xt=new fe({grid:Le,renderer:rt});Xt.mount(),dt.push(()=>Xt.destroy());const dn=new _e({grid:Le,renderer:rt});dn.mount(),dt.push(()=>dn.destroy()),dt.push(Le.on("facet:computed",()=>rt.refreshHeader?.())),Wt&&Wt.headerCheckbox===!0&&dt.push(Le.on("selection:changed",()=>rt.refreshHeader?.())),dt.push(Le.on("facet:expanded",()=>rt.invalidate("columns"))),dt.push(Le.on("model:changed",()=>rt.invalidate("rows")));const Kt=(tt,pt)=>rt.announce?.(tt,pt),fn=Le.messages,Bt=(tt,pt)=>fn.t(tt,pt),pn=tt=>Bt("count.rows",{count:tt});dt.push(Le.on("sort:changed",()=>{const tt=Le.sort.get();if(!tt.length){Kt(Bt("a11y.sort.cleared"));return}const pt=tt.map(Pt=>{const $t=Le.columns.get(Pt.col);return Bt("a11y.sort.column",{column:$t&&$t.title||Pt.col,direction:Bt(Pt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Kt(Bt("a11y.sort.by",{columns:fn.list(pt)}))})),dt.push(Le.on("filter:changed",()=>{const tt=Le.rows.matchCount?Le.rows.matchCount():Le.rows.count(),pt=Le.rows.totalCount?Le.rows.totalCount():tt;Kt(tt===pt?Bt("a11y.filter.cleared",{rows:pn(pt)}):Bt("a11y.filter.applied",{shown:pn(tt),total:pn(pt)}))})),dt.push(Le.on("selection:changed",()=>{const tt=Le.selection.keys().length;Kt(tt===0?Bt("a11y.selection.cleared"):Bt("a11y.selection.count",{count:tt}))})),dt.push(Le.on("group:toggled",tt=>{const pt=Le.rows.byKey?Le.rows.byKey(tt.key):null,Pt=(pt&&(pt.groupLabel??pt.groupValue))??tt.key;Kt(Bt(tt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Pt,rows:pn(Le.rows.count())}))})),dt.push(Le.on("column:grouped",tt=>{const pt=Array.isArray(tt.columns)?tt.columns:[];if(!pt.length){Kt(Bt("a11y.group.cleared"));return}const Pt=pt.map($t=>{const Ht=Le.columns.get($t);return Ht&&Ht.title||$t});Kt(Bt("a11y.group.by",{columns:fn.list(Pt)}))})),dt.push(Le.on("page:changed",tt=>{const pt=Number(tt.size)||0,Pt=Number(tt.total)||0,$t=pt>0?Math.max(1,Math.ceil(Pt/pt)):1;Kt(Bt("a11y.page.position",{page:(Number(tt.page)||0)+1,pages:$t}))}));let tn={added:0,removed:0},_t=null;const En=()=>{_t=null;const tt=[];tn.added&&tt.push(Bt("count.rowsAdded",{count:tn.added})),tn.removed&&tt.push(Bt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},tt.length&&Kt(fn.list(tt))};dt.push(Le.on("rows:changed",tt=>{if(!tt||typeof tt.added!="number")return;const pt=Number(tt.added)||0,Pt=Number(tt.removed)||0;!pt&&!Pt||(tn.added+=pt,tn.removed+=Pt,_t||(_t=setTimeout(En,Re)))})),dt.push(()=>{_t&&clearTimeout(_t)}),dt.push(Le.on("rows:paused",()=>{_t&&(clearTimeout(_t),_t=null),tn={added:0,removed:0},Kt(Bt("a11y.updates.paused"),{repeat:!0})})),dt.push(Le.on("rows:resumed",()=>Kt(Bt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:tt,first:pt}=hn;if(hn={count:0,first:null},!tt||!pt)return;const Pt=Le.columns.get(pt.colId),$t=Pt&&Pt.title||pt.colId,Ht=pt.reason?Bt("a11y.edit.reason",{reason:pt.reason}):"";if(tt===1){const nn=pt.restored===void 0||pt.restored===null||pt.restored===""?Bt("value.empty"):String(pt.restored);Kt(Bt("a11y.edit.refusedOne",{column:$t,value:nn,reason:Ht}),{repeat:!0});return}Kt(Bt("a11y.edit.refusedMany",{count:tt,reason:Ht}),{repeat:!0})};dt.push(Le.on("cell:reverted",tt=>{!tt||!tt.applied||(hn.count+=1,hn.first||(hn.first=tt),mn||(mn=setTimeout(Sn,150)))})),dt.push(()=>{mn&&clearTimeout(mn)}),dt.push(Le.on("history:applied",tt=>{const pt=!!(tt&&tt.direction==="redo"),Pt=tt&&tt.step&&tt.step.label;Kt(Pt?Bt(pt?"a11y.history.redo":"a11y.history.undo",{label:Pt}):Bt(pt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new It({grid:Le,renderer:rt,seed:et.state&&Array.isArray(et.state.annotations)?et.state.annotations:null});gn.mount(),dt.push(()=>gn.destroy()),Le.annotate=gn,Le.capture=async(tt={})=>{const{blob:pt,width:Pt,height:$t}=await Tt(rt.viewport.root,tt);return(tt.download===!0||tt.download!==!1&&tt.fileName)&&_(pt,tt.fileName||`${Le.get("exportName")||"grid"}.png`),Le.emit("presentation:captured",{width:Pt,height:$t,bytes:pt.size,mimeType:pt.type,fileName:tt.fileName||null},"api"),pt};const On=new gt({grid:Le,document:it,element:Ot.overlays,window:it.defaultView||void 0});On.mount(),dt.push(()=>On.destroy());const Tn=new b({grid:Le,document:it,element:Ot.overlays});Tn.mount?.(),dt.push(()=>Tn.destroy?.());const jn=new S({grid:Le,host:Le.rendererHost(),viewport:Ot,document:it});return jn.mount(),dt.push(()=>jn.destroy()),dt}function vt(Le){const rt=[],et=it=>{if(it&&(it.__lattice&&rt.push(it),it.children))for(const Et of it.children)et(Et)};return et(Le),rt}function St(Le,rt={}){(!Le||typeof Le!="object"||!("appendChild"in Le))&&B("createGrid needs a host element as its first argument."),rt=N(rt);const et=Le.ownerDocument||(typeof document<"u"?document:null);et||B("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const it=et.documentElement&&et.documentElement.lang,Et=!rt.licence&&G(et.querySelector)?et.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...rt};if(!rt.locale&&it&&(Nt.locale=it),Et&&(Nt.licence=Et),rt.views&&rt.views.local)if(rt.views.storage)D("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const zt=rt.views.local===!0?{}:rt.views.local;Nt.views={...rt.views,storage:k(zt)}}const dt=M(Nt),Ot=dt.rendererHost();Ot.document=et,mt(Ot.registry,rt),Ot.cellLayer=n(Ot),Ot.detailHost=new Ee({grid:dt,document:Le.ownerDocument||globalThis.document,createGrid:(zt,un)=>St(zt,un)});const Vt=new c(Le,Ot),Wt=dt.on("detail:toggled",()=>{Ot.detailHost.syncTarget(),Ot.detailHost.prune()}),sn=dt.on("config:changed",zt=>{zt&&zt.key==="detail"&&Ot.detailHost.reconfigure()});dt.on("destroy",()=>{Wt(),sn(),Ot.detailHost.destroy()}),Ot.detailHost.syncTarget(),dt.attachRenderer(Vt),Vt.mount();const an=ct(dt,Vt,rt,et,Ot.registry,Le),ln=dt.destroy.bind(dt);return dt.destroy=()=>{for(const zt of an)try{zt()}catch{}Le.__lattice===dt&&(Le.__lattice=null),ln()},Le.__lattice=dt,dt}}),je("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return n}});const Z=V("packages/core/src/internal/util.js"),M=Z.isFunction,I=Z.warnOnce,W=V("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,H=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,G=V("packages/dom/src/createGrid.js").createGrid,D=new Set([...Object.keys(W),...Object.keys(H)]);function v(t,i){for(const a of t.children)if(a.tagName===i.toUpperCase())return a;return null}function k(t,i){const a=[];for(const r of t.children)r.tagName===i.toUpperCase()&&a.push(r);return a}function y(t,i){const a=M(t.getAttribute)?t.getAttribute("data-field"):null;return a||String(t.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${i}`}function c(t){const i=t.trim();if(i==="")return null;if(i==="true"||i==="false")return i==="true";const a=Number(i);return Number.isFinite(a)&&i!==""?a:i}function o(t){const i=v(t,"thead"),a=v(i||t,"tr"),s=(a?k(a,"th").length?k(a,"th"):k(a,"td"):[]).map((m,b)=>{const g=y(m,b),f={id:g,field:g,title:String(m.textContent||"").trim()||g},w=M(m.getAttribute)?m.getAttribute("data-type"):null;w&&(D.has(w)?f.type=w:I(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${g}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const S=M(m.getAttribute)?m.getAttribute("data-format"):null;return S&&(f.format=S),f}),u=v(t,"tbody"),p=(u?k(u,"tr"):k(t,"tr").filter(m=>m!==a)).map((m,b)=>{const g=k(m,"td"),w={__row:(M(m.getAttribute)?m.getAttribute("data-id"):null)||`row${b}`};return s.forEach((S,h)=>{w[S.field]=g[h]?c(String(g[h].textContent||"")):null}),w});return{columns:s,rows:p}}function n(t,i={}){const{columns:a,rows:r}=o(t),s=t.ownerDocument.createElement("div");return t.parentNode.insertBefore(s,t),t.parentNode.removeChild(t),G(s,{rowKey:"__row",columns:a,rows:r,...i,columns:i.columns!==void 0?i.columns:a,rows:i.rows!==void 0?i.rows:r})}}),je("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return D}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/dom/src/createGrid.js").createGrid,_=V("packages/dom/src/hydrate.js").hydrateTable;function H(v,k){const y=[];return M(v.hasAttribute)&&v.hasAttribute(k)&&y.push(v),M(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${k}]`)),y}function B(v){const k=v.parentNode;if(!k||!k.children)return null;const y=[...k.children],c=y.indexOf(v),o=[y[c+1],y[c-1]];for(const n of o)if(n&&n.tagName==="SCRIPT"&&M(n.getAttribute)&&n.hasAttribute("data-lattice-config"))return n;return null}function G(v){const k=B(v);if(!k)return{};try{return JSON.parse(k.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function D(v){const k=v||(typeof document<"u"?document:null);if(!k)return[];const y=[];for(const c of H(k,"data-lattice-grid")){if(c.__lattice)continue;const o=G(c);y.push(c.tagName==="TABLE"?_(c,o):N(c,o))}return y}}),je("packages/modules/htmx/controller.js",function(e,V){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return N}});const M=V("packages/core/src/internal/util.js").isFunction;function I(W,_){if(!W||!M(_))return 0;let H=0;for(const B of _(W))B.__lattice&&M(B.__lattice.destroy)&&(B.__lattice.destroy(),H+=1);return H}function N(W,_){return!W||!M(_)?[]:_(W)}}),je("packages/modules/htmx/history.js",function(e,V){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return B}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/core/src/model/state.js"),N=I.serialiseState,W=I.restoreState;function _(G,D){const v=[];return G&&(M(G.hasAttribute)&&G.hasAttribute(D)&&v.push(G),M(G.querySelectorAll)&&v.push(...G.querySelectorAll(`[${D}]`))),v}function H(G,D){if(!G||!M(D))return 0;let v=0;for(const k of D(G))!k.__lattice||!M(k.setAttribute)||(k.setAttribute("data-lattice-state",N(k.__lattice)),v+=1);return v}function B(G,D){if(!G)return 0;const v=_(G,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of v)for(;y.firstChild;)y.removeChild(y.firstChild);v.length&&M(D)&&D(G);let k=0;for(const y of _(G,"data-lattice-state")){const c=M(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!c||!y.__lattice||(W(y.__lattice,c),k+=1)}return k}}),je("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 H}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return D}});const Z=V("packages/dom/src/hydrate.js"),M=Z.coerceCell,I=Z.childTags,N=Z.firstChildTag,W=5e3;function _(v,k={}){const y=v.pagination.get(),c=k.limit??(y.pageSize||100);return{offset:k.offset??(y.page??0)*c,limit:c,sort:JSON.stringify(v.sort.get()),filters:JSON.stringify(v.filters.get())}}function H(v,k){let y;if(v.tagName==="TR")y=[v];else{const c=N(v,"tbody")||v;y=I(c,"tr").length?I(c,"tr"):I(v,"tr")}return y.map((c,o)=>{const n=I(c,"td"),i={__row:(typeof c.getAttribute=="function"?c.getAttribute("data-id"):null)||`row${o}`};return k.forEach((a,r)=>{i[a.field]=n[r]?M(String(n[r].textContent||"")):null}),i})}function B(v){const k=JSON.parse(v);return Array.isArray(k)?{rows:k,total:void 0}:{rows:k.rows||[],total:k.total}}function G(v){v<=W||console.warn(`lattice-grid/htmx: parsed ${v} rows from an HTML fragment, past the documented ${W}-row boundary for that path. Consider a JSON response for this size.`)}function D(v,k){if(/json/i.test(v.contentType||""))return B(v.text);const c=H(v.fragment,k);return G(c.length),{rows:c,total:void 0}}}),je("packages/modules/htmx/oob.js",function(e,V){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const M=V("packages/core/src/internal/util.js").isFunction,N=V("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(_,H={}){const B=H.doc||(typeof document<"u"?document:null);if(!B||!M(B.addEventListener))return()=>{};const G=D=>{const v=D.detail,k=v&&v.target,y=k&&M(k.getAttribute)?k.getAttribute("data-lattice-row"):null;if(!y||!v.fragment)return;const c=H.columns||_.columns.visible().map(n=>({field:n.field||n.id})),[o]=N(v.fragment,c);o&&(delete o.__row,_.rows.apply({update:[{...o,[_.get("rowKey")]:y}]})),v.shouldSwap=!1};return B.addEventListener("htmx:oobBeforeSwap",G),()=>B.removeEventListener("htmx:oobBeforeSwap",G)}}),je("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 G}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return D}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/modules/htmx/rowmodel.js"),N=I.queryParams,W=I.ingestResponse,_="lattice:query-changed";function H(v,k){const y=v.createElement("tbody");if(M(v.createRange)){const c=v.createRange();c.selectNodeContents(y),y.appendChild(c.createContextualFragment(k))}return y}function B(v,k,y={}){const c=k.ownerDocument;let o=!1;const n=l=>{l.target!==k||!l.detail||!l.detail.parameters||Object.assign(l.detail.parameters,N(v,y))},t=l=>{l.target===k&&(o=!0)},i=l=>{if(o=!1,l.target!==k)return;const p=l.detail&&l.detail.xhr&&l.detail.xhr.status,m=p?`Could not load rows (server responded ${p}).`:"Could not load rows, the request failed to reach the server.";v.overlay.show("empty",m)},a=l=>{if(l.target!==k||(o=!1,l.detail&&(l.detail.shouldSwap=!1),!l.detail||!l.detail.xhr||l.detail.isError))return;const{xhr:p}=l.detail,m=M(p.getResponseHeader)&&p.getResponseHeader("Content-Type")||"",b=l.detail.serverResponse??p.responseText??"",g=y.columns||v.columns.visible().map(S=>({field:S.field||S.id})),f=/json/i.test(m)?null:H(c,b),{rows:w}=W({contentType:m,text:b,fragment:f},g);v.rows.load(w)},r=()=>{if(o&&M(k.dispatchEvent)){const p=c.defaultView&&c.defaultView.CustomEvent;k.dispatchEvent(p?new p("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const l=globalThis.htmx;l&&M(l.trigger)&&l.trigger(k,_)};c.addEventListener("htmx:configRequest",n),c.addEventListener("htmx:beforeRequest",t),c.addEventListener("htmx:beforeSwap",a),c.addEventListener("htmx:responseError",i),c.addEventListener("htmx:sendError",i);const s=v.on("sort:changed",r),u=v.on("filter:changed",r);return()=>{c.removeEventListener("htmx:configRequest",n),c.removeEventListener("htmx:beforeRequest",t),c.removeEventListener("htmx:beforeSwap",a),c.removeEventListener("htmx:responseError",i),c.removeEventListener("htmx:sendError",i),s(),u()}}const G="lattice:scroll-near-end";function D(v,k,y={}){const c=k.ownerDocument,o=y.threshold??20;let n=!1,t=!1;const i=h=>{h.target!==k||!h.detail||!h.detail.parameters||Object.assign(h.detail.parameters,N(v,{...y,offset:v.rows.count()}))},a=h=>{h.target===k&&(n=!0)},r=h=>{h.target===k&&(n=!1)},s=h=>{if(h.target!==k||(n=!1,h.detail&&(h.detail.shouldSwap=!1),!h.detail||!h.detail.xhr||h.detail.isError))return;const{xhr:d}=h.detail,j=M(d.getResponseHeader)&&d.getResponseHeader("Content-Type")||"",E=h.detail.serverResponse??d.responseText??"",O=y.columns||v.columns.visible().map(P=>({field:P.field||P.id})),T=/json/i.test(j)?null:H(c,E),{rows:A}=W({contentType:j,text:E,fragment:T},O);if(!A.length){t=!0;return}v.rows.apply({add:A})},u=()=>{t=!1},l=()=>{if(n||t)return;const h=globalThis.htmx;h&&M(h.trigger)&&h.trigger(k,G)};let p=!1;const m=()=>{p=!0},b=({last:h})=>{p&&(p=!1,(v.rows.count()===0||h>=v.rows.count()-1-o)&&l())};c.addEventListener("htmx:configRequest",i),c.addEventListener("htmx:beforeRequest",a),c.addEventListener("htmx:beforeSwap",s),c.addEventListener("htmx:responseError",r),c.addEventListener("htmx:sendError",r);const g=v.on("render:done",b),f=v.on("scroll",m),w=v.on("sort:changed",u),S=v.on("filter:changed",u);return()=>{c.removeEventListener("htmx:configRequest",i),c.removeEventListener("htmx:beforeRequest",a),c.removeEventListener("htmx:beforeSwap",s),c.removeEventListener("htmx:responseError",r),c.removeEventListener("htmx:sendError",r),g(),f(),w(),S()}}}),je("packages/modules/htmx/index.js",function(e,V){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const M=V("packages/core/src/internal/util.js").isFunction,I=V("packages/dom/src/createGrid.js"),N=I.gridElementsWithin,W=V("packages/dom/src/autoinit.js"),_=W.autoInit,H=V("packages/modules/htmx/controller.js"),B=H.destroyWithin,G=H.initWithin,D=V("packages/modules/htmx/history.js"),v=D.saveStateWithin,k=D.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return I.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return I.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 c=V("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return c.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return c.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 n=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return n.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n.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 H.destroyWithin}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return H.initWithin}}),Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return D.saveStateWithin}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return D.restoreStateWithin}});const i=V("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return i.driveOobUpdates}});const a=V("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return a.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return a.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return a.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return a.SCROLL_NEAR_END_EVENT}});const r=V("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return r.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return r.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return r.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return r.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return r.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return r.HTML_ROW_WARNING_THRESHOLD}});function s(l){const p=l||(typeof document<"u"?document:null);if(!p||!M(p.addEventListener))return()=>{};const m=w=>B(w.target,N),b=w=>G(w.detail&&w.detail.elt||w.target,_),g=w=>{v(w.detail&&w.detail.historyElt||p,N)},f=w=>{w.detail&&w.detail.cacheMiss||k(p,_)};return p.addEventListener("htmx:beforeCleanupElement",m),p.addEventListener("htmx:load",b),p.addEventListener("htmx:beforeHistorySave",g),p.addEventListener("htmx:historyRestore",f),()=>{p.removeEventListener("htmx:beforeCleanupElement",m),p.removeEventListener("htmx:load",b),p.removeEventListener("htmx:beforeHistorySave",g),p.removeEventListener("htmx:historyRestore",f)}}s();const u=s});try{Un("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),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 m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),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 g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.75.0";async function he(){return fe}const X="1.75.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).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(/^./,q=>q.toUpperCase()):""}const r={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=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"}),x=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(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?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class ue{#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 oe{#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 m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,m=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 d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=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:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=Y(s[f]);return u}function Q(){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 _(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=c=>{if(!_(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,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),this.#e=new Uint32Array(z+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(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(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:(z(`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 T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.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 T.set(s,f),f}function re(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(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 J(i){return!i||!i.presence?null:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(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 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,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(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 Q(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 _(i){const s=he(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 Q(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),m=f instanceof Date?f.getTime():Number(f);return Q(a,m)}return X(u,f)}}function C(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=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"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 m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),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 fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,X=fe.isFunction,z=fe.pathGetter,x=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return M(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function c(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let l=d;l<h;l++)n[l-d]=r[m.values[l]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=X(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new oe(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,g]of r)e[l]!==Y&&n.set(e[l],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==Y&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new x(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new x(d)),this.#p=d}#A(e,d){const h=M(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),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]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new x(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Q:0,this.#w=d.compactRatio??_;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let l=0;l<r;l++)this.#r[h+l]=d[l];this.#i=h+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 g=n.get(l.id);g?l.appendPacked(g,h,r):l.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(Math.max(this.#s,r)),h}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 h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(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 m=0;m<M.length;m++){const e=M[m];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 oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);return{readers:u,reset(){h=new WeakMap}}}class L{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 Q{#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={...J,...u};const f=s.columns??[];this.#r=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(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=he(),{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&&he()-i<s);return this.#o+=he()-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 m=this.#r.readers.get(a.id)??(x(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);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 d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`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(d))}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 _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),!g&&l&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),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&&d(n),r[n]=l}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,X=fe.warnOnce,z=["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=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`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: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(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=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(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 J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.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,m=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 d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>h.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,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(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=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(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,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(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,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${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 C(M,i){const s=he(M)||M===""?null:String(M),u=he(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,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const H=x(p);return H===null?u(p):H}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;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<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),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 d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="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 P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(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 g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,l){const g=new Date(n);switch(l){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===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;C<f?(c=Math.sqrt(-2*Math.log(C)),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)):C<=1-f?(c=C-.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-C)),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*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const M=Math.abs(C),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 m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});class fe{#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(L){if(!Number.isFinite(L))return;this.#t++;const Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}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 L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}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(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.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"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"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 m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),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 P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),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 ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),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 Ge}}),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 lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("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:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=c(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).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 G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+N*(b-y[0]))))}if(b>=y[2]){const N=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+N*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,Oe=be)}return Oe}function Re(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of N)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,N)=>k+N,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const N=Qe(y),I=T(1-(1-N)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:N}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"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 m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(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:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=Object.freeze({...J,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 m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(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 L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(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=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,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 F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${m.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,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(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 Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,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=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(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,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(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=oe(i,c,f[t],u);return c}function oe(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",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(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=>L(i,a,u,f));const t=c.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m: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 C(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,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"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 x}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),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 he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}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 m=t.method||"modifiedZScore";if(!(re.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=x.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function M(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.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(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const te=me("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 x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),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 fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(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!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Je=Un("packages/modules/htmx/index.js"),_i=Je.createGrid,Zi=Je.gridElementsWithin,Yi=Je.readTable,Xi=Je.hydrateTable,Qi=Je.autoInit,Ji=Je.serialiseState,eo=Je.restoreState,to=Je.createHeadlessGrid,no=Je.version,ro=Je.getVersion,io=Je.Grid,oo=Je.EventBus,so=Je.Registry,ao=Je.sharedRegistry,lo=Je.registerModules,uo=Je.parseLicence,co=Je.verifyLicence,fo=Je.licenceInfo,ho=Je.watermark,mo=Je.setLicence,po=Je.licenceState,go=Je.isLocalHost,yo=Je.matchesDomain,bo=Je.LicenceHolder,wo=Je.ColumnModel,vo=Je.buildGraph,ko=Je.Lookup,So=Je.ValuePipeline,Oo=Je.compileFormat,jo=Je.compileMask,Ao=Je.specToOoxml,Po=Je.EXTENDED_TYPES,Co=Je.createRadixType,Eo=Je.RADIX_PRESETS,To=Je.parseRadix,Mo=Je.formatRadix,No=Je.createUnitType,Ro=Je.registerUnitSystem,Lo=Je.defineUnit,Fo=Je.UNIT_SYSTEMS,xo=Je.parseUnit,Do=Je.formatUnit,Io=Je.createCurrencyType,$o=Je.parseMoney,zo=Je.formatMoney,Bo=Je.convertMoney,Uo=Je.rateFunction,Ho=Je.MISSING_RATE,Vo=Je.Messages,Go=Je.createMessages,Ko=Je.auditCatalogue,Wo=Je.EN_GB,qo=Je.MESSAGE_KEYS,_o=Je.DEFAULT_LOCALE,Zo=Je.formatList,Yo=Je.resolveLocale,Xo=Je.LOCALES,Qo=Je.resolveCatalogue,Jo=Je.EN_US,es=Je.FR_FR,ts=Je.FR_CA,ns=Je.IT_IT,rs=Je.ES_ES,is=Je.PT_BR,os=Je.DE_DE,ss=Je.NL_NL,as=Je.SV_SE,ls=Je.DA_DK,us=Je.NB_NO,cs=Je.FI_FI,ds=Je.PL_PL,fs=Je.CS_CZ,hs=Je.HU_HU,ms=Je.RO_RO,ps=Je.UK_UA,gs=Je.EL_GR,ys=Je.JA_JP,bs=Je.AR,ws=Je.AR_SA,vs=Je.ColumnStore,ks=Je.Bitset,Ss=Je.Dictionary,Os=Je.MultiValue,js=Je.MaskPool,As=Je.sortColumn,Ps=Je.sortMulti,Cs=Je.evaluateFilters,Es=Je.compact,Ts=Je.testValue,Ms=Je.groupByColumns,Ns=Je.total,Rs=Je.TOTAL_FNS,Ls=Je.pivot,Fs=Je.Window,xs=Je.openWindow,Ds=Je.WINDOW_KINDS,Is=Je.evaluateFormula,$s=Je.parseFormula,zs=Je.referencesOf,Bs=Je.looksLikeFormula,Us=Je.FormulaError,Hs=Je.FUNCTIONS,Vs=Je.compileRules,Gs=Je.ingest,Ks=Je.ingestSync,Ws=Je.createSource,qs=Je.createMemorySource,_s=Je.createPagedSource,Zs=Je.createRemoteSource,Ys=Je.createStreamSource,Xs=Je.PROTOCOL,Qs=Je.createPushdownSource,Js=Je.planQuery,ea=Je.splitFilters,ta=Je.applyResidual,na=Je.capabilitiesOf,ra=Je.resolveMutate,ia=Je.NO_CAPABILITIES,oa=Je.odataAdapter,sa=Je.filtersToOData,aa=Je.conditionToOData,la=Je.restAdapter,ua=Je.DEFAULT_PARAMS,ca=Je.dfqlAdapter,da=Je.duckdbAdapter,fa=Je.filtersToSql,ha=Je.RowModel,ma=Je.createRowKey,pa=Je.SelectionModel,ga=Je.RangeModel,ya=Je.EditModel,ba=Je.ChangeModel,wa=Je.StateModel,va=Je.STATE_VERSION,ka=Je.VERSION,Sa=Je.createStat,Oa=Je.deltaOf,ja=Je.toneOf,Aa=Je.setLicense,Pa=Je.licenseInfo,Ca=Je.licenseState,Ea=Je.destroyWithin,Ta=Je.initWithin,Ma=Je.saveStateWithin,Na=Je.restoreStateWithin,Ra=Je.driveOobUpdates,La=Je.driveServerMode,Fa=Je.driveInfiniteScroll,xa=Je.QUERY_CHANGED_EVENT,Da=Je.SCROLL_NEAR_END_EVENT,Ia=Je.queryParams,$a=Je.rowsFromFragment,za=Je.rowsFromJson,Ba=Je.ingestResponse,Ua=Je.warnIfLargeHtmlPayload,Ha=Je.HTML_ROW_WARNING_THRESHOLD,Va=Je.attach;var Ga=Je.default;export{bs as AR,ws as AR_SA,ks as Bitset,fs as CS_CZ,ba as ChangeModel,wo as ColumnModel,vs as ColumnStore,ls as DA_DK,_o as DEFAULT_LOCALE,ua as DEFAULT_PARAMS,os as DE_DE,Ss as Dictionary,gs as EL_GR,Wo as EN_GB,Jo as EN_US,rs as ES_ES,Po as EXTENDED_TYPES,ya as EditModel,oo as EventBus,cs as FI_FI,ts as FR_CA,es as FR_FR,Hs as FUNCTIONS,Us as FormulaError,io as Grid,Ha as HTML_ROW_WARNING_THRESHOLD,hs as HU_HU,ns as IT_IT,ys as JA_JP,Xo as LOCALES,bo as LicenceHolder,ko as Lookup,qo as MESSAGE_KEYS,Ho as MISSING_RATE,js as MaskPool,Vo as Messages,Os as MultiValue,us as NB_NO,ss as NL_NL,ia as NO_CAPABILITIES,ds as PL_PL,Xs as PROTOCOL,is as PT_BR,xa as QUERY_CHANGED_EVENT,Eo as RADIX_PRESETS,ms as RO_RO,ga as RangeModel,so as Registry,ha as RowModel,Da as SCROLL_NEAR_END_EVENT,va as STATE_VERSION,as as SV_SE,pa as SelectionModel,wa as StateModel,Rs as TOTAL_FNS,ps as UK_UA,Fo as UNIT_SYSTEMS,ka as VERSION,So as ValuePipeline,Ds as WINDOW_KINDS,Fs as Window,ta as applyResidual,Va as attach,Ko as auditCatalogue,Qi as autoInit,vo as buildGraph,na as capabilitiesOf,Es as compact,Oo as compileFormat,jo as compileMask,Vs as compileRules,aa as conditionToOData,Bo as convertMoney,Io as createCurrencyType,_i as createGrid,to as createHeadlessGrid,qs as createMemorySource,Go as createMessages,_s as createPagedSource,Qs as createPushdownSource,Co as createRadixType,Zs as createRemoteSource,ma as createRowKey,Ws as createSource,Sa as createStat,Ys as createStreamSource,No as createUnitType,Ga as default,Lo as defineUnit,Oa as deltaOf,Ea as destroyWithin,ca as dfqlAdapter,Fa as driveInfiniteScroll,Ra as driveOobUpdates,La as driveServerMode,da as duckdbAdapter,Cs as evaluateFilters,Is as evaluateFormula,sa as filtersToOData,fa as filtersToSql,Zo as formatList,zo as formatMoney,Mo as formatRadix,Do as formatUnit,ro as getVersion,Zi as gridElementsWithin,Ms as groupByColumns,Xi as hydrateTable,Gs as ingest,Ba as ingestResponse,Ks as ingestSync,Ta as initWithin,go as isLocalHost,fo as licenceInfo,po as licenceState,Pa as licenseInfo,Ca as licenseState,Bs as looksLikeFormula,yo as matchesDomain,oa as odataAdapter,xs as openWindow,$s as parseFormula,uo as parseLicence,$o as parseMoney,To as parseRadix,xo as parseUnit,Ls as pivot,Js as planQuery,Ia as queryParams,Uo as rateFunction,Yi as readTable,zs as referencesOf,lo as registerModules,Ro as registerUnitSystem,Qo as resolveCatalogue,Yo as resolveLocale,ra as resolveMutate,la as restAdapter,eo as restoreState,Na as restoreStateWithin,$a as rowsFromFragment,za as rowsFromJson,Ma as saveStateWithin,Ji as serialiseState,mo as setLicence,Aa as setLicense,ao as sharedRegistry,As as sortColumn,Ps as sortMulti,Ao as specToOoxml,ea as splitFilters,Ts as testValue,ja as toneOf,Ns as total,co as verifyLicence,no as version,Ua as warnIfLargeHtmlPayload,ho as watermark};
|
|
57
57
|
|
|
58
58
|
//# sourceMappingURL=htmx.esm.min.js.map
|